I'm having issues with an applet I'm trying to build and no matter what advice I have found over the past 2 days, nothing seems to work.
I have built an applet in Eclipse using web services (so there are multiple jars involved). When I run the .java file as an applet in Eclipse, it works fine. But, when I embed the applet within html, I get errors. See below:
Exception in thread "AWT-EventQueue-3" java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.client.AxisClient at org.apache.axis.client.Service.getAxisClient(Service.java:104) at org.apache.axis.client.Service.<init>(Service.java:113) at com.ngc.bmc2.tis.image.axis.service.ImageServiceLocator.<init>(ImageServiceLocator.java:12) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy._initImageServicePortTypeProxy(ImageServicePortTypeProxy.java:18) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy.<init>(ImageServicePortTypeProxy.java:8) at com.ngc.sb.tis.image.axis.service.client.TisImageryClient.paint(TisImageryClient.java:18) at sun.awt.RepaintArea.paintComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(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) Exception in thread "AWT-EventQueue-4" java.lang.NoClassDefFoundError: Could not initialize class org.apache.axis.client.AxisClient at org.apache.axis.client.Service.getAxisClient(Service.java:104) at org.apache.axis.client.Service.<init>(Service.java:113) at com.ngc.bmc2.tis.image.axis.service.ImageServiceLocator.<init>(ImageServiceLocator.java:12) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy._initImageServicePortTypeProxy(ImageServicePortTypeProxy.java:18) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy.<init>(ImageServicePortTypeProxy.java:8) at com.ngc.sb.tis.image.axis.service.client.TisImageryClient.paint(TisImageryClient.java:18) at sun.awt.RepaintArea.paintComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(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) -----------------------------------------------------------------------
Here is my directory structure:
C:\~~~~\EclipseProject\WebContent\Applet --> index.html file C:\~~~~\EclipseProject\WebContent\Applet\classes --> class files from both my web service client and the web service C:\~~~~\EclipseProject\WebContent\Applet\lib --> jar files of the applet and web service
I thought that it might be a java version issue since the applet I created was in 1.6 and the web service was based on 1.5, but that cannot be right because it would not have worked when I ran it in Eclipse.
Any help would be appreciated because I have been killing myself for two straight days on this trying to find the answer.
If any other information is needed please let me know.
Thanks, B
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35257
7
posted
0
Shouldn't all the "../lib/applet.jar" entries really be "lib/applet.jar" instead, since the lib directory is in the same directory as the HTML file?
I didn't think so, since I set my codebase attribute as classes which is within the Applet directory.
Even still, I tried changing it to "lib/applet.jar" instead of "../lib/applet.jar" and this time I got:
Exception in thread "AWT-EventQueue-3" java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceException at com.ngc.sb.tis.image.axis.service.client.TisImageryClient.paint(TisImageryClient.java:18) at sun.awt.RepaintArea.paintComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(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.lang.ClassNotFoundException: javax.xml.rpc.ServiceException at sun.applet.AppletClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.applet.AppletClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) ... 14 more
Which leads me to believe that it could not find the jaxrpc.jar file.
Thanks though.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35257
7
posted
0
I didn't think so, since I set my codebase attribute as classes which is within the Applet directory.
Let me rephrase it not as question but as a hint : You do need to change it in the way I indicated, because the archive attribute and the codebase attribute are independent of each other.
Even still, I tried changing it to "lib/applet.jar" instead of "../lib/applet.jar" and this time I got: ... Which leads me to believe that it could not find the jaxrpc.jar file.
You need to change all the other jar file locations in the same way.
Brendan Crisler
Greenhorn
Joined: Feb 07, 2007
Posts: 19
posted
0
Sorry for the confusion, but when I said:
Even still, I tried changing it to "lib/applet.jar" instead of "../lib/applet.jar"
I meant that I did change all of them.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35257
7
posted
0
Also make sure that none of the files has any permissions set that would prevent it from being served (try downloading through the browser).
A last resort is a look at the web server access logs, to see which files the browser is trying to access, and whether or not it's succeeding.
Brendan Crisler
Greenhorn
Joined: Feb 07, 2007
Posts: 19
posted
0
Well, checked the permissions on all of the jar files and they seem fine. I was also able to navigate through the web browser and download several jar files just to check the directory locations worked fine, with no errors. I changed the directory locations for all the jars in the archive back to "../lib/<file>". According to the error and access logs on my Apache server, there are no errors. The GETs know where to pull the jar files from and I don't see any errors. Here are the Apache server logs:
-------------------------------------- Error.log --------------------------------------- [Tue Mar 18 15:11:17 2008] [notice] Apache/2.2.6 (Win32) PHP/5.2.5 configured -- resuming normal operations [Tue Mar 18 15:11:17 2008] [notice] Server built: Sep 5 2007 08:58:56 [Tue Mar 18 15:11:17 2008] [notice] Parent: Created child process 1848 [Tue Mar 18 15:11:17 2008] [notice] Child 1848: Child process is running [Tue Mar 18 15:11:17 2008] [notice] Child 1848: Acquired the start mutex. [Tue Mar 18 15:11:17 2008] [notice] Child 1848: Starting 250 worker threads. [Tue Mar 18 15:11:17 2008] [notice] Child 1848: Starting thread to listen on port 8080. ------------------------------------------
So.... when I try to load the applet again from the browser, this shows up in my Java Console:
Exception in thread "AWT-EventQueue-3" java.lang.ExceptionInInitializerError at org.apache.commons.discovery.jdk.JDKHooks.<clinit>(JDKHooks.java:75) at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:412) at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378) at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45) at java.security.AccessController.doPrivileged(Native Method) at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41) at org.apache.axis.components.logger.LogFactory.<clinit>(LogFactory.java:33) at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43) at org.apache.axis.client.Service.getAxisClient(Service.java:104) at org.apache.axis.client.Service.<init>(Service.java:113) at com.ngc.bmc2.tis.image.axis.service.ImageServiceLocator.<init>(ImageServiceLocator.java:12) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy._initImageServicePortTypeProxy(ImageServicePortTypeProxy.java:18) at com.ngc.bmc2.tis.image.axis.service.ImageServicePortTypeProxy.<init>(ImageServicePortTypeProxy.java:8) at com.ngc.sb.tis.image.axis.service.client.TisImageryClient.paint(TisImageryClient.java:18) at sun.awt.RepaintArea.paintComponent(Unknown Source) at sun.awt.RepaintArea.paint(Unknown Source) at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(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.lang.RuntimePermission createClassLoader) 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.checkCreateClassLoader(Unknown Source) at java.lang.ClassLoader.<init>(Unknown Source) at org.apache.commons.discovery.jdk.PsuedoSystemClassLoader.<init>(PsuedoSystemClassLoader.java:73) at org.apache.commons.discovery.jdk.JDK12Hooks.findSystemClassLoader(JDK12Hooks.java:215) at org.apache.commons.discovery.jdk.JDK12Hooks.<clinit>(JDK12Hooks.java:73) ... 27 more
-----------------------------------------------
Now, I've seen these errors before and it seemed to lead me to Signed Jars as a solution. Is this really what I have to do? Or hopefully something else should work. Is there some type of security setting in the server I need to modify?
No, that's a client thing. Signing the applet or altering your the security policy are the two ways around this; see HowCanAnAppletReadFilesOnTheLocalFileSystem for details.
I didn't know that the Axis libraries create a classloader even when used as a client. But then, I've never used them in an applet, always in applications, so security restrictions were not an issue. (Actually, it looks like the logging framework does this, which seems a way too complicated thing to do.) [ March 18, 2008: Message edited by: Ulf Dittmer ]
John Rodey
Greenhorn
Joined: Mar 04, 2010
Posts: 1
posted
0
Did any of this help? I am running in to the same problem.
I have tried signing my applet jar.
I have tried altering my java.policy file.
I have tried AccessController.doPrivileged().
None have worked for me! Any help is greatly appreciated!!!
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35257
7
posted
0
Well, signing all involved jar files should fix this problem (possibly also requiring the doPrivileged thing).
gkumar raghu
Greenhorn
Joined: Jul 15, 2010
Posts: 1
posted
0
make sure you have included commons-discovery-0.4.jar and commons-logging.jar in jboss lib directory