This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Applets and the fly likes Applet Axis Client Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet Axis Client Errors" Watch "Applet Axis Client Errors" New topic
Author

Applet Axis Client Errors

Brendan Crisler
Greenhorn

Joined: Feb 07, 2007
Posts: 19
Help!

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

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

Here is the html code:

<html>
<title>Applet Test</title>
<body>
<h1>Applet Test</h1>
<applet codebase="classes" code="com.ngc.sb.tis.image.axis.service.client.TisImageryClient.class"
height="300" width="300" archive="../lib/applet.jar,../lib/axis.jar,../lib/jaxrpc.jar,
../lib/commons-discovery-0.2.jar,../lib/commons-logging.jar,../lib/saaj.jar,../lib/wsdl4j-1.5.1.jar">
</applet>
</body>
</html>

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

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: 41046
    
  43
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?


Ping & DNS - my free Android networking tools app
Brendan Crisler
Greenhorn

Joined: Feb 07, 2007
Posts: 19
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: 41046
    
  43
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
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: 41046
    
  43
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
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:

Access.log
---------------------------------------------------
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet HTTP/1.1" 301 237
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/ HTTP/1.1" 200 396
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/applet.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/axis.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/jaxrpc.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/commons-discovery-0.2.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/commons-logging.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/saaj.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/lib/wsdl4j-1.5.1.jar HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/classes/com/ngc/sb/tis/image/axis/service/client/TisImageryClient.class HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/classes/com/ngc/bmc2/tis/image/axis/service/ImageServicePortTypeProxy.class HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/classes/com/ngc/bmc2/tis/image/axis/service/ImageServicePortType.class HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /favicon.ico HTTP/1.1" 200 1772
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/classes/com/ngc/bmc2/tis/image/axis/service/ImageServiceLocator.class HTTP/1.1" 304 -
127.0.0.1 - - [18/Mar/2008:15:11:50 -0500] "GET /Applet/classes/com/ngc/bmc2/tis/image/axis/service/ImageService.class HTTP/1.1" 304 -

--------------------------------------
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?

Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43


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
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: 41046
    
  43
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
make sure you have included commons-discovery-0.4.jar and commons-logging.jar in jboss lib directory
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet Axis Client Errors
 
Similar Threads
file reading in applet
Facing problem while running Java Applets
Accesing an EJB code in applet using JBOSS
Exception while loading applet
Getting parameters from the htmp page