Hi
I have a JTable applet that implements querys with MySQL, and i have a couple of classes in my program. I made it using ECLIPSE, and when i run it using this code:


<body>
<applet code="AconsultaMysql.class" archive="mysql-connector-java-5.1.17-bin.jar" width="900" height="300">
</applet>
</body>
</html>

It is in a package called webconsultas and it calls the class nemed "ResultadoSetTableModel.class", i just wondered whats going wrong in my htlm code, or java's code.

I get the following:


java.lang.NoClassDefFoundError: AconsultaMysql (wrong name: webconsultas/AconsultaMysql)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Excepción: java.lang.NoClassDefFoundError: AconsultaMysql (wrong name: webconsultas/AconsultaMysql)

Regards

Manuel

Recommended Answers

All 7 Replies

NoClassDefFoundError: AconsultaMysql (wrong name: webconsultas/AconsultaMysql)

Is your class in a package? If so you need to include the package name in the code= tag:
code="webconsultas.AconsultaMysql"

Hi NormR1:
Yes it is in a package, but I already did what you say but still get the same error, I beliave that this error it's something related with the paths or some thing like that, in eclipse I'm working in the following workspace: MisApplets - src -webconsultas and it run fine into eclipse's IDE, so I take the two classes that the applet needs to run and i move them into the directory where the browser can find them.

Or maybe it's something else that i'm missing..

this is the code that you say with the same error result.

<html>
<head>
<body>
<applet code="webconsultas.AconsultaMysql.class" archive="mysql-connector-java-5.1.17-bin.jar" width="900" height="300">
</applet>
</body>
</html>

----------------------------
cargar: clase webconsultas.AconsultaMysql.class no encontrada.
java.lang.ClassNotFoundException: webconsultas.AconsultaMysql.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Excepción: java.lang.ClassNotFoundException: webconsultas.AconsultaMysql.class

ClassNotFoundException: webconsultas.AconsultaMysql.class

The ending .class is NOT part of the class name. It is part of the filename.
The browser adds ".class" to the class name to get the file name and it can not find that file.

Look at my last post. I did NOT code the file name (with ending .class)
I had the code= attribute refer only to the class name.

Ok you're right I got it! but still the same result

cargar: clase webconsultas.AconsultaMysql no encontrada.
java.lang.ClassNotFoundException: webconsultas.AconsultaMysql
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Excepción: java.lang.ClassNotFoundException: webconsultas.AconsultaMysql

Where are the all files you are using?
The html, the jar and the class files.
If the class files are in a package, they must be in a folder with the name of the package not in the same folder with the html and jar files.

It is simpler if you remove the package statement from the source, then everything can be in the same folder.

Hi NormR1,

I did the two ways, moved the class files to the folder with the name of the package and removed the package statement from the source, in bouth cases I get this new result.

------------------------------------------
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:286)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ResultadoSetTableModel.<init>(ResultadoSetTableModel.java:29)
at AconsultaMysql.<init>(AconsultaMysql.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$12.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at com.mysql.jdbc.StringUtils.<clinit>(StringUtils.java:70)
... 26 more
Excepción: java.lang.RuntimeException: java.lang.ExceptionInInitializerError

-------------------------------------------------

is this problem related with some additional configuration with mysql???

Caused by: java.lang.ExceptionInInitializerError
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:286)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at ResultadoSetTableModel.<init>(ResultadoSetTableModel.java:29)
at AconsultaMysql.<init>(AconsultaMysql.java:51)

This part of the stack trace looks like the problem is in mysql

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.