2017-02-22 244 views
0

我正在嘗試部署我的maven項目ws-producer。我不知道從哪裏開始找到這個錯誤的原因。該項目通過超級pom連接到另一個名爲ws-interface的項目。我不確定我應該提供給誰以識別此問題,因此請隨時索取更多信息。maven tomcat部署soap webservice錯誤

-ws製片pom-

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>nl.hu.fnt.gsos</groupId> 
    <artifactId>ws-producer</artifactId> 
    <packaging>war</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <parent> 
     <groupId>nl.hu.fnt.gsos</groupId> 
     <artifactId>ws-parent</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <name>Producer Maven Webapp</name> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.ws</groupId> 
      <artifactId>jaxws-rt</artifactId> 
      <scope>provided</scope> 
     </dependency> 
     <dependency> 
      <groupId>nl.hu.fnt.gsos</groupId> 
      <artifactId>ws-interface</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.6</version> 
      <scope>provided</scope> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>ws-producer</finalName> 
     <plugins> 
      <plugin> 
       <groupId>org.apache.tomcat.maven</groupId> 
       <artifactId>tomcat7-maven-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

-ws接口pom-

<project 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>nl.hu.fnt.gsos</groupId> 
    <artifactId>ws-interface</artifactId> 
    <packaging>jar</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Webservice interface project</name> 
    <parent> 
     <groupId>nl.hu.fnt.gsos</groupId> 
     <artifactId>ws-parent</artifactId> 
     <version>1.0-SNAPSHOT</version> 
    </parent> 
    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
     </dependency> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.ws</groupId> 
      <artifactId>jaxws-rt</artifactId> 
      <version>2.2.5</version> 
      <exclusions> 
       <exclusion> 
        <artifactId>istack-commons-runtime</artifactId> 
        <groupId>com.sun.istack</groupId> 
       </exclusion> 
      </exclusions> 
     </dependency> 
     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.6</version> 
      <scope>runtime</scope> 
     </dependency> 
    </dependencies> 
    <build> 
     <finalName>ws-interface</finalName> 
     <plugins> 
      <plugin> 
       <groupId>org.jvnet.jax-ws-commons</groupId> 
       <artifactId>jaxws-maven-plugin</artifactId> 
       <configuration> 
        <!-- Needed with JAXP 1.5 --> 
        <vmArgs> 
         <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg> 
        </vmArgs> 
       </configuration> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-install-plugin</artifactId> 
       <version>2.4</version> 
       <executions> 
        <execution> 
         <phase>install</phase> 
         <goals> 
          <goal>install-file</goal> 
         </goals> 
         <configuration> 
          <groupId>nl.hu.fnt.gsos</groupId> 
          <artifactId>ws-interface</artifactId> 
          <version>1.0-SNAPSHOT</version> 
          <packaging>jar</packaging> 
          <file>${basedir}/target/ws-interface.jar</file> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

-super pom-

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
          http://maven.apache.org/maven-v4_0_0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>nl.hu.fnt.gsos</groupId> 
    <artifactId>ws-parent</artifactId> 
    <packaging>pom</packaging> 
    <version>1.0-SNAPSHOT</version> 
    <name>Simple parent project for GSOS purpose</name> 

    <modules> 
     <module>ws-interface</module> 
     <module>ws-producer</module> 
     <module>ws-consumer</module> 
    </modules> 

    <dependencyManagement> 
     <dependencies> 
      <dependency> 
       <groupId>junit</groupId> 
       <artifactId>junit</artifactId> 
       <version>3.8.1</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>javax.servlet</groupId> 
       <artifactId>servlet-api</artifactId> 
       <version>2.5</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>com.sun.xml.ws</groupId> 
       <artifactId>jaxws-rt</artifactId> 
       <version>2.2.8</version> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>nl.hu.fnt.gsos</groupId> 
       <artifactId>ws-interface</artifactId> 
       <scope>compile</scope> 
       <version>1.0-SNAPSHOT</version> 
      </dependency> 
      <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.11</version> 
     </dependency> 

     <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-core</artifactId> 
      <version>2.2.11</version> 
     </dependency> 

     </dependencies> 
    </dependencyManagement> 
    <build> 
     <pluginManagement> 
      <plugins> 
       <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-compiler-plugin</artifactId> 
        <version>3.1</version> 
        <configuration> 
         <source>1.7</source> 
         <target>1.7</target> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.jvnet.jax-ws-commons</groupId> 
        <artifactId>jaxws-maven-plugin</artifactId> 
        <version>2.3</version> 
        <executions> 
         <execution> 
          <id>wsimport-from-jdk</id> 
          <goals> 
           <goal>wsimport</goal> 
          </goals> 
          <phase>generate-sources</phase> 
         </execution> 
        </executions> 
        <configuration> 
         <!--wsdls file directory --> 
         <wsdlDirectory>src/main/webapp/wsdl/</wsdlDirectory> 
         <!-- which wsdl file --> 
         <wsdlFiles> 
          <wsdlFile>BookService.wsdl</wsdlFile> 
         </wsdlFiles> 
         <!-- Keep generated files --> 
         <keep>true</keep> 
         <!-- Package name --> 
         <packageName>nl.hu.fnt.gsos.wsinterface</packageName> 
         <!-- generated source files destination --> 
         <!-- <sourceDestDir>target/generated-code/src</sourceDestDir> --> 
        </configuration> 
       </plugin> 
       <plugin> 
        <groupId>org.apache.tomcat.maven</groupId> 
        <artifactId>tomcat7-maven-plugin</artifactId> 
        <version>2.2</version> 
        <configuration> 
         <server>tomcatappserver</server> 
         <url>http://localhost:5471/manager/text</url> 
         <username>tomcat</username> 
         <password>s3cret</password> 
        </configuration> 
       </plugin> 
       <plugin> 
        <inherited>true</inherited> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-eclipse-plugin</artifactId> 
        <version>2.8</version> 
        <configuration> 
         <skip>false</skip> 
         <downloadSources>true</downloadSources> 
         <downloadJavadocs>true</downloadJavadocs> 
         <projectNameTemplate>[artifactId]</projectNameTemplate> 
         <wtpmanifest>true</wtpmanifest> 
         <wtpapplicationxml>true</wtpapplicationxml> 
         <useProjectReferences>true</useProjectReferences> 
         <wtpapplicationxml>true</wtpapplicationxml> 
         <wtpversion>1.5</wtpversion> 
         <!-- wtpdefaultserver>${eclipse.ear.runtime.name}</wtpdefaultserver --> 
        </configuration> 
        <executions> 
         <execution> 
          <id>synchronise-eclipse-eclipse</id> 
          <phase>generate-resources</phase> 
          <goals> 
           <goal>eclipse</goal> 
          </goals> 
          <inherited>true</inherited> 
         </execution> 
         <execution> 
          <id>synchronise-eclipse-clean</id> 
          <phase>clean</phase> 
          <goals> 
           <goal>clean</goal> 
          </goals> 
          <inherited>true</inherited> 
         </execution> 
        </executions> 
       </plugin> 

      </plugins> 
     </pluginManagement> 
    </build> 
    <repositories> 
     <repository> 
      <id>java.net2</id> 
      <name>Repository hosting the jee6 artifacts</name> 
      <url>http://download.java.net/maven/2</url> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>codehaus</id> 
      <name>Codehaus REPO</name> 
      <url>http://repository.codehaus.org</url> 
      <layout>default</layout> 
      <releases> 
       <enabled>true</enabled> 
       <updatePolicy>always</updatePolicy> 
       <checksumPolicy>warn</checksumPolicy> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
       <updatePolicy>never</updatePolicy> 
       <checksumPolicy>fail</checksumPolicy> 
      </snapshots> 

     </pluginRepository> 
     <pluginRepository> 
      <id>java.net2</id> 
      <name>Repository hosting the jee6 artifacts</name> 
      <url>http://download.java.net/maven/2</url> 
     </pluginRepository> 
    </pluginRepositories> 

</project> 

-Sun-jaxws.xml-

<?xml version="1.0" encoding="UTF-8"?> 
<endpoints 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/jax-ws/ri/runtime http://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/2.0/jaxws/sun-jaxws.xsd" 
    xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0"> 
    <endpoint name="ws-producer" implementation="nl.hu.fnt.gsos.wsproducer.BookServiceImpl" 
     url-pattern="/ws-producer" /> 
</endpoints> 

-BookServiceImpl.java-

package nl.hu.fnt.gsos.wsproducer; 

import javax.jws.WebService; 

import nl.hu.fnt.gsos.wsinterface.BookRequestType; 
import nl.hu.fnt.gsos.wsinterface.BookResponseType; 
import nl.hu.fnt.gsos.wsinterface.IBookService; 
import nl.hu.fnt.gsos.wsinterface.ObjectFactory; 

@WebService(endpointInterface= "nl.hu.fnt.gsos.wsinterface.IBookService") 
public class BookServiceImpl implements IBookService { 

    @Override 
    public BookResponseType getBookByISDNRequestNumber(BookRequestType request) { 
     ObjectFactory factory = new ObjectFactory(); 
     BookResponseType response = factory.createBookResponseType(); 
     try{ 

     } catch (RuntimeException e){ 

     } 
     return response; 
    } 

} 

- 錯誤對數

22-Feb-2017 21:48:22.618 SEVERE [http-apr-8009-exec-45] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing 
javax.servlet.ServletException: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoClassDefFoundError: com/sun/xml/bind/api/JAXBRIContext 
    at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:70) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5240) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 
    at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1284) 
    at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:666) 
    at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:648) 
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:136) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) 
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240) 
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522) 
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095) 
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672) 
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2500) 
    at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2489) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    at java.lang.Thread.run(Thread.java:745) 
Caused by: com.sun.xml.ws.transport.http.servlet.WSServletException: WSSERVLET11: failed to parse runtime descriptor: java.lang.NoClassDefFoundError: com/sun/xml/bind/api/JAXBRIContext 
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:141) 
    at com.sun.xml.ws.transport.http.servlet.WSServletContainerInitializer.onStartup(WSServletContainerInitializer.java:65) 
    ... 34 more 
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/bind/api/JAXBRIContext 
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:255) 
    at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:99) 
    at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:74) 
    at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:58) 
    at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:120) 
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:521) 
    at com.sun.xml.ws.server.EndpointFactory.create(EndpointFactory.java:300) 
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:164) 
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:577) 
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:560) 
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:303) 
    at com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:179) 
    at com.sun.xml.ws.transport.http.servlet.WSServletContextListener.parseAdaptersAndCreateDelegate(WSServletContextListener.java:131) 
    ... 35 more 
Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.api.JAXBRIContext 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 48 more 

22-Feb-2017 21:48:22.621 SEVERE [http-apr-8009-exec-45] org.apache.catalina.core.StandardContext.startInternal Context [/ws-producer] startup failed due to previous errors 

回答

1

其實錯誤日誌顯示確切的問題。

需要的類com.sun.xml.bind.api.JAXBRIContext不在您的服務器或應用程序類路徑中。 (這是你在課堂路徑中必須具備的瞬態依賴)。

它位於JAXB-IMPL-x.x.x.jar(X.X.X - 是一個版本爲例JAXB-IMPL-2.2.6.jar)

這取決於你用什麼容器。

容器像JBoss有,但你的不。

所以,你的期權數量: 1.把它放在系統類路徑 2.把它放在服務器類路徑 3.包裝它與您的WAR文件。 這樣做在你的項目POM文件添加像

 <dependencies> 
      <dependency> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      <version>2.2.6</version> 
      <scope>runtime</scope> 
      </dependency> 
     </dependencies> 

注依賴性。不在<dependencyManagement>元素在「super pom」

+0

感謝您的回答,但是這確實解決了我的問題。然而,你可能是對的,因爲我無法在生成的war librarie文件夾中找到任何依賴關係。所以,在項目ws-interface和ws-producer中,我的pom文件肯定有問題。我將它們添加到我原來的帖子中。 – Colivar

+0

我通過編輯提供的範圍編輯ws-producer pom的依賴項來解決它。你有什麼想法爲什麼有人會把它提供?再次感謝給我正確的提示,讓我朝着正確的方向前進。 – Colivar

+0

你的pom沒有錯。如果需要的jar文件在類路徑中,則不需要將另一個打包到war文件中。所以,需要的範圍是'提供'。這是特定於戰爭或耳朵文件。這意味着在編譯期間,Maven把它放到類路徑中,但不打包它。 'compile'或'runtime'作用域迫使Maven將jar文件打包到WAR/EAR中。而已。所以正如我經常說的那樣,jaxb-impl或其他實現已經在類路徑中,所以'provided'是最好的選擇。 – Vadim