문제

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?

도움이 되었습니까?

해결책

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,

다른 팁

Yes, you should remove these from the webapp once they are in the endorsed dir.

If you try the Java EE version of Tomcat, TomEE Plus, JAX-WS support is already integrated and JAXB 2.2 is in the endorsed dir.

Tomcat 7 does NOT support JAX-WS out of box. To enable JAX-WS on Tomcat you need

  1. to include at least "catalina-ws.jar" in Tomcat's lib (not necessarly under "endorsed"!).

"catalina-ws.jar" should be downloaded as "Tomcat extras", and it is not included in TC7's default download archive.

  1. Include the "JAX-WS RI" libs in your web applications lib.

just try google "The Next Milestone: JAX-WS Web Service on Tomcat and JBoss", you would find more information about this topic.

(However for a Java EE container like JBoss 7, all libs are there already. )

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top