gpt4 book ai didi

java - slf4j java.lang.LinkageError 加载程序约束违反

转载 作者:行者123 更新时间:2023-11-30 11:10:22 25 4
gpt4 key购买 nike

出于项目目的,我不得不坚持使用Java 1.6进行开发,我使用了异步客户端jar文件并将其合并到我的项目中以实现异步功能,并使用java 1.6开发并导出了一个JAR。这个 jar 包含在另一个在 java 7 上运行的 web 项目的构建路径中。它在 java 7 64 位和 tomcat7 64 位上工作正常。但是当使用 java 7 32 位和 tomcat7 32 位时看到以下错误:

java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/apache/catalina/loader/StandardClassLoader) for resolved class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type taticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory; used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:299)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:269)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)
at com.ning.http.client.AsyncHttpClient.<clinit>(AsyncHttpClient.java:146)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:39)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:32)
at com.netspective.ems.invoker.AsyncApiInvoker.post(AsyncApiInvoker.java:73)
at com.netspective.ems.api.ExceptionApi.notify(ExceptionApi.java:42)
at com.netspective.ems.NetspectiveEMS.prepareAndPostDetails(NetspectiveEMS.java:101)
at com.netspective.ems.NetspectiveEMS.log(NetspectiveEMS.java:168)
at com.netspective.watchtower.sdk.log4j.WatchtowerClientAppender.append(WatchtowerClientAppender.java:32)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.log(Category.java:856)
at org.apache.commons.logging.impl.Log4JLogger.debug(Log4JLogger.java:155)
at org.apache.commons.discovery.resource.names.DiscoverNamesInFile.findResourceNames(DiscoverNamesInFile.java:178)
at org.apache.commons.discovery.tools.DiscoverClass.find(DiscoverClass.java:323)
at org.apache.commons.discovery.tools.DiscoverClass.newInstance(DiscoverClass.java:520)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:370)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:270)
at gov.max.service.appendixb.persistence.restlet.resources.common.ServiceConfig.<clinit>(ServiceConfig.java:22)
at gov.max.service.appendixb.filter.security.SecurityFilter.init(SecurityFilter.java:129)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4656)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5309)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)

我在项目中使用了如下jar

async-http-client.jar
com.fasterxml.jackson.core.jar
com.fasterxml.jackson.databind.jar
com.springsource.org.joda.time-1.6.0.jar
jackson-annotations-2.0.2.jar
jackson-databind-2.0.5-sources.jar
jackson-datatype-joda-2.0.4.jar
json-1.5.jar
slf4j-api-1.7.0.jar

有没有办法解决这个异常?感谢您的任何建议。

最佳答案

尝试使用 slf4j-api-1.5.*.jar 或更早版本。我知道 api 的版本号可能不依赖于 Java 版本,但值得一试。我在我的 Java 1.6 项目中尝试了以下内容

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>

关于java - slf4j java.lang.LinkageError 加载程序约束违反,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27700969/

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