我看到很多关于它的话题,但没有一个与确切的场景,然后没有一个解决我的。
我有一个简单的网络应用程序,其中包含一些其他端点。我使用Maven的Jersey原型配置了这个应用程序,现在一切正常。 今天我在项目中创建了一个Maven更新项目,现在,当我从Eclipse启动Tomcat时,它没有找到org.glassfish.jersey.servlet.ServletContainer类。相信我,它工作正常。
我试图删除tomcat的安装并重新配置它,但没有任何作用。我是一个疯子'出来了!
这是Tomcat日志中的错误:
Fev 02, 2017 9:19:43 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:AcmeEAI' did not find a matching property.
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server version: Apache Tomcat/7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server built: Nov 7 2016 21:27:23 UTC
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Server number: 7.0.73.0
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Name: Linux
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: OS Version: 3.19.0-32-generic
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Architecture: amd64
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Java Home: /usr/lib/jvm/jdk1.7.0_79/jre
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Version: 1.7.0_79-b15
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: JVM Vendor: Oracle Corporation
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_BASE: /home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: CATALINA_HOME: /home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.base=/home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dcatalina.home=/home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dwtp.deploy=/home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73/wtpwebapps
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Djava.endorsed.dirs=/home/luizgustavoss/Dev/Servers/apache-tomcat-7.0.73/endorsed
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.VersionLoggerListener log
INFORMAÇÕES: Command line argument: -Dfile.encoding=UTF-8
Fev 02, 2017 9:19:43 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: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
Fev 02, 2017 9:19:43 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["http-bio-8080"]
Fev 02, 2017 9:19:43 PM org.apache.coyote.AbstractProtocol init
INFORMAÇÕES: Initializing ProtocolHandler ["ajp-bio-8009"]
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.Catalina load
INFORMAÇÕES: Initialization processed in 571 ms
Fev 02, 2017 9:19:43 PM org.apache.catalina.core.StandardService startInternal
INFORMAÇÕES: Starting service Catalina
Fev 02, 2017 9:19:43 PM org.apache.catalina.core.StandardEngine startInternal
INFORMAÇÕES: Starting Servlet Engine: Apache Tomcat/7.0.73
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.TldConfig execute
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.
Fev 02, 2017 9:19:43 PM org.apache.catalina.core.ApplicationContext log
INFORMAÇÕES: Marking servlet Jersey Web Application as unavailable
Fev 02, 2017 9:19:43 PM org.apache.catalina.core.StandardContext loadOnStartup
GRAVE: Servlet [Jersey Web Application] in web application [/AcmeEAI] threw load() exception
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1133)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Fev 02, 2017 9:19:43 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["http-bio-8080"]
Fev 02, 2017 9:19:43 PM org.apache.coyote.AbstractProtocol start
INFORMAÇÕES: Starting ProtocolHandler ["ajp-bio-8009"]
Fev 02, 2017 9:19:43 PM org.apache.catalina.startup.Catalina start
INFORMAÇÕES: Server startup in 647 ms
这是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>acme.corp.integration</groupId>
<artifactId>AcmeEAI</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Acme EAI Webapp</name>
<url>http://maven.apache.org</url>
<build>
<finalName>AcmeEAI</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
</dependency>
<!-- uncomment this to get JSON support -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<!-- Logging dependencies -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<jersey.version>2.25</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
这是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="false">
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>acme.corp.integration.rest, acme.corp.integration.common.rest</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<resource-ref>
<description>postgreSQL Datasource</description>
<res-ref-name>jdbc/postgres</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Jersey jars正如预期的那样在war文件lib目录中:
jar file where org.glassfish.jersey.servlet.ServletContainer is
关于环境的事情:
我使用Eclipse Luna,Maven插件和instalations都很好,我使用的是Tomcat 7.操作系统是Linux Mint。
所以,我没有看到任何配置问题,因为我说它工作正常。战争文件中有泽西罐子,汤姆猫根本就没看到它。
有什么想法吗?
祝你好运
答案 0 :(得分:3)
我只是不明白为什么即使使用战争文件中的球衣罐也不起作用。
祝你好运!