2013-09-27 111 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> 

我希望這個作品,爲新人們誰將會面臨這個問題

問候

相關問題