gpt4 book ai didi

在 Tomcat 8 上启动 Spring 应用程序时出现 java.lang.IllegalAccessError

转载 作者:行者123 更新时间:2023-11-28 21:50:39 24 4
gpt4 key购买 nike

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

INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started . INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Jun 29 10:59:34 CEST 2015]; root of context hierarchy . INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com...]

ERROR o.s.web.context.ContextLoader - Context initialization failed java.lang.IllegalAccessError: tried to access method org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava/lang/Object; from class org.springframework.context.event.AbstractApplicationEventMulticaster

下面是完整的堆栈跟踪:

INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_45\bin;C:\WINDOWS\Sun\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 INFO: Initializing ProtocolHandler ["http-nio-8088"] lip 29, 2015 11:40:01 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read lip 29, 2015 11:40:01 AM org.apache.coyote.AbstractProtocol init INFO: Initializing ProtocolHandler ["ajp-nio-8099"] lip 29, 2015 11:40:01 AM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector INFO: Using a shared selector for servlet write/read lip 29, 2015 11:40:01 AM org.apache.catalina.startup.Catalina load INFO: Initialization processed in 823 ms lip 29, 2015 11:40:01 AM org.apache.catalina.core.StandardService startInternal INFO: Starting service Catalina lip 29, 2015 11:40:01 AM org.apache.catalina.core.StandardEngine startInternal INFO: Starting Servlet Engine: Apache Tomcat/8.0.23 lip 29, 2015 11:40:04 AM org.apache.jasper.servlet.TldScanner scanJars INFO: 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. lip 29, 2015 11:40:04 AM org.apache.catalina.core.ApplicationContext log INFO: Spring WebApplicationInitializers detected on classpath: [com.siemens.ott.RestServiceWebAppIntializer@5fb6fe5e] lip 29, 2015 11:40:04 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext .11:40:04.745 INFO o.s.web.context.ContextLoader - Root WebApplicationContext: initialization started .11:40:04.760 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Mon Jun 29 11:40:04 CEST 2015]; root of context hierarchy .11:40:04.848 INFO o.s.w.c.s.AnnotationConfigWebApplicationContext - Registering annotated classes: [class com.ott.BusinessBeans] .11:40:05.192 ERROR o.s.web.context.ContextLoader - Context initialization failed java.lang.IllegalAccessError: tried to access method org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava/lang/Object; from class 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] at org.springframework.context.event.SimpleApplicationEventMulticaster.(SimpleApplicationEventMulticaster.java:60) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster(AbstractApplicationContext.java:667) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:471) ~[spring-context-4.1.6.RELEASE.jar:4.1.6.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) ~[spring-web-4.0.9.RELEASE.jar:4.0.9.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) ~[spring-web-4.0.9.RELEASE.jar:4.0.9.RELEASE] at 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] at 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] at 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] at 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] at 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: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener java.lang.IllegalAccessError: tried to access method org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingletonMutex()Ljava/lang/Object; from class org.springframework.context.event.AbstractApplicationEventMulticaster at org.springframework.context.event.AbstractApplicationEventMulticaster.setBeanFactory(AbstractApplicationEventMulticaster.java:84) at org.springframework.context.event.SimpleApplicationEventMulticaster.(SimpleApplicationEventMulticaster.java:60) at org.springframework.context.support.AbstractApplicationContext.initApplicationEventMulticaster(AbstractApplicationContext.java:667) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:471) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

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

项目是 Dynamic Web Module 3.1。

下面是 .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 依赖树:

C:\Users\Z003DP9F\java-8 workspace\workspace\vmgw>mvn dependency:tree [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building vmgw 1.0 [INFO] ------------------------------------------------------------------------ [WARNING] The artifact javax.xml:jaxb-api:jar:2.1 has been relocated to javax.xml.bind:jaxb-api:jar:2.1 [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ vmgw --- [WARNING] The artifact javax.xml:jaxb-api:jar:2.1 has been relocated to 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:compile [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:compile [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:compile [INFO] +- wsdl4j:wsdl4j:jar:1.6.3:compile [INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided [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:compile [INFO] +- org.apache.httpcomponents:httpclient:jar:4.5:compile [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] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS

最佳答案

问题是您正在混合不兼容的不同版本的 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-b​​om 管理,您现在应该拥有可以协同工作的版本并且不再有冲突的版本。如需托管版本列表,请查看此 appendix .

关于在 Tomcat 8 上启动 Spring 应用程序时出现 java.lang.IllegalAccessError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31111791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com