在tomcat中通过hudson进行部署时出错

时间:2014-11-24 08:30:55

标签: spring maven tomcat jpa hudson

我有一个maven项目,在我的本地环境中运行完美。但是当我在DEV环境中部署它时,它会在部署时发出以下错误并停止任何进一步的部署步骤,服务器就会上升。

log4j:ERROR A "org.apache.log4j.xml.DOMConfigurator" object is not assignable to a "org.apache.log4j.spi.Configurator" variable.
log4j:ERROR The class "org.apache.log4j.spi.Configurator" was loaded by
log4j:ERROR [org.apache.catalina.loader.StandardClassLoader@19968e23] whereas object of type
log4j:ERROR "org.apache.log4j.xml.DOMConfigurator" was loaded by [WebappClassLoader
  context: /cloud
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@19968e23
].
log4j:ERROR Could not instantiate configurator [org.apache.log4j.xml.DOMConfigurator].
log4j:WARN No appenders could be found for logger (com.att.security.web.servlet.filters.CSPCookieFilter).
log4j:WARN Please initialize the log4j system properly.

我在catalina日志中看到了这一点。部署始终成功,但应用程序无法正常运行。当我将我的应用程序从spring 3.2.0升级到3.2.7时,它开始出现,因为我想使用JPA 2.1规范并直接调用过程。

作为一种解决方法,我必须清除工作区并通过hudson重新部署构建,然后手动重新启动tomcat 7.0.52服务器以使应用程序正常工作。在这种情况下,错误来了,但应用程序工作正常。

我的POM看起来像这样:

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <javax.version>3.0.1</javax.version>
    <org.springframework.version>3.2.7.RELEASE</org.springframework.version>
    <hibernate.version>4.3.4.Final</hibernate.version>
    <tiles.version>2.2.2</tiles.version>
    <org.slf4j-version>1.7.5</org.slf4j-version>
    <ehcache.version>2.8.0</ehcache.version>
    <apache.poi-version>3.9</apache.poi-version>
    <junit-version>4.8.1</junit-version>
    <mockito-version>1.8.5</mockito-version>
</properties>

    <!-- utilities to convert java objects to JSON objects -->
<dependencies>
    <!-- Java Servlet APIs -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>${javax.version}</version>
    </dependency>
    <dependency>
        <groupId>javax.persistence</groupId>
        <artifactId>persistence-api</artifactId>
        <version>1.0.2</version>
    </dependency>
    <dependency>
        <groupId>org.codehaus.jackson</groupId>
        <artifactId>jackson-mapper-asl</artifactId>
        <version>1.9.12</version>
    </dependency>
    <!-- JSTL Support -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <!-- Spring Libraries -->
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-jpa</artifactId>
        <version>1.6.0.RELEASE</version>
    </dependency>
    <dependency>
       <groupId>org.hibernate</groupId>
       <artifactId>hibernate-entitymanager</artifactId>
       <version>${hibernate.version}</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit-version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>${mockito-version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-digester</groupId>
        <artifactId>commons-digester</artifactId>
        <version>1.8</version>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-servlet</artifactId>
        <version>${tiles.version}</version>
        <exclusions>
            <exclusion>
                <groupId>commons-digester</groupId>
                <artifactId>commons-digester</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.tiles</groupId>
        <artifactId>tiles-jsp</artifactId>
        <version>${tiles.version}</version>
    </dependency>

    <!-- Java Mail API -->
    <dependency>
        <groupId>javax.mail</groupId>
        <artifactId>mail</artifactId>
        <version>1.4.3</version>
    </dependency>

    <!-- Support for logger used by spring frameworks -->

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>${org.slf4j-version}</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>${org.slf4j-version}</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache</artifactId>
        <version>${ehcache.version}</version>
    </dependency>

    <dependency>
        <groupId>com.sun.xml.parsers</groupId>
        <artifactId>jaxp-ri</artifactId>
        <version>1.4.1</version>
      </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>${apache.poi-version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi-ooxml</artifactId>
        <version>${apache.poi-version}</version>
    </dependency>
</dependencies>

我对我的申请做了最近的更改:
1.包括Javamail API依赖关系
2.将spring-jpa-data依赖性从1.3.4升级到1.6.0 3.将弹簧基座版本从3.2.0增加到3.2.7

我在网上搜索但没找到适合我的东西。请指导。该应用程序将在一周内进入PROD,我不想坚持我的解决方法。

任何帮助都是预先赞赏的,因为我在发布问题后没有声誉也这样做:)

1 个答案:

答案 0 :(得分:1)

您必须在两个Tomcat库和Web应用程序库中放置log4j.jar。你必须选择并保留其中一个。