Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
原因:java.lang.NoClassDefFoundError:org/apache/log4j/Logger_Java_Logging_Classpath_Classloader_Intuit Partner Platform - Fatal编程技术网

原因:java.lang.NoClassDefFoundError:org/apache/log4j/Logger

原因:java.lang.NoClassDefFoundError:org/apache/log4j/Logger,java,logging,classpath,classloader,intuit-partner-platform,Java,Logging,Classpath,Classloader,Intuit Partner Platform,我遇到了一个有趣的问题,在运行时找不到org.apache.log4j.Logger类。我正试图获得授权,但这正是它失败的地方: OAuthAuthorizer OAuthAuthorizer=新的OAuthAuthorizer(OAUTH_使用者_密钥、OAUTH_使用者_密钥、SAML_提供者_ID、用户ID) 我使用的是jdeveloper11.1.1.6。以下是我所知道的: 我查看了UI.war/WEB-INF/lib目录,在那里看到了log4j-1.2.17.jar 抱怨它的类是org

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

OAuthAuthorizer OAuthAuthorizer=新的OAuthAuthorizer(OAUTH_使用者_密钥、OAUTH_使用者_密钥、SAML_提供者_ID、用户ID)

我使用的是jdeveloper11.1.1.6。以下是我所知道的:

  • 我查看了UI.war/WEB-INF/lib目录,在那里看到了log4j-1.2.17.jar

  • 抱怨它的类是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)
    
  • 我反编译了XMLConfigurator,奇怪的是它没有导入org.apache.log4j.Logger,而是使用org.slf4j.Logger,它也在我的jars目录(slf4j-api-1.7.5.jar)中。同样有趣的是,第60行(参见堆栈跟踪)在我的反编译中是一个空行

  • 当然,如果我在设计期间添加Logger.xxxxx,它会发现它很好

  • 我直接使用示例java代码中的代码/JAR,但已导入到现有应用程序中

  • 我一直在网上搜寻答案,我相信我已经查遍了我能想到的所有领域。我还引用了这个非常好的页面:

    如果授权是使用Intuit Developer API的第一步,我有点卡住了

    添加@jhadesdev建议的输出:

    log4j记录器的所有版本:

    • zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp//u-WL\u-user/j2ee-app/lt5l71/war/WEB-INF/lib/log4j-1.2.17.jar/org/apache/log4j/Logger.class
    从OAuthAuthorizer类的类加载器中可见的log4j的所有版本:

    • zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp//u-WL\u-user/j2ee-app/lt5l71/war/WEB-INF/lib/log4j-1.2.17.jar/org/apache/log4j/Logger.class
    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

    • zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp//u-WL\u-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//u-WL\u-user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar/org/opensaml/xml/XMLConfigurator.class

    从OAuthAuthorizer类的类加载器中可见的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

    • zip:C:/Users/Chris/AppData/Roaming/JDeveloper/system11.1.1.6.38.61.92/DefaultDomain/servers/DefaultServer/tmp//u-WL\u-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//u-WL\u-user/j2ee-app/lt5l71/war/WEB-INF/lib/xmltooling-1.3.1.jar/org/opensaml/xml/XMLConfigurator.class


    我仍在解释结果。

    在运行时,您的应用程序无法找到jar

    摘自:

    在我们的头脑中保持两个不同的例外是很重要的 在这种情况下:

  • java.lang.ClassNotFoundException这是一个
    异常
    ,它表示 在类路径上找不到类。这表明我们 正在尝试加载类定义,但上不存在该类 类路径

  • java.lang.NoClassDefFoundError这是
    错误
    ,它表示JVM 在其内部类定义数据结构中查找 类的定义,但未找到它。这与 表示无法从类路径加载它。通常这个 指示我们以前试图从中加载类 类路径,但由于某种原因失败-现在我们再次尝试, 但我们甚至不会尝试加载它,因为我们失败了 更早地加载它。早些时候的失败可能是一场灾难 ClassNotFoundException或ExceptionInInitializeError(指示 静态初始化块中的故障)或任何其他故障 问题。关键是,NoClassDefFoundError不一定是 类路径问题


  • java.lang.ClassNotFoundException表示在类路径中找不到类。 可能是log4j的版本不兼容。
    检查不同的log4j版本

    您可以在pom文件中使用以下maven依赖项。否则,您可以从net下载以下两个JAR并将其添加到构建路径中

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


    谢谢

    基于stacktrace,intuit类com.intuit.ipp.aggcat.util.SAML2AssertionGenerator在类路径上需要一个saml jar

    saml类org.opensaml.xml.XMLConfigurator需要打开它的log4j,它在战争中,但找不到它

    对此的一种解释是,需要log4j的类XMLConfigurator不是在WAR内部找到的,而是在下游类加载器上找到的。战争中会丢失一个saml罐子吗

    需要log4j的类XMLConfigurator在加载它的类加载器级别上找不到它,并且WAR上的log4j版本在特定的类加载器上不可见

    要对此进行故障排除,一种方法是在oauth调用之前添加:

    System.out.println("all versions of log4j Logger: " + getClass().getClassLoader().getResources("org/apache/log4j/Logger.class") );
    
    System.out.println("all versions of XMLConfigurator: " + getClass().getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
    
    System.out.println("all versions of XMLConfigurator visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
    
    System.out.println("all versions of log4j visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassloader().getResources("org/apache/log4j/Logger.class") );
    
    另外,如果您使用的是Java7,请看一看,它是我用来帮助解决这些问题的工具

    为了看看发生了什么事,你能告诉我吗
    System.out.println("all versions of log4j Logger: " + getClass().getClassLoader().getResources("org/apache/log4j/Logger.class") );
    
    System.out.println("all versions of XMLConfigurator: " + getClass().getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
    
    System.out.println("all versions of XMLConfigurator visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassLoader().getResources("org/opensaml/xml/XMLConfigurator.class") );
    
    System.out.println("all versions of log4j visible from the classloader of the OAuthAuthorizer class: " + OAuthAuthorizer.class.getClassloader().getResources("org/apache/log4j/Logger.class") );
    
    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
    
        <prefer-application-packages>
            <package-name>org.opensaml.*</package-name>
        </prefer-application-packages>