2017-11-02 17 views
0

JerseyにWebServiceをコンパイルする際に問題がありますが、その質問に対する多くの回答がありますが、私はtomcat 8.5でこれを実行しようとしています。すべての依存関係を設定し、mavenでダウンロードしてください。これはエラーです:MavenとJerseyライブラリを使用してREST WebServiceをコンパイルする際に問題が発生しました

nov 02, 2017 12:47:03 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
ADVERTÊNCIA: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:carros' did not find a matching property. 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server version:  Apache Tomcat/8.5.20 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server built:   Aug 2 2017 21:35:49 UTC 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Server number:   8.5.20.0 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: OS Name:    Windows 10 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: OS Version:   10.0 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Architecture:   x86 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Java Home:    C:\Program Files (x86)\Java\jdk1.8.0_151\jre 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: JVM Version:   1.8.0_151-b12 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: JVM Vendor:   Oracle Corporation 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: CATALINA_BASE:   C:\Users\PsychoPeres\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: CATALINA_HOME:   C:\Program Files\Apache Software Foundation\apache-tomcat-8.5.20 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dcatalina.base=C:\Users\PsychoPeres\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\apache-tomcat-8.5.20 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dwtp.deploy=C:\Users\PsychoPeres\eclipse-workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\apache-tomcat-8.5.20\endorsed 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.VersionLoggerListener log 
INFORMAÇÕES: Command line argument: -Dfile.encoding=Cp1252 
nov 02, 2017 12:47:03 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent 
INFORMAÇÕES: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files (x86)\Java\jdk1.8.0_151\jre\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_141/bin/server;C:/Program Files/Java/jre1.8.0_141/bin;C:/Program Files/Java/jre1.8.0_141/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\nodejs\;C:\Users\PsychoPeres\AppData\Local\Microsoft\WindowsApps;;C:\Program Files (x86)\Microsoft VS Code\bin;C:\Users\PsychoPeres\AppData\Roaming\npm;C:\eclipse;;.] 
nov 02, 2017 12:47:03 PM org.apache.coyote.AbstractProtocol init 
INFORMAÇÕES: Initializing ProtocolHandler ["http-nio-8080"] 
nov 02, 2017 12:47:03 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 
INFORMAÇÕES: Using a shared selector for servlet write/read 
nov 02, 2017 12:47:03 PM org.apache.coyote.AbstractProtocol init 
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-nio-8009"] 
nov 02, 2017 12:47:03 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector 
INFORMAÇÕES: Using a shared selector for servlet write/read 
nov 02, 2017 12:47:03 PM org.apache.catalina.startup.Catalina load 
INFORMAÇÕES: Initialization processed in 779 ms 
nov 02, 2017 12:47:03 PM org.apache.catalina.core.StandardService startInternal 
INFORMAÇÕES: Starting service [Catalina] 
nov 02, 2017 12:47:03 PM org.apache.catalina.core.StandardEngine startInternal 
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/8.5.20 
nov 02, 2017 12:47:07 PM org.apache.jasper.servlet.TldScanner scanJars 
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
nov 02, 2017 12:47:12 PM org.apache.jasper.servlet.TldScanner scanJars 
INFORMAÇÕES: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time. 
nov 02, 2017 12:47:12 PM org.apache.coyote.AbstractProtocol start 
INFORMAÇÕES: Starting ProtocolHandler ["http-nio-8080"] 
nov 02, 2017 12:47:12 PM org.apache.coyote.AbstractProtocol start 
INFORMAÇÕES: Starting ProtocolHandler ["ajp-nio-8009"] 
nov 02, 2017 12:47:12 PM org.apache.catalina.startup.Catalina start 
INFORMAÇÕES: Server startup in 8535 ms 
nov 02, 2017 12:47:23 PM org.apache.catalina.core.ApplicationContext log 
INFORMAÇÕES: Marking servlet [Jersey REST Service] as unavailable 
nov 02, 2017 12:47:23 PM org.apache.catalina.core.StandardWrapperValve invoke 
GRAVE: Allocate exception for servlet [Jersey REST Service] 
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer 
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1285) 
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:512) 
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:493) 
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:119) 
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1050) 
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:779) 
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:133) 
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:478) 
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:80) 
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650) 
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:799) 
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) 
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1457) 
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
    at java.lang.Thread.run(Thread.java:748) 

これはのpom.xml

<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>br.com.livro</groupId> 
    <artifactId>carros</artifactId> 
    <packaging>war</packaging> 
    <version>0.0.1-SNAPSHOT</version> 
    <name>carros Maven Webapp</name> 
    <url>http://maven.apache.org</url> 
    <!-- Dependências --> 
    <dependencies> 
     <!-- JUnit --> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     <!-- Servlet --> 
     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>javax.servlet-api</artifactId> 
      <version>3.0.1</version> 
      <scope>provided</scope> 
     </dependency> 
     <!-- MySQL --> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.35</version> 
      <scope>compile</scope> 
     </dependency> 
     <!-- Jersey --> 
     <dependency> 
      <groupId>org.glassfish.jersey.containers</groupId> 
      <artifactId>jersey-container-servlet</artifactId> 
      <version>2.18</version> 
     </dependency> 
     <!-- Google-GSON --> 
     <dependency> 
      <groupId>com.google.code.gson</groupId> 
      <artifactId>gson</artifactId> 
      <version>2.3.1</version> 
     </dependency> 
    </dependencies> 

    <build> 
     <finalName>carros</finalName> 
     <plugins> 
      <!-- Compiler --> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <configuration> 
        <source>1.8</source> 
        <target>1.8</target> 
        <encoding>UTF-8</encoding> 
       </configuration> 
      </plugin> 
     </plugins> 
    </build> 
</project> 

これは私がニュージャージー1を悪用多くの人々を見てるのWeb.xml

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" 
    id="WebApp_ID" version="3.0"> 
    <display-name>Carros</display-name> 
    <servlet> 
     <servlet-name>Jersey REST Service</servlet-name> 
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> 
     <init-param> 
      <param-name>javax.ws.rs.Application</param-name> 
      <param-value>br.com.livro.rest.MyApplication</param-value> 
     </init-param> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>Jersey REST Service</servlet-name> 
     <url-pattern>/rest/*</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

です.xとそのエラーを表示するが、私の依存関係で私は2.xのバージョンを使用していますが、まだエラーが表示されます。

答えて

0

は君たちに感謝され、今日、最後のバージョンは、私はそれを置くとき私は、私の展開アセンブリで私のMavenの依存関係を持っていなかったことを考え出しましたそれが働いていた。 ありがとうございました。

0

は、これを追加してみてください:

<dependency> 
    <groupId>org.glassfish.jersey.containers</groupId> 
    <artifactId>jersey-container-servlet-core</artifactId> 
    <version>2.18</version> 
</dependency> 

2.26

+0

jersey-container-servletをmavenに追加すると、コアもダウンロードされます。これは私の依存関係libにあります –

関連する問題