+ Start a Discussion

JAXWS - Classpath problem

I have a swing application where I use JAXWS to generate classes from a salesforce wsdl file.  Everything works fine in my NetBeans environment.

When I package up the software for release, the call to login to the salesforce web service gets the following exception:
url.toString() = file:/C:/Program%20Files/GST/LOB/bin/App.jarException in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: javax.xml.ws.WebFault.messageName()Ljava/lang/String;
    at com.sun.xml.ws.model.RuntimeModeler.processExceptions(RuntimeModeler.java:1162)
    at com.sun.xml.ws.model.RuntimeModeler.processDocBareMethod(RuntimeModeler.java:1330)
    at com.sun.xml.ws.model.RuntimeModeler.processMethod(RuntimeModeler.java:663)
    at com.sun.xml.ws.model.RuntimeModeler.processClass(RuntimeModeler.java:420)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:254)
    at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:661)
    at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:649)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:343)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:326)
    at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:308)
    at javax.xml.ws.Service.getPort(Unknown Source)
    at com.sforce.soap.enterprise.SforceService.getSoap(SforceService.java:74)
    at com.generatedsystems.afs.sf.SfConnector.doLogin(Unknown Source)
    at com.generatedsystems.afs.task.AFSTask.sendDataToSf(Unknown Source)
    at com.generatedsystems.afs.app.AFSExecutableTask.btn1ActionPerformed(Unknown Source)
    at com.generatedsystems.afs.app.AFSExecutableTask.access$200(Unknown Source)
    at com.generatedsystems.afs.app.AFSExecutableTask$3.actionPerformed(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(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.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.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)

So javax.xml.ws.WebFault.messageName() method is not found.  When running in the jre, this class is in rt.jar and indeed that method does not exist in the class.  The correct method exists in a jar file called jaxws-api.jar.  My problem is that even after placing the jar first in my classpath, the jvm still seems to use the WebFault class from the rt.jar.  

After some digging, I think I found the problem, being that rt.jar is part of the delivered jre, the jvm will always choose that jar over one on my classpath.  So then I thought the proper solution was to use the system property java.endorsed.dirs to inform the jvm to use the jar I wanted it to.  This mechanism is described here: http://java.sun.com/javase/6/docs/technotes/guides/standards/

I implemented the setting of that property to my jar and the jvm is still using the WebFault from the rt.jar in the jre.

Am I missing something here?

Thanks for any help.

Best Answer chosen by Admin (Salesforce Developers) 

Thanks for the reply.  I fugured out the problem.


Initially I was setting the java.endorsed.dirs property in my code (ie: after the JVM was already running) setting it as a parameter on JVM startup fixed the issue.

All Answers

If you're using jax ws 2.2, using the endorsed mechanism is necessary, unfortunately. You could try dropping the jar in $JAVA_HOME/jre/lib/endorsed (jdk) or $JAVA_HOME/lib/endorsed (jre) if the system property isn't . I'm pretty sure those are the right paths. :)

Thanks for the reply.  I fugured out the problem.


Initially I was setting the java.endorsed.dirs property in my code (ie: after the JVM was already running) setting it as a parameter on JVM startup fixed the issue.

This was selected as the best answer