在Tomcat 8

时间:2015-06-29 09:09:26

标签: java spring maven spring-mvc tomcat

当我尝试在Tomcat 8上运行项目时,我收到了这个非常奇怪的错误:

  

INFO o.s.web.context.ContextLoader - Root WebApplicationContext:初始化已启动   。 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - 刷新根WebApplicationContext:启动日期[Mon Jun 29 10:59:34 CEST 2015];上下文层次结构的根   。 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - 注册带注释的类:[class com ...]

     

错误o.s.web.context.ContextLoader - 上下文初始化失败   java.lang.IllegalAccessError:试图访问方法org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava / lang / Object;来自org.springframework.context.event.AbstractApplicationEventMulticaster类

下面的完整堆栈跟踪:

  

信息:在java.library.path中找不到基于APR的Apache Tomcat Native库,它可以在生产环境中实现最佳性能:C:\ Program Files \ Java \ jdk1.8.0_45 \ bin; C:\ WINDOWS \孙\的Java \ BIN; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ ProgramData \ ORACLE \的Java \ javapath; C:\ WINDOWS \ SYSTEM32; C:\ WINDOWS; C:\ WINDOWS \ SYSTEM32 \ WBEM; C:\ WINDOWS \ System32 \ WindowsPowerShell \ v1.0 \; C:\ Program Files \ WIDCOMM \ Bluetooth Software \; C:\ Program Files \ WIDCOMM \ Bluetooth Software \ syswow64; C:\ glassfish4 \ jdk7 \ jre \ bin; C:\ Program Files \ TortoiseSVN \ bin; D:\ apache-maven-3.2.3 \ bin; C:\ Program Files(x86)\ QuickTime \ QTSystem \;。   lip 29,2015 11:40:01 AM org.apache.coyote.AbstractProtocol init   信息:初始化ProtocolHandler [" http-nio-8088"]   lip 29,2015 11:40:01 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector   信息:使用共享选择器进行servlet写/读   lip 29,2015 11:40:01 AM org.apache.coyote.AbstractProtocol init   信息:初始化ProtocolHandler [" ajp-nio-8099"]   lip 29,2015 11:40:01 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector   信息:使用共享选择器进行servlet写/读   lip 29,2015 11:40:01 AM org.apache.catalina.startup.Catalina load   信息:初始化在823毫秒内处理   lip 29,2015 11:40:01 AM org.apache.catalina.core.StandardService startInternal   信息:开始服务Catalina   lip 29,2015 11:40:01 AM org.apache.catalina.core.StandardEngine startInternal   信息:启动Servlet引擎:Apache Tomcat / 8.0.23   lip 29,2015 11:40:04 AM org.apache.jasper.servlet.TldScanner scanJars   信息:至少有一个JAR被扫描用于TLD但尚未包含TLD。为此记录器启用调试日志记录,以获取已扫描但未在其中找到TLD的完整JAR列表。在扫描期间跳过不需要的JAR可以缩短启动时间和JSP编译时间。   lip 29,2015 11:40:04 AM org.apache.catalina.core.ApplicationContext log   信息:在类路径上检测到Spring WebApplicationInitializers:[com.siemens.ott.RestServiceWebAppIntializer@5fb6fe5e]   lip 29,2015 11:40:04 AM org.apache.catalina.core.ApplicationContext log   信息:初始化Spring根WebApplicationContext   .11:40:04.745 INFO o.s.web.context.ContextLoader - Root WebApplicationContext:初始化已启动   .11:40:04.760 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - 刷新Root WebApplicationContext:启动日期[Mon Jun 29 11:40:04 CEST 2015];上下文层次结构的根   .11:40:04.848 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - 注册带注释的类:[class com.ott.BusinessBeans]   .11:40:05.192错误o.s.web.context.ContextLoader - 上下文初始化失败   java.lang.IllegalAccessError:试图访问方法org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava / lang / Object;来自org.springframework.context.event.AbstractApplicationEventMulticaster类       at org.springframework.context.event.AbstractApplicationEventMulticaster.setBeanFactory(AbstractApplicationEventMulticaster.java:84)〜[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]       在org.springframework.context.event.SimpleApplicationEventMulticaster。(SimpleApplicationEventMulticaster.java:60)〜[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]       在org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster(AbstractApplicationContext.java:667)〜[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]       在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:471)〜[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE]       在org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)〜[spring-web-4.0.9.RELEASE.jar:4.0.9.RELEASE]       在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)〜[spring-web-4.0.9.RELEASE.jar:4.0.9.RELEASE]       在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)[spring-web-4.0.9.RELEASE.jar:4.0.9.RELEASE]       at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)[catalina.jar:8.0.23]       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)[catalina.jar:8.0.23]       在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)[catalina.jar:8.0.23]       at org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1409)[catalina.jar:8.0.23]       在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1399)[catalina.jar:8.0.23]       at java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_45]       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[na:1.8.0_45]       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)[na:1.8.0_45]       在java.lang.Thread.run(Thread.java:745)[na:1.8.0_45]   lip 29,2015 11:40:05 AM org.apache.catalina.core.StandardContext listenerStart   SEVERE:将上下文初始化事件发送到类org.springframework.web.context.ContextLoaderListener的侦听器实例的异常   java.lang.IllegalAccessError:试图访问方法org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava / lang / Object;来自org.springframework.context.event.AbstractApplicationEventMulticaster类       在org.springframework.context.event.AbstractApplicationEventMulticaster.setBeanFactory(AbstractApplicationEventMulticaster.java:84)       在org.springframework.context.event.SimpleApplicationEventMulticaster。(SimpleApplicationEventMulticaster.java:60)       在org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster(AbstractApplicationContext.java:667)       在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:471)       at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)       在org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)       在org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)       在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)       at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167)       在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)       在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1409)       在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1399)       at java.util.concurrent.FutureTask.run(FutureTask.java:266)       在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)       at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)       在java.lang.Thread.run(Thread.java:745)

我的第一个想法是Spring版本中有一些错误,但我找不到任何东西。这与我曾多次使用的项目设置完全相同,唯一的区别是这是java 8项目。

项目是动态网络模块3.1。

Bellow是.pom文件中的依赖项,我没有看到版本中的任何冲突。

如果有人在遇到此事之前请帮助。

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-core</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.ws</groupId>
        <artifactId>spring-ws-test</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>wsdl4j</groupId>
        <artifactId>wsdl4j</artifactId>
        <version>1.6.3</version>
    </dependency>

    <dependency>
        <groupId>javax.validation</groupId>
        <artifactId>validation-api</artifactId>
        <version>1.1.0.Final</version>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>5.1.1.Final</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5</version>
    </dependency>


    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.3</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.annotation</groupId>
        <artifactId>javax.annotation-api</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.xml</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.1</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>4.1.6.RELEASE</version>
    </dependency>

    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.4</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.7.12</version>
    </dependency>
</dependencies>

mvn dependecy tree:

  

C:\ Users \ Z003DP9F \ java-8 workspace \ workspace \ vmgw&gt; mvn依赖项:树   [INFO]扫描项目......   [信息]   [INFO] ----------------------------------------------- -------------------------   [INFO]构建vmgw 1.0   [INFO] ----------------------------------------------- -------------------------   [警告]工件javax.xml:jaxb-api:jar:2.1已经重定位到javax.xml.bind:jaxb-api:jar:2.1   [信息]   [INFO] --- maven-dependency-plugin:2.8:tree(default-cli)@vmgw ---   [警告]工件javax.xml:jaxb-api:jar:2.1已经重定位到javax.xml.bind:jaxb-api:jar:2.1   [INFO] com.siemens.ott:vmgw:war:1.0   [INFO] + - org.springframework:spring-core:jar:4.1.6.RELEASE:compile   [INFO] | - commons-logging:commons-logging:jar:1.2:compile   [INFO] + - org.springframework.ws:spring-ws-test:jar:2.2.1.RELEASE:compile   [INFO] | + - org.springframework.ws:spring-xml:jar:2.2.1.RELEASE:compile   [INFO] | - xmlunit:xmlunit:jar:1.5:编译   [INFO] + - org.springframework:spring-context:jar:4.1.6.RELEASE:compile   [INFO] | + - org.springframework:spring-aop:jar:4.1.6.RELEASE:compile   [INFO] | | - aopalliance:aopalliance:jar:1.0:编译   [INFO] | + - org.springframework:spring-beans:jar:4.1.6.RELEASE:compile   [INFO] | - org.springframework:spring-expression:jar:4.1.6.RELEASE:compile   [INFO] + - org.springframework:spring-webmvc:jar:4.1.6.RELEASE:compile   [INFO] | - org.springframework:spring-web:jar:4.1.6.RELEASE:compile   [INFO] + - ch.qos.logback:logback-classic:jar:1.1.3:compile   [INFO] | + - ch.qos.logback:logback-core:jar:1.1.3:compile   [INFO] | - org.slf4j:slf4j-api:jar:1.7.7:编译   [INFO] + - wsdl4j:wsdl4j:jar:1.6.3:编译   [INFO] + - javax.servlet:javax.servlet-api:jar:3.0.1:已提供   [INFO] + - javax.annotation:javax.annotation-api:jar:1.2:compile   [INFO] + - javax.xml.bind:jaxb-api:jar:2.1:compile   [INFO] | + - javax.xml.stream:stax-api:jar:1.0-2:compile   [INFO] | - javax.activation:activation:jar:1.1:compile   [INFO] + - org.springframework.ws:spring-ws-core:jar:2.2.1.RELEASE:compile   [INFO] | - org.springframework:spring-oxm:jar:4.0.9.RELEASE:compile   [INFO] + - junit:junit:jar:4.12:test   [INFO] | - org.hamcrest:hamcrest-core:jar:1.3:test   [INFO] + - org.springframework:spring-test:jar:4.1.6.RELEASE:compile   [INFO] + - commons-io:commons-io:jar:2.4:编译   [INFO] + - org.apache.httpcomponents:httpclient:jar:4.5:编译   [INFO] | + - org.apache.httpcomponents:httpcore:jar:4.4.1:compile   [INFO] | - commons-codec:commons-codec:jar:1.9:compile   [INFO] + - org.slf4j:jcl-over-slf4j:jar:1.7.12:compile   [INFO] + - javax.validation:validation-api:jar:1.1.0.Final:compile   [INFO] - org.hibernate:hibernate-validator:jar:5.1.1.Final:compile   [INFO] + - org.jboss.logging:jboss-logging:jar:3.1.3.GA:compile   [INFO] - com.fasterxml:classmate:jar:1.0.0:compile   [INFO] ----------------------------------------------- -------------------------   [信息]建立成功

1 个答案:

答案 0 :(得分:6)

问题是你混合了不兼容的不同版本的Spring。无论你不应该混合来自任何框架(Spring,Hibernate,JSF等)的不同版本的jar,因为这很难发生。

最好的方法是使用Spring IO Platform

将以下内容添加到您的pom

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>io.spring.platform</groupId>
            <artifactId>platform-bom</artifactId>
            <version>1.1.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

然后删除pom中的版本,因为版本现在由platform-bom管理,您现在应该具有一起工作的版本,并且没有更多冲突的版本。有关托管版本的列表,请检查此appendix