Skip to main content

NoSuchMethodError: com.sun.xml.bind.api.JAXBRIContext.newInstance

10 replies [Last post]
robmacgrogan
Offline
Joined: 2009-01-28

Hello. I am relatively new to JAXWS. I used Apache SOAP for many years, so there has been something of a learning curve. Please forgive me if I use some of the terminology incorrectly.

Until today I was using (I believe) the "native" JAX-WS that comes with J2ee and/or the Glassfish J2EE server. All was working well except that I could not send or receive large binaries. So, I followed the instructions for working with large binaries, which required me to download JAXWS-RI (2.1.7). I included all of the jar files in the JAXWS-RI lib directory in both my client and server applications. Not sure if this was required or not. I then went through the steps to use the StreamingDataHandler, re ran wsgen, built and deployed my server, re ran wsimport, recompiled my client, and attempted to run my client application.

Now, however, whenever I try to access any of my remote JAXWS methods (not just the new one that uses streaming data handler) I get a NoSuchMethod error on the client side (full stacktrace at the end of this message). I really am completely stumped as to why this would happen. I assume there is an incompatibility in my client classpath somewhere--somehow one of the new JAXWS-RI jars conflicts with something else, but I really don't know what.

In case it's helpful, here's a list of all the Jars in my client classpath (I'm using Eclipse):

activation.jar (from JAXWS-RI distribution)
antlr-2.7.6.jar
commons-collections-3.1.jar
commons-logging-1.1.1.jar
dom4j-1.6.1.jar
hibernate3.jar
hsqldb.jar
javassist-3.4.GA.jar
jaxws-rt.jar (from JAXWS-RI distribution)
jta-1.1.jar
mail.jar
mime-util-1.2.jar
odfdom.jar
org-netbean-swing-outline.jar
poi-3.2.jar
poi-contrib-3.2.jar
poi-scratchpad-3.2.jar
slf4j-api-1.5.2.jar
slf4j-jdk14-1.5.2.jar
stax-ex.jar (from JASWS-RI distribution)
xercesImpl.jar

Also, using JDK1.6.0_10

Thanks, in advance, for any help you can give.

Here's the stacktrace:

Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: com.sun.xml.bind.api.JAXBRIContext.newInstance([Ljava/lang/Class;Ljava/util/Collection;Ljava/util/Map;Ljava/lang/String;ZLcom/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader;)Lcom/sun/xml/bind/api/JAXBRIContext;
at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:109)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:159)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:152)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:151)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:255)
at com.sun.xml.ws.client.WSServiceDelegate.createSEIPortInfo(WSServiceDelegate.java:698)
at com.sun.xml.ws.client.WSServiceDelegate.addSEI(WSServiceDelegate.java:686)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:341)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:324)
at com.sun.xml.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:306)
at javax.xml.ws.Service.getPort(Service.java:92)
at org.sourcejammer.server.service.SessionServiceService.getSessionServicePort(SessionServiceService.java:51)
at org.revisions.client.remote.ServiceFactory.getSessionService(ServiceFactory.java:92)
at org.revisions.client.remote.ArchiveConnector.createConnection(ArchiveConnector.java:45)
at org.revisions.client.remote.ArchiveConnector.getConnection(ArchiveConnector.java:26)
at org.revisions.client.command.ViewFileDetailsCommand.execute(ViewFileDetailsCommand.java:22)
at org.revisions.client.gui.action.ViewFileDetailsAction.actionPerformed(ViewFileDetailsAction.java:26)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6134)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5899)
at java.awt.Container.processEvent(Container.java:2023)
at java.awt.Component.dispatchEventImpl(Component.java:4501)
at java.awt.Container.dispatchEventImpl(Container.java:2081)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4301)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3965)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3895)
at java.awt.Container.dispatchEventImpl(Container.java:2067)
at java.awt.Window.dispatchEventImpl(Window.java:2458)
at java.awt.Component.dispatchEvent(Component.java:4331)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
robmacgrogan
Offline
Joined: 2009-01-28

I've done a bit more experimenting. I tried adding back all the classes in jaxws-ri/lib to my client application but to no avail. Then I noticed that the call to JAXBRIContext.newInstance() is coming from com.sun.xml.ws.developer.JAXBContextFactory, which is part of jaxws-rt.jar.

Anyway, the stacktrace shows that JAXBContextFactory is attempting to call JAXBRIContext.newInstance(Class, Collection, Map, String, RuntimeAnnotationReader). However, this method does not appear to exist in the version of JAXBRIContext distributed in the jaxb-impl.jar distributed with jaxws-ri. The closest approximation is newInstance(Class[]. Collection, Map, String boolean, RuntimeAnnotationReader).

Is this a bug in the JAXWS2.1.7-20090419 distribution?

robmacgrogan
Offline
Joined: 2009-01-28

I tried using jaxws-ri 2.1.5 but got the same result, so this is not a bug in the 2.1.7 distribution. I also added the jaxb-api.jar and jaxws-api.jar files to my JDK/jre/lib/endorsed directory. However, the problem persists. If I add jaxws-rt.jar to my client classpath, I get this issue. If I remove it, the issue goes away. Has anyone else experienced this problem?

Please help. I'm really stuck.

Thanks.

robmacgrogan
Offline
Joined: 2009-01-28

I have tried to get this working six different ways to Sunday on two completely different machines. Whatever I do I get the same result. If I include the jaxws-rt.jar (or the webservices-rt.jar from the latest Glassfish) I get some permutation of the no such method error.

Please, if anyone has gotten StreamingDataHandler to work please give me a hand.

robmacgrogan
Offline
Joined: 2009-01-28

Still nothing? Really? I consistently get this error on two different machines, 1 Ubuntu/Linux and the other Windows XP. Can anyone out there help?

Martin Grebac

You might be getting some clash with the JDK classes which contain both
JAXB and JAX-WS or some left-over jars in endorsed directories?
MartinG

metro@javadesktop.org wrote:
> Still nothing? Really? I consistently get this error on two different machines, 1 Ubuntu/Linux and the other Windows XP. Can anyone out there help?
> [Message sent by forum member 'robmacgrogan' (robmacgrogan)]
>
> http://forums.java.net/jive/thread.jspa?messageID=344045
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
> For additional commands, e-mail: users-help@metro.dev.java.net
>
>

--
Martin Grebac, http://blogs.sun.com/mgrebac

Web Technologies & Standards
Sun Microsystems Czech

ICQ: 93478885

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@metro.dev.java.net
For additional commands, e-mail: users-help@metro.dev.java.net

bhaktimehta
Offline
Joined: 2004-03-18

Can you try with metro 1.5 https://metro.dev.java.net/1.5/
It has jaxws 2.1.7 integrated. All you will need is download metro and unzip it and Take a backup of your orignal webservices-* jars from GF/lib and replace all the webservices-*.jar from metro 1.5 to your GF/lib and that will avoid these kinds of errors

I hope that should work for you

Regards,
Bhakti

robmacgrogan
Offline
Joined: 2009-01-28

This suggestion did not help me with my problem.

Here's what I did:

* Downloaded Metro 1.5
* Removed jaxb-api.jar and jaxws-api.jar from jre/lib/endorsed
* Placed webservices-api.jar from Metro 1.5 into jre/lib/endorsed
* Removed the webservice*.jar files from my glassfish/lib directory
* Copied the new metro1.5 webservice*.jar files into glassfish/lib, excluding webservice-api.jar
* Copied metro 1.5 webservice-api.jar into glassfish/lib/endorsed
* Put the webservice jars from metro 1.5 into the classpath for my server application (excluding webservice-api.jar)
* Regenerated webservices using wsgen
* Rebuilt my server application and deployed it to Glassfish
* Put the webservice jars from Metro 1.5 into my client classpath (excluding webservice-api.jar)
* Re-imported my services using wsimport

Now I get a slightly different permutation of the same error. This time the class that can't find JAXBRIContext.getInstance() is RmVersion. Please see the stacktrace below. It seems that RmVersion is looking for JAXBRIContext.getInstance(Class, Collection, Map, String, RuntimeAnnotationReader), which does not seem to be a valid method in the version of JAXBRIContext in webservices-rt.jar from Metro1.5.

This would be a whole lot easier to debug if there were a distribution of the 1.5 jars that included source.

java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.policy.AssertionValidationProcessor
at com.sun.xml.ws.policy.EffectiveAlternativeSelector.doSelection(EffectiveAlternativeSelector.java:157)
at com.sun.xml.ws.policy.jaxws.WSDLPolicyMapWrapper.doAlternativeSelection(WSDLPolicyMapWrapper.java:142)
at com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension.postFinished(PolicyWSDLParserExtension.java:1047)
at com.sun.xml.ws.wsdl.parser.DelegatingParserExtension.postFinished(DelegatingParserExtension.java:187)
at com.sun.xml.ws.wsdl.parser.WSDLParserExtensionFacade.postFinished(WSDLParserExtensionFacade.java:334)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:149)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:265)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:228)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:176)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.(Service.java:56)
at org.sourcejammer.server.service.AdminServiceService.(AdminServiceService.java:42)
at org.revisions.client.remote.ServiceFactory.initAdminService(ServiceFactory.java:99)
at org.revisions.client.remote.ServiceFactory.(ServiceFactory.java:43)
at org.revisions.client.remote.ArchiveConnector.createConnection(ArchiveConnector.java:41)
at org.revisions.client.remote.ArchiveConnector.getConnection(ArchiveConnector.java:26)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderer.addOutOfSyncFiles(OutOfSyncFileListRenderer.java:67)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderer.prepareOutOfSyncFiles(OutOfSyncFileListRenderer.java:52)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderRunner$RendererThread.run(OutOfSyncFileListRenderRunner.java:72)
java.lang.NullPointerException
at org.revisions.client.remote.ServiceFactory.getSessionService(ServiceFactory.java:87)
at org.revisions.client.remote.ArchiveConnector.createConnection(ArchiveConnector.java:45)
at org.revisions.client.remote.ArchiveConnector.getConnection(ArchiveConnector.java:26)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderer.addOutOfSyncFiles(OutOfSyncFileListRenderer.java:67)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderer.prepareOutOfSyncFiles(OutOfSyncFileListRenderer.java:52)
at org.revisions.client.gui.renderer.OutOfSyncFileListRenderRunner$RendererThread.run(OutOfSyncFileListRenderRunner.java:72)
java.lang.NoSuchMethodError: com.sun.xml.bind.api.JAXBRIContext.newInstance([Ljava/lang/Class;Ljava/util/Collection;Ljava/util/Map;Ljava/lang/String;ZLcom/sun/xml/bind/v2/model/annotation/RuntimeAnnotationReader;)Lcom/sun/xml/bind/api/JAXBRIContext;
at com.sun.xml.ws.rm.RmVersion.(RmVersion.java:189)
at com.sun.xml.ws.rm.RmVersion.(RmVersion.java:57)
at com.sun.xml.ws.rm.policy.assertion.Rm10Assertion.(Rm10Assertion.java:64)
at com.sun.xml.ws.rm.policy.spi_impl.RmAssertionValidator.(RmAssertionValidator.java:65)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.xml.ws.policy.privateutil.ServiceFinder$LazyIterator.next(ServiceFinder.java:378)
at com.sun.xml.ws.policy.privateutil.ServiceFinder.toArray(ServiceFinder.java:228)
at com.sun.xml.ws.policy.privateutil.PolicyUtils$ServiceProvider.load(PolicyUtils.java:445)
at com.sun.xml.ws.policy.AssertionValidationProcessor.(AssertionValidationProcessor.java:55)
at com.sun.xml.ws.policy.EffectiveAlternativeSelector.doSelection(EffectiveAlternativeSelector.java:157)
at com.sun.xml.ws.policy.jaxws.WSDLPolicyMapWrapper.doAlternativeSelection(WSDLPolicyMapWrapper.java:142)
at com.sun.xml.ws.policy.jaxws.PolicyWSDLParserExtension.postFinished(PolicyWSDLParserExtension.java:1047)
at com.sun.xml.ws.wsdl.parser.DelegatingParserExtension.postFinished(DelegatingParserExtension.java:187)
at com.sun.xml.ws.wsdl.parser.WSDLParserExtensionFacade.postFinished(WSDLParserExtensionFacade.java:334)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:149)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:265)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:228)
at com.sun.xml.ws.client.WSServiceDelegate.(WSServiceDelegate.java:176)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104)
at javax.xml.ws.Service.(Service.java:56)
at org.sourcejammer.server.service.AdminServiceService.(AdminServiceService.java:42)
at org.revisions.client.remote.ServiceFactory.initAdminService(ServiceFactory.java:99)
at org.revisions.client.remote.ServiceFactory.(ServiceFactory.java:43)
at org.revisions.client.remote.ArchiveConnector.createConnection(ArchiveConnector.java:41)
at org.revisions.client.remote.ArchiveConnector.getConnection(ArchiveConnector.java:26)
at org.revisions.client.command.GetArchiveStatsAndMessages.execute(GetArchiveStatsAndMessages.java:18)
at org.revisions.client.gui.main.DashboardPanel.buildMessagePanel(DashboardPanel.java:93)
at org.revisions.client.gui.main.DashboardPanel.initGui(DashboardPanel.java:62)
at org.revisions.client.gui.main.DashboardPanel.(DashboardPanel.java:36)
at org.revisions.client.gui.main.MainTabContainer.populateTabPanels(MainTabContainer.java:80)
at org.revisions.client.gui.main.MainTabContainer.(MainTabContainer.java:39)
at org.revisions.client.gui.main.RevisionsGuiClient.(RevisionsGuiClient.java:52)
at org.revisions.client.gui.main.RevisionsGuiClient.launchClient(RevisionsGuiClient.java:100)
at org.revisions.client.gui.main.RevisionsGuiClient.main(RevisionsGuiClient.java:132)
java.lang.NullPointerException
at org.revisions.client.remote.ServiceFactory.getSessionService(ServiceFactory.java:87)
at org.revisions.client.remote.ArchiveConnector.createConnection(ArchiveConnector.java:45)
at org.revisions.client.remote.ArchiveConnector.getConnection(ArchiveConnector.java:26)
at org.revisions.client.command.GetArchiveStatsAndMessages.execute(GetArchiveStatsAndMessages.java:18)
at org.revisions.client.gui.main.DashboardPanel.buildMessagePanel(DashboardPanel.java:93)
at org.revisions.client.gui.main.DashboardPanel.initGui(DashboardPanel.java:62)
at org.revisions.client.gui.main.DashboardPanel.(DashboardPanel.java:36)
at org.revisions.client.gui.main.MainTabContainer.populateTabPanels(MainTabContainer.java:80)
at org.revisions.client.gui.main.MainTabContainer.(MainTabContainer.java:39)
at org.revisions.client.gui.main.RevisionsGuiClient.(RevisionsGuiClient.java:52)
at org.revisions.client.gui.main.RevisionsGuiClient.launchClient(RevisionsGuiClient.java:100)
at org.revisions.client.gui.main.RevisionsGuiClient.main(RevisionsGuiClient.java:132)

robmacgrogan
Offline
Joined: 2009-01-28

I was finally able to get this resolved. It looks like there was an older version of jaxb-rt and jaxws-rt lurking in my classpath and I did not realize it. Thanks.

parshuramjuwekar
Offline
Joined: 2010-02-17

Yes, i was able to resolve the problem after removing older version of jaxb-impl.jar from classpath.

Thank you Guys.

rkg_java
Offline
Joined: 2007-03-20

Now after placing the jars, I am getting the below problem. Please help me in sorting out this problem.

SEVERE: Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener

java.lang.NoClassDefFoundError: com/sun/xml/bind/api/TypeReference

at com.sun.xml.ws.modeler.RuntimeModeler.processRpcMethod(RuntimeModeler.java:750)

at com.sun.xml.ws.modeler.RuntimeModeler.processMethod(RuntimeModeler.java:508)

at com.sun.xml.ws.modeler.RuntimeModeler.processClass(RuntimeModeler.java:353)

at com.sun.xml.ws.modeler.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:249)

at com.sun.xml.ws.server.RuntimeEndpointInfo.createModel(RuntimeEndpointInfo.java:180)

at com.sun.xml.ws.server.RuntimeEndpointInfo.init(RuntimeEndpointInfo.java:326)

at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.createModelAndMetadata(WSServletContextListener.java:203)

at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:119)

at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3795)

at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)

at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1173)

at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:550)

at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:105)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:627)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:563)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)

at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:843)

at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:679)

at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1293)