java - WAR 文件未在 tomcat 7 中启动

标签 java maven tomcat

我无法启动使用 maven 编译的 war 文件。当我在不添加依赖项的情况下编译应用程序时,它可以正常启动,但是在添加依赖项之后,出现以下错误。我使用的开发环境是windows 7,java SE6,maven 3.0.5。

这是tomcat 7产生的错误

Oct 16, 2013 4:56:34 PM org.apache.catalina.startup.ContextConfig processServletContainerInitializers
SEVERE: Failed to process JAR found at URL [jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/F_Quote-1.0-SNAPSHOT/WEB-INF/lib/primefaces-3.4.jar!/] for ServletContainerInitializers for context with name [/F_Quote-1.0-SNAPSHOT]
Oct 16, 2013 4:56:34 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
Oct 16, 2013 4:56:34 PM org.apache.catalina.startup.TldConfig tldScanJar
WARNING: Failed to process JAR [jar:file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%207.0/webapps/F_Quote-1.0-SNAPSHOT/WEB-INF/lib/primefaces-3.4.jar!/] for TLD files
java.util.zip.ZipException: invalid CEN header (bad signature)

下面是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">  
<modelVersion>4.0.0</modelVersion>
  <groupId>com.farchis</groupId>
  <artifactId>F_Quote</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>Farchis Estimator</name>

  <repositories>
    <repository>
        <id>prime-repo</id> 
        <name>PrimeFaces Maven Repository</name>
        <url>http://repository.primefaces.org</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.3.0.Beta4</version>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.0.1.Final</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>     
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-webflow</artifactId>
        <version>2.3.2.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc14</artifactId>
        <version>10.2.0.1.0</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
    <dependency>
        <groupId>com.sun.facelets</groupId>
        <artifactId>jsf-facelets</artifactId>
        <version>1.1.14</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-impl</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>com.sun.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.2.3</version>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>20030825.184428</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
    <!-- 
        The JSP/Servlet API libraries are appserver implementation dependent and belongs 
        in case of Tomcat 6 in the Tomcat/lib folder and should in no way be moved
         nor duplicated somewhere else
        bug fix add <scope>provided</scope>
    -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>         
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>3.2.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>2.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.1.4.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.primefaces</groupId>
        <artifactId>primefaces</artifactId>
        <version>3.4</version>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>3.0</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-entitymanager</artifactId>
        <version>4.2.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.webflow</groupId>
        <artifactId>spring-faces</artifactId>
        <version>2.3.1.RELEASE</version>
    </dependency>
  </dependencies>
</project>

最佳答案

在 WAR 文件中添加依赖项后会出现此问题。因此您可以从 local repository 中删除所有这些依赖项并重新生成 JAR 文件。

您仍然面临一些问题,然后尝试使用 Tomcat 6.0。以前我也遇到过同样的问题,我更换了我的 Tomcat,它对我来说运行良好。

关于java - WAR 文件未在 tomcat 7 中启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19420187/

相关文章:

java - 为 Swing 库强制使用 EDT 线程

java - 如何使用maven执行第三方jar

Java:解析大文件大小:NumberFormatException

java - token "}"的语法错误,但我真的找不到它

maven - Gemfile.lock 在 Maven 和 gradle 中等效

java - 基本 Spring-Security MVC 应用程序中的 404 错误

tomcat - Heroku Java Tomcat ServletContextListener 不在 slugc 或重启时调用 contextDestroyed

tomcat - 无法访问在 Docker 容器中启动的 Tomcat

java - HTTP 状态 404 -/com.demo/rest/hello - 使用 Rest 项目

tomcat - 使用java代码停止tomcat中的Web应用程序