Skip to main content

Tip for using JAX-WS 2.2/ Metro 2.0 with Tomcat 6.x on JDK 6

Posted by ramapulavarthi on April 3, 2009 at 4:24 PM PDT

If you trying to use JAX-WS 2.2 on top of JDK 6, you run into classloading problems. Resonating with the problems we had with using JAX-WS 2.1 on JDK 6 FCS?, Dejavu !!!.

As you guessed, JDK 6 (U4 and later) has JAX-WS implementation with JAX-WS 2.1 API. If you try to use JAX-WS 2.2, the runtime always picks up the JAX-WS API from bootclasloader and will not see JAX-WS 2.2 API in your classpath. Well, the solution is the same, i.e, using the endorsed overriding mechanism. This has been documented and discussed before.

But how do you configure for Web Services running on Tomcat 6 using JDK 6. Its easy with Tomcat 5.5, you just need to copy jaxws-api.jar and jaxb-api.jar into $TOMCAT_HOME/common/endorsed directory. But there are some changes in classloading in Tomcat 6.x and there is no documentation on the default endorsed directory.

Here it is, you have to create endorsed directory in $TOMCAT_HOME and Copy jax-ws.api.jar and jaxb-api.jar from JAX-WS (webservices-api.jar in case of Metro) to $TOMCAT_HOME/endorsed. You might also find my other blog on running JAX-WS samples on Tomcat 6.x useful.

I am putting here one of the problems one would see when using JAX-WS 2.2 features without endorsed mechanism. For ex, if you are using AddressingFeature.Responses added in JAX-WS 2.2 API, you would get


SEVERE: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoSuchMethodError: javax.xml.ws.soap.Addressing.responses()Ljavax/xml/ws/soap/AddressingFeature$Responses;
java.lang.NoSuchMethodError: javax.xml.ws.soap.Addressing.responses()Ljavax/xml/ws/soap/AddressingFeature$Responses;



Follow the above tip to configure the endorsed directory and it should work.

Technorati:

JAX-WS

Tomcat 6

Related Topics >>

Comments

Copied the following jars from my netbeans jax22 directory ...

Copied the following jars from my netbeans jax22 directory and endorsed dir to $APACHE_HOME/endorsed - But, it does not seem to help me yet. Please advise.

(Note- I am using netbeans 7 and apache 7)

ls endorsed/
jaxb-api.jar jaxws-api.jar

Deployment errors -

symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service
super(__getWsdlLocation(), CALCULATORWSSERVICE_QNAME, features);

symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service
super(wsdlLocation, CALCULATORWSSERVICE_QNAME, features);

symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
location: class javax.xml.ws.Service
super(wsdlLocation, serviceName, features);
3 errors

Thanks for posting!

Adding the webservices-api.jar to TOMCAT_HOME/endorsed as you write fixed the problem I was having. I was trying to get Tomcat 6 to accept the webservices-api.jar in my $JRE_HOME/lib/endorsed directory but was always getting this error (including here to help future googlers):

SEVERE: Exception sending context initialized event to listener instance of class com.sun.xml.ws.transport.http.servlet.WSServletContextListener com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: [failed to localize] JAX-WS 2.1 API is loaded from file:/work/myapps/jdk1.6.0_18/jre/lib/rt.jar, But JAX-WS runtime requires JAX-WS 2.2 API. Use the endorsed standards override mechanism to load JAX-WS 2.2 API ()

at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:139)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)

Apparently Tomcat 6 just ignores the files placed in the JRE's endorsed directory, you have to place them in the $TOMCAT_HOME/endorsed for things to work. This is even if you place the webservices-*.jars in the WEB-INF/lib of the web service provider WAR as I have.

Seems its still picking up classes from JDK. Did you copy jax-ws.api.jar and jaxb-api.jar from JAX-WS (webservices-api.jar in case of Metro) to $TOMCAT_HOME/endorsed as it says in this blog?

Hello Ramapulavarthi , For web service implementation I am using JDK1.6.06 with jax-ws2.1 on tomcat 6. In that while calling web service from servlet I am getting following issues 1) in case of fault response Could not initialize class com.sun.xml.internal.ws.fault.SOAPFaultBuilder 2) In case success response Could not initialize class com.sun.xml.internal.ws.message.AttachmentUnmarshallerImpl As you told I put all the web service lib in shard lib and updated its location in catilina.conf. Still I am facing issue. is it releated to JVM or tomcat library? Please provide your comment.