引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger [英] Caused By: java.lang.NoClassDefFoundError: org/apache/log4j/Logger

查看:315
本文介绍了引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个有趣的问题,在运行时没有找到org.apache.log4j.Logger类。我正在尝试获得授权,这就是它失败的地方:

I've got an interesting problem in which the org.apache.log4j.Logger class is not found during runtime. I'm trying to get authorized and that is where it's failing:

OAuthAuthorizer oauthAuthorizer = new OAuthAuthorizer(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,SAML_PROVIDER_ID,userId);

我正在使用JDeveloper 11.1.1.6。以下是我所知道的:

I'm using JDeveloper 11.1.1.6. Here is what I know:


  1. 我查看了我的UI.war / WEB-INF / lib目录,我看到了那里有log4j-1.2.17.jar。

  1. I've looked in my UI.war/WEB-INF/lib directory and I see the log4j-1.2.17.jar there.

抱怨它的类是org.opensaml.xml.XMLConfigurator

The class complaining about it is org.opensaml.xml.XMLConfigurator

Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Logger
    at org.opensaml.xml.XMLConfigurator.<clinit>(XMLConfigurator.java:60)
    at org.opensaml.DefaultBootstrap.initializeXMLTooling(DefaultBootstrap.java:195)
    at org.opensaml.DefaultBootstrap.bootstrap(DefaultBootstrap.java:91)
    at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.getSAMLBuilder(SAML2AssertionGenerator.java:156)
    at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.createSubject(SAML2AssertionGenerator.java:187)
    at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.buildAssertion(SAML2AssertionGenerator.java:114)
    at com.intuit.ipp.aggcat.util.SAML2AssertionGenerator.generateSignedAssertion(SAML2AssertionGenerator.java:83)
    at com.intuit.ipp.aggcat.util.SamlUtil.createSignedSAMLPayload(SamlUtil.java:156)
    at com.intuit.ipp.aggcat.util.OAuthUtil.getOAuthTokens(OAuthUtil.java:60)
    at com.intuit.ipp.aggcat.core.OAuthAuthorizer.<init>(OAuthAuthorizer.java:85)
    at com.incomemax.view.intuit.WebUtil.getAggCatService(WebUtil.java:91)





Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:305)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:246)
    ... 64 more


  • 我已经解压缩了XMLConfigurat或者奇怪的是它不导入org.apache.log4j.Logger它使用的是org.slf4j.Logger,它也在我的jars目录中(slf4j-api-1.7.5.jar)。同样有趣的是第60行(参见堆栈跟踪)是我的反编译中的空行。

  • I decomplied XMLConfigurator and oddly it doesn't import org.apache.log4j.Logger It uses org.slf4j.Logger which is also in my jars directory (slf4j-api-1.7.5.jar). Also interesting is that line 60 (see stack trace) is a blank line in my decompile.

    当然如果我在设计时添加Logger.xxxxx,它发现它很好。

    Of course if I add Logger.xxxxx during design time, it finds it just fine.

    我直接从示例java代码中使用代码/ jar,但导入到我现有的应用程序中。

    I'm using the code/jars directly from the sample java code, but imported into my existing application.

    我一直在网上搜索答案,我相信我已经检查了所有我能想到的方面。我还引用了这个非常好的页面: http://myarch.com/classnotfound/

    I've been scouring the web for answers and I believe I've checked all the areas I can think of. I also referenced this very good page: http://myarch.com/classnotfound/

    鉴于授权是使用Intuit Developer API的第1步,我有点卡住了。

    Given authorization is step 1 in using the Intuit Developer API, I'm kinda stuck.

    从@jhadesdev添加输出建议:

    Adding output from @jhadesdev suggestion:

    所有版本的log4j Logger:

    All versions of log4j Logger:


    • zip:C:/ Users / Chris /AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/log4j-1.2.17.jar!/org/ apache / log4j / Logger.class

    所有版本的log4j都可以从OAuthAuthorizer类的类加载器中看到:

    All versions of log4j visible from the classloader of the OAuthAuthorizer class:


    • zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee- app / lt5l71 / war / WEB-INF / lib / log4j-1.2.17.jar!/org/apache/log4j/Logger.class

    所有版本的XMLConfigurator:

    All versions of XMLConfigurator:


    • jar:file:/ C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/ org / opensaml / xml / XMLConfigurator.class

    • jar:file:/C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/ DefaultServer的/ tmp / _WL_user / J2EE的应用程序/ lt5l71 /战争/ WEB-INF / lib目录/ IPP-java的aggcat-V1的devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app /lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class

    从OAuthAuthorizer类的类加载器中可以看到所有版本的XMLConfigurator:

    All versions of XMLConfigurator visible from the class loader of the OAuthAuthorizer class:


    • jar:file:/ C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class

    • jar:file:/C:/Oracle/Middleware11116/modules/com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61。 92 /默认域/服务器/ DefaultServer的/ tmp / _WL_user / J2EE的应用程序/ lt5l71 /战争/ WEB-INF / lib目录/ IPP-java的aggcat-V1的devkit-1.0.2.jar!/组织/ opensaml / XML / XMLConfigurator .class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp /_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class

    zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp/_WL_user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class

    我仍在努力解释结果。

    推荐答案

    提出建议@jhadesdev和其他人的解释,我在这里找到了这个问题。

    With the suggestions @jhadesdev and the explanations from others, I've found the issue here.

    添加代码后,看看各种类加载器可见的内容,我发现了这个: / p>

    After adding the code to see what was visible to the various class loaders I found this:

    All versions of log4j Logger: 
      zip:<snip>war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
    
    All versions of log4j visible from the classloader of the OAuthAuthorizer class: 
      zip:<snip>war/WEB-INF/lib/log4j-1.2.17.jar!/org/apache/log4j/Logger.class
    
    All versions of XMLConfigurator: 
      jar:<snip>com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
      zip:<snip>war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
      zip:<snip>war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
    
    All versions of XMLConfigurator visible from the classloader of the OAuthAuthorizer class: 
      jar:<snip>com.bea.core.bea.opensaml2_1.0.0.0_6-1-0-0.jar!/org/opensaml/xml/XMLConfigurator.class
      zip:<snip>war/WEB-INF/lib/ipp-java-aggcat-v1-devkit-1.0.2.jar!/org/opensaml/xml/XMLConfigurator.class
      zip:<snip>war/WEB-INF/lib/xmltooling-1.3.1.jar!/org/opensaml/xml/XMLConfigurator.class
    

    我注意到另一个版本的XMLConfigurator可能被拿起了。
    我对该类进行了反编译并在第60行发现了这一点(错误位于原始堆栈跟踪中) private static final Logger log = Logger.getLogger(XMLConfigurator.class); 并且该类是从 org.apache.log4j.Logger 导入的!

    I noticed that another version of XMLConfigurator was possibly getting picked up. I decompiled that class and found this at line 60 (where the error was in the original stack trace) private static final Logger log = Logger.getLogger(XMLConfigurator.class); and that class was importing from org.apache.log4j.Logger!

    所以这是这个类正在加载和使用。我的修复是重命名包含此文件的jar文件,因为我无法找到我明确或间接加载它的位置。这可能会在我实际部署时出现问题。

    So it was this class that was being loaded and used. My fix was to rename the jar file that contained this file as I can't find where I explicitly or indirectly load it. Which may pose a problem when I actually deploy.

    感谢您提供所有帮助和课程加载所需的课程。

    Thanks for all help and the much needed lesson on class loading.

    这篇关于引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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