 |
Problems using JAX-WS 2.1 and JAXB 2.1 with JDK 6?
Posted by ramapulavarthi on January 12, 2007 at 12:12 AM | Comments (10)
When using JAX-WS 2.1 and JAXB 2.1 with JDK 6, you may see errors like this when running Web Services Tools (wsimport and wsgen) in JAX-WS 2.1 installation.
While invoking wsimport:
D:\work\jax-ws\test\>%JAXWS_HOME%\bin\wsimport -d temp hello_literal.wsdl
parsing WSDL...
generating code...
D:\work\jax-ws\test\temp\test\Hello_Service.java:63: cannot find symbol
symbol : method getPort(javax.xml.namespace.QName,java.lang.Class,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service
return (Hello)super.getPort(new QName("urn:test", "HelloPort"), Hello.class, features);
^
1 error
compilation failed, errors should have been reported
D:\work\jax-ws\test\>%JAXWS_HOME%\bin\wsimport -d temp hello_literal.wsdl
parsing WSDL...
Exception in thread "main" java.lang.LinkageError: JAXB 2.0 API is being loaded
from the bootstrap classloader, but this RI (from jar:file:/D:/work/axws-ri/lib/jaxb-impl.jar!
/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API.
Use the endorsed directory mechanism to place jaxb-api.jar i
n the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:135)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:389)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:253)
at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getJAXBContext(BindInfo.java:316)
at com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:195)
at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:502)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:211)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:69)
at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:119)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2159)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:179)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:127)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:146)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.ws.Invoker.WsimportMain(Invoker.java:78)
at com.sun.tools.ws.WsImport.main(WsImport.java:38)
While invoking wsgen:
Exception in thread "main" java.lang.LinkageError: JAXB 2.0 API is being loaded
from the bootstrap classloader, but this RI (from jar:file:/D:/work/jaxws-ri/lib/jaxb-impl.jar!
/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API.
Use the endorsed directory mechanism to place jaxb-api.jar i
n the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:135)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:389)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:253)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:84)
at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:86)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:126)
at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:125)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:124)
at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:63)
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:252)
at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:185)
at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.ws.Invoker.WsgenMain(Invoker.java:115)
at com.sun.tools.ws.WsGen.main(WsGen.java:38)
Sometimes its pretty clear what the error is, but not in all cases. JAXB 2.0 and JAX-WS 2.0 are part of JDK 6. To use JAX-WS 2.1 with JDK 6, newer versions of API jars (JAX-WS 2.1 and JAXB 2.1 API jars) need to be in bootclasspath before rt.jar. To do this you can use Java endorsed mechanism to override whats in Java platform. See http://java.sun.com/j2se/1.5.0/docs/guide/standards/ for more details on Endorsed Standards Override Mechanism.
To get around this issue, You can simply copy jaxb-api.jar, jaxws-api.jar to
<java-home>/lib/endorsed
Here <java-home> refers to the directory where the runtime software is installed (which is the top-level directory of the J2SE Runtime Environment or the jre directory in the JDK).
If you prefer to not change JDK,
For invoking wsimport and wsgen tools in JAX-WS 2.1, you can set WSIMPORT_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib & WSGEN_OPTS=-Djava.endorsed.dirs=%JAXWS_HOME%/lib, where JAXWS_HOME points to JAX-WS 2.1 installation.
If you use ant tasks, you can pass -Djava.endorsed.dirs=%JAXWS_HOME%/lib as jvmarg while calling wsimport and wsgen ant tasks. For this to work, you need to set fork="true" attribute of wsimport and wsgen ant tasks.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Thanks Rama, that was helpful!
Posted by: redhot on February 06, 2007 at 03:45 AM
-
please , how do i perform this for a webstart client ?
setting in the jnlp file to a working path for jax-ws api libs is doable ?.
i have not succeded yet.
im doing a standard WSIT webstart client ,using jdk 1.6 for both client and glassfish.
having the answer "switch to jre 1.5" as ive seen on some places, is abit scary and hardly acceptable solution.
Posted by: gustav3d on February 09, 2007 at 08:26 AM
-
seems my property from jnlp file got filtered:
property name="java.endorsed.dirs" value="xxx"
Posted by: gustav3d on February 09, 2007 at 08:28 AM
-
If you're using maven, you can specify the JAXB API version to use with the dependency tag:
< dependency>
< groupId> javax.xml.bind< /groupId>
< artifactId> jaxb-api< /artifactId>
< version> 2.0< /version>
< /dependency>
Posted by: openina on May 23, 2007 at 07:20 AM
-
Hi Rama,
I am facing the same problem of super.getPort even though I had used the -Xendorsed switch with wsimport.
I used your tip of setting WSIMPORT_OPTS ans WS_GEN_OPTS but still the error is there.
I could not locate the "endorsed" directory in JDK 1.6 nor JRE 1.6 directories.
Please help.
Posted by: nitinpai on August 19, 2007 at 07:53 AM
-
Hi Rama,
I just download jdk16u3 and am using the dailybuild of netbeans (from yesterday), and I'm still getting this error.
I've tried placing the "endorsed" folder in all my java_home\lib folder on my machine with no success. I'm not sure where to place -Dendorsed.dirs switch.
Any suggestions? I'm a java novice trying to build a simple webservice client.
Thanks.
Posted by: flemingho on October 05, 2007 at 09:42 AM
-
Actually it's working for me. Sorry.
Posted by: flemingho on October 06, 2007 at 04:13 AM
-
If you use netbeans and tomcat you should look at
http://wiki.netbeans.info/wiki/view/FaqEndorsedDirTomcat
Posted by: ofical2 on November 14, 2007 at 02:34 AM
-
You could also install the latest jdk1.6.4 version and run tomcat on that.
( http://java.sun.com/javase/downloads/index.jsp )
It fixes the problem !
Posted by: nocturnal on March 06, 2008 at 11:02 PM
-
I'm using Eclpise and I couldn't start the JBOSS 5.0 server initially for the same reason. After reading this I've simply updated JBOSS Server configuration to override class path. I've added the two libraries jaxb and jaxws ahead of jre1.6 in the 'bootstrap entries'. I didn't add to since i didn't feel it necessary. you can either put them together in your workspace or elsewhere. works fine.thanks for the advice.
Posted by: himutiger on March 18, 2008 at 03:58 AM
|