加载slf4j LoggerFactory时,websphere classloader给出java.lang.LinkageError [英] websphere classloader gives java.lang.LinkageError when loading slf4j LoggerFactory

查看:220
本文介绍了加载slf4j LoggerFactory时,websphere classloader给出java.lang.LinkageError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[我最初在Websphere论坛bot上发布了此消息,但未及时收到回复.我将在此处重新发布内容更多的内容]

[I originally posted this on the websphere forums bot didn't see a timely response. I'm re-posting here with slightly more content]

问题

我在我们的企业应用程序(即".ear")中添加了一个jar(称为"Foo.jar"),创建了清单条目等,令我惊讶的是,当我的EJB实例化FooClient时, Websphere在org.slf4j.LoggerFactory上引发了java.lang.LinkageError

I added a jar (call it "Foo.jar") to our enterprise application (i.e. ".ear"), created the manifest entry, etc., and found, to my surprise, that when my EJB instantiated FooClient, websphere threw a java.lang.LinkageError upon org.slf4j.LoggerFactory

我已将classloader调试添加到跟踪中,但发现的内容不多.我希望看到"WAS实际在哪里找到slf4j类".这是条目:

I've added classloader debugging to the trace and did not find much. I was hoping to see "where WAS actually found the slf4j class". Here are the entries:

[9/24/14 16:23:01:417 CDT] 00000067 CompoundClass >  loadClass org.slf4j.LoggerFactory this=com.ibm.ws.classloader.CompoundClassLoader@5c2687e4[app:yourappServer] Entry

[9/24/14 16:23:01:418 CDT] 00000067 CompoundClass <  loadClass org.slf4j.LoggerFactory java.lang.LinkageError: org.slf4j.LoggerFactory Exit

我已经检查了was8目录,并找到了slf4j jar的各种副本/版本.

I've checked my was8 directory and found various copies/versions of the slf4j jar.

/plugins
        /osgiappbundles/com.ibm.ws.osgi.applications/aries/slf4j-api-1.5.6.jar
        /slf4j-api-1.5.6.jar

/profiles/AppSrv01
        /installedConnectors/activemq-rar-5.9.1.rar/slf4j-api-1.7.5.jar
        /wstemp
                /appdepl14769b0c2de/slf4j-api-1.7.5.jar3472682177251273594.tmp
                /appdepl14769b0c2de/slf4j-api-1.7.5.jar7922145899030561292.tmp

另一位开发人员告诉我您将无法使用Foo.jar",因为我们需要输入"Parent_last",而该项目目前无法使用.

Another developer told me "you won't be able to use Foo.jar" because we would need to put "Parent_last" and that's not an option for this project currently.

其他上下文

  • Websphere 8.0.0.7
  • RAD 9

问题

  • java.lang.LinkageError:这是类加载器问题"还是类的版本错误"问题?我对错误版本的类"问题的经验通常会看到"NoSuchMethod"错误,而不是实例化异常.

  • java.lang.LinkageError : is this a 'classloader problem' or 'wrong version of class' problem? My experience with "wrong version of class" problems I usually see "NoSuchMethod" errors, not instantiation exceptions.

还有其他解决方法吗?

更新

我阅读了一些有关共享库和隔离类加载器"的信息,这似乎是解决方案.但是由于某种原因,当我将共享库与应用程序或模块相关联时,我的RAD/Eclipse UI似乎不被保存,因为它没有保存".随后消失了.

I read a bit about shared libraries and "isolated classloader" and this seemed the solution. However for some reason, my RAD/Eclipse UI seems broken as it does not 'save' when I associate the shared library with an application or module. It subsequently disappears.

提前感谢

推荐答案

检查Foo.jar和您使用的SL4J的版本:它们肯定不同.确保正确的版本在您的类路径中具有优先级:您可以将其放在WEB-INF/lib中,但还要检查一下它在WEB-INF/lib中是否只有一个版本.

Check the version of SL4J expected by Foo.jar and the one you are using: they are surely different. Ensure the correct version has precedence in your classpath: you can put it in WEB-INF/lib but also check that you have just one version of it in WEB-INF/lib.

要发现您正在使用哪个SL4J jar,可以运行

To discover which SL4J jar you are using you can run

java -verbose:class ....

,并且JVM会丢弃正在加载的内容以及从何处卸载.

and the JVM will dump out what it's loading, and from where.

您说我通常会看到NoSuchMethod错误",而不是LinkageError;在这种情况下,该方法存在,但还有其他不兼容之处.

You say "I usually see NoSuchMethod errors" instead of LinkageError; in this case the method exists but has some other incompatibility.

这篇关于加载slf4j LoggerFactory时,websphere classloader给出java.lang.LinkageError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆