2013-09-27 116 views
4

我有一个包含Web服务的标准J2EE Web应用程序。我正在使用webservices-rt库来承载这些服务。 [见下面的maven dependency]。不过,我得到以下异常在运行时:在部署Web应用程序时,出现NoClassDefFoundError异常:LocalizableImpl

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/ws/util/localization/LocalizableImpl 
    at com.sun.xml.ws.util.exception.JAXWSExceptionBase.<init>(JAXWSExceptionBase.java:63) 
    at com.sun.xml.ws.transport.http.servlet.WSServletException.<init>(WSServletException.java:47) 
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:118) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4791) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5285) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [...] 
    at java.lang.Thread.run(Thread.java:724) 
Caused by: java.lang.ClassNotFoundException: com.sun.xml.ws.util.localization.LocalizableImpl 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) 
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) 
    ... 33 more 

Maven的WS依赖

<dependency> 
     <groupId>com.sun.xml.ws</groupId> 
     <artifactId>webservices-rt</artifactId> 
     <version>1.4</version> 
     <scope>compile</scope> 
    </dependency> 

我缺少一个库?我试过加入jaxws-rt。但是,这需要额外的回购[jboss]。我对此有点怀疑,因为它为这个项目引入了很多新的库。

回答

0

声明JBoss回购不会自动导入回购库。它只是使库可用于导入。

底线是,如果你想使用库中的类,那么你必须把库拉入你的项目。如果库在JBoss仓库中,那么你必须声明JBoss仓库。

+1

我明白,但它也引入了JBoss平台可能使用的库。我希望引入执行任务所需的最少外部库。 – monksy

+0

我在回应你说你不愿意声明JBoss回购的部分,因为你担心它可能会引入额外的依赖关系。这不应该是一个担心,因为声明回购没有拉入依赖关系。如果某个特定的依赖项牵扯到您不想要的其他依赖项,则可以使用依赖项排除。 –

1

尝试

的JAX-WS依赖库“JAXWS-rt.jar中的”缺失。

去这里http://jax-ws.java.net/

下载JAX-WS RI分布。

解压缩并将“jaxws-rt.jar”复制到Tomcat库文件夹“{$ TOMCAT}/lib”中。

重新启动Tomcat。

+2

复制意大利面http://www.mkyong.com/webservices/jax-ws/java-lang-classnotfoundexception-com-sun-xml-ws-transport-http-servlet-wsservletcontextlistener/? – Lan

0

对于行家,Tomcat应用程序尝试在你的pom.xml这些依赖

<dependencies> 
    <!-- jax-ws maven dependency --> 
    <dependency> 
     <groupId>com.sun.xml.ws</groupId> 
     <artifactId>jaxws-rt</artifactId> 
     <version>2.2.8</version> 
    </dependency> 
    <!-- servlet provided by tomcat --> 
    <dependency> 
     <groupId>javax.servlet</groupId> 
     <artifactId>javax.servlet-api</artifactId> 
     <version>3.1.0</version> 
     <scope>provided</scope> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core --> 
    <dependency> 
     <groupId>com.sun.xml.bind</groupId> 
     <artifactId>jaxb-core</artifactId> 
     <version>2.2.7</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.sun.xml.stream.buffer/streambuffer --> 
    <dependency> 
     <groupId>com.sun.xml.stream.buffer</groupId> 
     <artifactId>streambuffer</artifactId> 
     <version>1.5.3</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl --> 
    <dependency> 
     <groupId>com.sun.xml.bind</groupId> 
     <artifactId>jaxb-impl</artifactId> 
     <version>2.2.7</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/com.sun.xml.ws/policy --> 
    <dependency> 
     <groupId>com.sun.xml.ws</groupId> 
     <artifactId>policy</artifactId> 
     <version>2.3.1</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.glassfish.gmbal/gmbal-api-only --> 
    <dependency> 
     <groupId>org.glassfish.gmbal</groupId> 
     <artifactId>gmbal-api-only</artifactId> 
     <version>3.2.0-b003</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.glassfish.ha/ha-api --> 
    <dependency> 
     <groupId>org.glassfish.ha</groupId> 
     <artifactId>ha-api</artifactId> 
     <version>3.1.9</version> 
    </dependency> 
</dependencies> 

我希望这个作品,为新人们谁将会面临这个问题

问候

相关问题