您好以前我使用的是tomcat 7并且正在tomcat 7(在Linux服务器上)部署我的war文件。现在我已经安装了tomcat8(在linux服务器上),但它没有部署我的war文件。我的配置是:
下图中的最后一个是我的Web应用程序。
米
我的Web.xml文件是:
<web-app 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"
version="3.0">
<display-name>DL Access</display-name>
<listener>
<listener-class>
com.dl.pretasks.PreTasks
</listener-class>
</listener>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.dl.dlaccess.service</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>jersey-serlvet1</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.dl.contentTags.service</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>jersey-serlvet2</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.dl.contentTags.service</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<servlet-name>jersey-serlvet3</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.dl.changeApiStatus.service</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/dl/dlaccess/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jersey-serlvet1</servlet-name>
<url-pattern>/dl/content/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jersey-serlvet2</servlet-name>
<url-pattern>/dl/content/cron</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jersey-serlvet3</servlet-name>
<url-pattern>/apistatus/*</url-pattern>
</servlet-mapping>
<error-page>
<location>/defaultErrorPage.jsp</location>
</error-page>
</web-app>
我的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>svc</groupId>
<artifactId>svc</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>svc Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- <dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId>
<version>0.9.0</version> </dependency> -->
<dependency>
<groupId>com.github.ptgoetz</groupId>
<artifactId>storm-signals</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.storm</groupId>
<artifactId>storm-core</artifactId>
<version>0.9.1-incubating</version>
<exclusions>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>javax.servlet</groupId>
</exclusion>
<exclusion>
<artifactId>servlet-api</artifactId>
<groupId>org.mortbay.jetty</groupId>
</exclusion>
<exclusion>
<artifactId>asm</artifactId>
<groupId>org.ow2.asm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.2.0</version>
<exclusions>
<exclusion>
<artifactId>javax.servlet</artifactId>
<groupId>org.glassfish</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>0.98.4-hadoop2</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.0.0</version>
</dependency>
<!-- <dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId>
<version>1.0</version>
</dependency>
<!-- <dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
<version>1.0</version>
<scope>runtime</scope>
</dependency> -->
</dependencies>
<build>
<finalName>svc</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Tomcat日志文件:
16-Nov-2014 20:27:44.985 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version: Apache Tomcat/8.0.14
16-Nov-2014 20:27:44.987 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built: Sep 24 2014 09:01:51
16-Nov-2014 20:27:44.987 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number: 8.0.14.0
16-Nov-2014 20:27:44.987 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name: Linux
16-Nov-2014 20:27:44.987 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version: 3.13.0-37-generic
16-Nov-2014 20:27:44.987 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture: amd64
16-Nov-2014 20:27:44.988 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version: 1.7.0_67-b01
16-Nov-2014 20:27:44.988 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor: Oracle Corporation
16-Nov-2014 20:27:45.295 INFO [main] org.apache.catalina.core.AprLifecycleListener.init The APR based Apache Tomcat Native library which allows optimal performance in production environments was n$
16-Nov-2014 20:27:45.520 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-22410"]
16-Nov-2014 20:27:45.536 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Nov-2014 20:27:45.539 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
16-Nov-2014 20:27:45.543 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
16-Nov-2014 20:27:45.543 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 636 ms
16-Nov-2014 20:27:45.568 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service Catalina
16-Nov-2014 20:27:45.569 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.0.14
16-Nov-2014 20:27:45.609 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive /etc/tools/tomcat-8.0.14/webapps/svc.war
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
16-Nov-2014 20:27:50.074 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
16-Nov-2014 20:27:50.080 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/svc] startup failed due to previous errors
16-Nov-2014 20:27:50.091 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive /etc/tools/tomcat-8.0.14/webapps/svc.war has finished i$
16-Nov-2014 20:27:50.094 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /etc/tools/tomcat-8.0.14/webapps/docs
16-Nov-2014 20:27:50.145 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /etc/tools/tomcat-8.0.14/webapps/docs has finis$
16-Nov-2014 20:27:50.146 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /etc/tools/tomcat-8.0.14/webapps/examples
16-Nov-2014 20:27:50.437 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /etc/tools/tomcat-8.0.14/webapps/examples has f$
16-Nov-2014 20:27:50.437 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /etc/tools/tomcat-8.0.14/webapps/ROOT
16-Nov-2014 20:27:50.460 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /etc/tools/tomcat-8.0.14/webapps/ROOT has finis$
16-Nov-2014 20:27:50.460 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /etc/tools/tomcat-8.0.14/webapps/manager
16-Nov-2014 20:27:50.491 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /etc/tools/tomcat-8.0.14/webapps/manager has fi$
16-Nov-2014 20:27:50.491 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory /etc/tools/tomcat-8.0.14/webapps/host-manager
16-Nov-2014 20:27:50.516 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory /etc/tools/tomcat-8.0.14/webapps/host-manager h$
16-Nov-2014 20:27:50.526 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-22410"]
16-Nov-2014 20:27:50.535 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
16-Nov-2014 20:27:50.540 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 4996 ms
在我的ubuntu机器上,这个Web应用程序在tomcat上正常运行。但是当我在ubuntu服务器上进行检索并想要访问时,它会开始创建404错误。我不认为web.xml或pom.xml存在一些问题,因为在这种情况下它不应该部署在我的本地机器上。
有什么建议吗?
答案 0 :(得分:2)
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.
SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
16-Nov-2014 20:27:50.074 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Error listenerStart
16-Nov-2014 20:27:50.080 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.startInternal Context [/svc] startup failed due to previous errors
解决.jars之间的这种冲突应该是第一步。应删除其中一个。
答案 1 :(得分:0)
在POM.xml中使用以下标签
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>