引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger

时间:2022-03-06 15:39:17

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:

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

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

OAuthAuthorizer oauthAuthorizer =新的OAuthAuthorizer(OAUTH_CONSUMER_KEY,OAUTH_CONSUMER_SECRET,SAML_PROVIDER_ID,userId);

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

我正在使用JDeveloper 11.1.1.6。这就是我所知道的:

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

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

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

    抱怨它的类是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
    
  3. 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.

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

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

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

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

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

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/

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

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

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

Adding output from @jhadesdev suggestion:

从@jhadesdev建议添加输出:

All versions of log4j Logger:

所有版本的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

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

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

  • 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

All versions of XMLConfigurator:

所有版本的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/_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

All versions of XMLConfigurator visible from the class loader of the OAuthAuthorizer 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/_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

I'm still working on interpreting the results.

我还在努力解释结果。

8 个解决方案

#1


24  

During runtime your application is unable to find the jar.

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

Taken from this answer by Jared:

取自Jared的回答:

It is important to keep two different exceptions straight in our head in this case:

在这种情况下,重要的是要保持两个不同的例外:

  1. java.lang.ClassNotFoundException This an Exception, it indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.

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

  2. java.lang.NoClassDefFoundError This is Error, it indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying again, but we're not even going to try to load it, because we failed loading it earlier. The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.

    java.lang.NoClassDefFoundError这是Error,它表明JVM在其内部类定义数据结构中查找了类的定义但未找到它。这不同于说它无法从类路径加载。通常这表明我们之前尝试从类路径加载一个类,但由于某种原因它失败了 - 现在我们再次尝试,但我们甚至都不会尝试加载它,因为我们之前没有加载它。较早的失败可能是ClassNotFoundException或ExceptionInInitializerError(表示静态初始化块中的失败)或任何其他问题。关键是,NoClassDefFoundError不一定是类路径问题。

for similarities and differences

因为异同

#2


7  

You can use the following maven dependency in your pom file. Otherwise, you can download the following two jars from net and add it to your build path.

您可以在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>

This is copied from my working project. First make sure it is working in your project. Then you can change the versions to use any other(versions) compatible jars.

这是从我的工作项目中复制的。首先确保它在您的项目中正常工作。然后,您可以更改版本以使用任何其他(版本)兼容的jar。

For AggCat, you can refer the POM file of the sample java application.

对于AggCat,您可以引用示例Java应用程序的POM文件。

https://github.com/IntuitDeveloperRelations/IPP_Sample_Code/blob/master/CustomerAccountData/Java/AggCatSampleApplication/pom.xml

Thanks

#3


4  

Based on the stacktrace, an intuit class com.intuit.ipp.aggcat.util.SAML2AssertionGenerator needs a saml jar on the classpath.

基于stacktrace,intuit类com.intuit.ipp.aggcat.util.SAML2AssertionGenerator需要类路径上的saml jar。

A saml class org.opensaml.xml.XMLConfigurator needs on it's turn log4j, which is inside the WAR but cannot find it.

一个saml类org.opensaml.xml.XMLConfigurator需要它的log4j,它在WAR内但无法找到它。

One explanation for this is that the class XMLConfigurator that needs log4j was found not inside the WAR but on a downstream classloader. could a saml jar be missing from the WAR?

对此的一种解释是,需要log4j的类XMLConfigurator不在WAR内部,而是在下游类加载器中。战争中可能缺少一个saml jar吗?

The class XMLConfigurator that needs log4j cannot find it at the level of the classloader that loaded it, and the log4j version on the WAR is not visible on that particular classloader.

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

In order to troubleshoot this, a way is to add this before the oauth call:

为了解决这个问题,一种方法是在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") );

Also if you are using Java 7, have a look at jHades, it's a tool I made to help troubleshooting these type of problems.

此外,如果您使用的是Java 7,请查看jHades,它是我帮助解决这些类型问题的工具。

In order to see what is going on, could you post the results of the classpath queries above, for which container is this happening, tomcat, jetty? It would be better to put the full stacktrace with all the caused by's in pastebin, just in case.

为了看看发生了什么,你可以发布上面的类路径查询的结果,对于哪个容器发生这种情况,tomcat,jetty?为了以防万一,最好将完整的堆栈跟踪与由pastebin引起的所有引起。

#4


4  

Check in Deployment Assembly,

检查部署程序集,

I have the same error, when i generate the war file with the "maven clean install" way and deploy manualy, it works fine, but when i use the runtime enviroment (eclipse) the problems come.

我有同样的错误,当我使用“maven clean install”方式生成war文件并部署manualy时,它工作正常,但是当我使用运行时环境(eclipse)问题来了。

The solution for me (for eclipse IDE) go to: "proyect properties" --> "Deployment Assembly" --> "Add" --> "the jar you need", in my case java "build path entries". Maybe can help a litle!

我的解决方案(对于eclipse IDE)转到:“proyect properties” - >“Deployment Assembly” - >“Add” - >“你需要的jar”,在我的例子中是java“build path entries”。也许可以帮助一个痘痘!

#5


3  

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

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

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

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!

我注意到另一个版本的XMLConfigurator可能会被拿起来。我反编译该类并在第60行(其中错误位于原始堆栈跟踪中)发现此私有静态最终Logger log = Logger.getLogger(XMLConfigurator.class);那个类是从org.apache.log4j.Logger导入的!

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.

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

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

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

#6


2  

Had the same problem, it was indeed caused by weblogic stupidly using its own opensaml implementation. To solve it, you have to tell it to load classes from WEB-INF/lib for this package in weblogic.xml:

有同样的问题,它确实是由weblogic愚蠢地使用自己的opensaml实现引起的。要解决它,你必须告诉它在weblogic.xml中从WEB-INF / lib为这个包加载类:

    <prefer-application-packages>
        <package-name>org.opensaml.*</package-name>
    </prefer-application-packages>

maybe <prefer-web-inf-classes>true</prefer-web-inf-classes> would work too.

也许 true 也可以。

#7


1  

java.lang.ClassNotFoundException is indicate that class is not found in class path. it could be the version of log4j is not compatible. check for different log4j version.

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

#8


0  

I had the same issue, for me this fixed the issue:
right click on the project ->maven -> update project

我有同样的问题,对我来说这解决了这个问题:右键点击项目 - > maven - >更新项目

引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger

#1


24  

During runtime your application is unable to find the jar.

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

Taken from this answer by Jared:

取自Jared的回答:

It is important to keep two different exceptions straight in our head in this case:

在这种情况下,重要的是要保持两个不同的例外:

  1. java.lang.ClassNotFoundException This an Exception, it indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.

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

  2. java.lang.NoClassDefFoundError This is Error, it indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying again, but we're not even going to try to load it, because we failed loading it earlier. The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.

    java.lang.NoClassDefFoundError这是Error,它表明JVM在其内部类定义数据结构中查找了类的定义但未找到它。这不同于说它无法从类路径加载。通常这表明我们之前尝试从类路径加载一个类,但由于某种原因它失败了 - 现在我们再次尝试,但我们甚至都不会尝试加载它,因为我们之前没有加载它。较早的失败可能是ClassNotFoundException或ExceptionInInitializerError(表示静态初始化块中的失败)或任何其他问题。关键是,NoClassDefFoundError不一定是类路径问题。

for similarities and differences

因为异同

#2


7  

You can use the following maven dependency in your pom file. Otherwise, you can download the following two jars from net and add it to your build path.

您可以在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>

This is copied from my working project. First make sure it is working in your project. Then you can change the versions to use any other(versions) compatible jars.

这是从我的工作项目中复制的。首先确保它在您的项目中正常工作。然后,您可以更改版本以使用任何其他(版本)兼容的jar。

For AggCat, you can refer the POM file of the sample java application.

对于AggCat,您可以引用示例Java应用程序的POM文件。

https://github.com/IntuitDeveloperRelations/IPP_Sample_Code/blob/master/CustomerAccountData/Java/AggCatSampleApplication/pom.xml

Thanks

#3


4  

Based on the stacktrace, an intuit class com.intuit.ipp.aggcat.util.SAML2AssertionGenerator needs a saml jar on the classpath.

基于stacktrace,intuit类com.intuit.ipp.aggcat.util.SAML2AssertionGenerator需要类路径上的saml jar。

A saml class org.opensaml.xml.XMLConfigurator needs on it's turn log4j, which is inside the WAR but cannot find it.

一个saml类org.opensaml.xml.XMLConfigurator需要它的log4j,它在WAR内但无法找到它。

One explanation for this is that the class XMLConfigurator that needs log4j was found not inside the WAR but on a downstream classloader. could a saml jar be missing from the WAR?

对此的一种解释是,需要log4j的类XMLConfigurator不在WAR内部,而是在下游类加载器中。战争中可能缺少一个saml jar吗?

The class XMLConfigurator that needs log4j cannot find it at the level of the classloader that loaded it, and the log4j version on the WAR is not visible on that particular classloader.

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

In order to troubleshoot this, a way is to add this before the oauth call:

为了解决这个问题,一种方法是在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") );

Also if you are using Java 7, have a look at jHades, it's a tool I made to help troubleshooting these type of problems.

此外,如果您使用的是Java 7,请查看jHades,它是我帮助解决这些类型问题的工具。

In order to see what is going on, could you post the results of the classpath queries above, for which container is this happening, tomcat, jetty? It would be better to put the full stacktrace with all the caused by's in pastebin, just in case.

为了看看发生了什么,你可以发布上面的类路径查询的结果,对于哪个容器发生这种情况,tomcat,jetty?为了以防万一,最好将完整的堆栈跟踪与由pastebin引起的所有引起。

#4


4  

Check in Deployment Assembly,

检查部署程序集,

I have the same error, when i generate the war file with the "maven clean install" way and deploy manualy, it works fine, but when i use the runtime enviroment (eclipse) the problems come.

我有同样的错误,当我使用“maven clean install”方式生成war文件并部署manualy时,它工作正常,但是当我使用运行时环境(eclipse)问题来了。

The solution for me (for eclipse IDE) go to: "proyect properties" --> "Deployment Assembly" --> "Add" --> "the jar you need", in my case java "build path entries". Maybe can help a litle!

我的解决方案(对于eclipse IDE)转到:“proyect properties” - >“Deployment Assembly” - >“Add” - >“你需要的jar”,在我的例子中是java“build path entries”。也许可以帮助一个痘痘!

#5


3  

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

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

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

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!

我注意到另一个版本的XMLConfigurator可能会被拿起来。我反编译该类并在第60行(其中错误位于原始堆栈跟踪中)发现此私有静态最终Logger log = Logger.getLogger(XMLConfigurator.class);那个类是从org.apache.log4j.Logger导入的!

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.

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

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

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

#6


2  

Had the same problem, it was indeed caused by weblogic stupidly using its own opensaml implementation. To solve it, you have to tell it to load classes from WEB-INF/lib for this package in weblogic.xml:

有同样的问题,它确实是由weblogic愚蠢地使用自己的opensaml实现引起的。要解决它,你必须告诉它在weblogic.xml中从WEB-INF / lib为这个包加载类:

    <prefer-application-packages>
        <package-name>org.opensaml.*</package-name>
    </prefer-application-packages>

maybe <prefer-web-inf-classes>true</prefer-web-inf-classes> would work too.

也许 true 也可以。

#7


1  

java.lang.ClassNotFoundException is indicate that class is not found in class path. it could be the version of log4j is not compatible. check for different log4j version.

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

#8


0  

I had the same issue, for me this fixed the issue:
right click on the project ->maven -> update project

我有同样的问题,对我来说这解决了这个问题:右键点击项目 - > maven - >更新项目

引起者:java.lang.NoClassDefFoundError:org / apache / log4j / Logger