Deploying JAX-WS webapp in Tomcat 7

RickDavis picture RickDavis · Jul 24, 2012 · Viewed 13.2k times · Source

I am developing simple JAX-WS webservice. I am creating WAR file using ANT build script. The file when deployed to Tomcat 7 server, throws following exception and there is deployment error as follows.

JAXB 2.1 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/D:/DreamSoln/Server/apache-tomcat-7.0.29/webapps/WebserviceDemo/WEB-INF/lib/jaxb-impl.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.2 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader.

I have JDK 1.6 installed, I tried endorsed mechanism i.e. I created lib/endorsed directory and copied jaxb-api.jar and jaxws-api.jar in it. But still it does not work.

Do I need to remove jaxb-api.jar and jaxws-api.jar from WEB-INF/lib of my web-app?

What else needs to be done?

Answer

ggarciao picture ggarciao · Jul 24, 2012

I think that you are not endorsing correctly the tomcat lib. The folder lib/endorsed was used in previous version of tomcat (like Tomcat 5.5 if I remembered correctly) but in the new ones (Tomcat 6 and afterwards) the endorsed lib is usually at <TOMCAT_HOME>/endorsed (if it does not exist, you have to create it).

Actually, tomcat use the system property java.endorsed.dirs to define the endorsed folder location. So please check this value in your tomcat installation.

How to check this? Printing this property in any servlet/listener that you have in your application.

Example Using a context listener (inspired from this blog)

public class WebappLoadListener implements ServletContextListener {

    public void contextDestroyed(ServletContextEvent arg0) {
    }

    public void contextInitialized(ServletContextEvent arg0) {
        System.out.println("\n\n\n ENDORSED DIR: " +System.getProperty("java.endorsed.dirs"));      
    }
}

Hoping it helps,