将 Rampart 添加到 POM 依赖项时出现 IllegalAccessError

发布于 2024-11-11 16:57:24 字数 1724 浏览 5 评论 0原文

我们尝试将 Rampart 添加到模块的 POM 文件中,这样做后,我们的 ear 无法再启动,并出现以下异常:

java.lang.IllegalAccessError: tried to access method org.apache.log4j.Logger.<init>(Ljava/lang/String;)V from class org.apache.log4j.spi.RootLogger
        at org.apache.log4j.spi.RootLogger.<init>(RootLogger.java:43)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:78)
        at org.apache.log4j.xml.XMLWatchdog.doOnChange(DOMConfigurator.java:862)
        at org.apache.log4j.helpers.FileWatchdog.checkAndConfigure(FileWatchdog.java:88)
        at org.apache.log4j.helpers.FileWatchdog.<init>(FileWatchdog.java:57)
        at org.apache.log4j.xml.XMLWatchdog.<init>(DOMConfigurator.java:853)
        at org.apache.log4j.xml.DOMConfigurator.configureAndWatch(DOMConfigurator.java:584)

org.apache.log4j.Logger 定义在两个 jar 中 - log4jlog4j-over-slf4j。 在 log4j 中 - 有一个构造函数:

protected Logger(String name)

log4j-over-slf4j 中有一个构造函数:

Logger(String name) //Package access only

似乎由于某种原因 Rampart 触发了一个错误类路径顺序并将 log4j-over-slf4j 放置在 log4j 之前。

然而,最麻烦的问题是我们无法更改 ear 的清单来更改顺序 - 因此最终我们通过将 log4j jar 添加到系统类路径

我的问题有两个部分:

  1. Rampart 问题是否熟悉以及是否有解决方案?
  2. 这可能是什么原因 改变耳朵的表现 不会影响类路径吗? (我是 没有那么有经验 应用程序服务器 - 如此明显 欢迎回答)

我们使用的是 Weblogic 10.3Rampart 1.5.1。我们正在使用 Maven 编译和构建 ear 文件 - 我今天刚刚了解到 mar 文件,因此任何有关该文件的输入也将受到欢迎。

We tried adding Rampart to our module's POM file and after doing so our ear can no longer start with the following exception:

java.lang.IllegalAccessError: tried to access method org.apache.log4j.Logger.<init>(Ljava/lang/String;)V from class org.apache.log4j.spi.RootLogger
        at org.apache.log4j.spi.RootLogger.<init>(RootLogger.java:43)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:78)
        at org.apache.log4j.xml.XMLWatchdog.doOnChange(DOMConfigurator.java:862)
        at org.apache.log4j.helpers.FileWatchdog.checkAndConfigure(FileWatchdog.java:88)
        at org.apache.log4j.helpers.FileWatchdog.<init>(FileWatchdog.java:57)
        at org.apache.log4j.xml.XMLWatchdog.<init>(DOMConfigurator.java:853)
        at org.apache.log4j.xml.DOMConfigurator.configureAndWatch(DOMConfigurator.java:584)

org.apache.log4j.Logger is defined in two jars - log4j and log4j-over-slf4j.
In log4j - there is a constructor:

protected Logger(String name)

In log4j-over-slf4j there is a constructor:

Logger(String name) //Package access only

It seems that for some reason Rampart triggered a bad classpath order and placed log4j-over-slf4j before log4j.

However, the most troubling problem is that we were unable to change our ear's manifest to change the order - so eventually we "solved" it by adding the log4j jar to the System Classpath

My question has two parts:

  1. Is the Rampart problem familiar and does it have a solution?
  2. What reason could it be that
    changing the manifest of the ear
    would not effect the classpath? (I'm
    not that experienced with
    application servers - so obvious
    answers are welcome)

We are using Weblogic 10.3, and Rampart 1.5.1. We are using Maven to compile and build the ear file - and I just learned today of a mar file, so any inputs about that will also be welcomed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

倾其所爱 2024-11-18 16:57:24

log4j-over-slf4j 是代理 slf4j 的 log4j 的替代品。这意味着在您的类路径中您有具有相同名称和包但实现截然不同的类。

由于您在系统中使用 log4j,因此删除 log4j-over-slf4j 是安全的。在这种情况下,需要 log4j-over-slf4j 的库实际上将使用原始的 log4j。

log4j-over-slf4j is replacement of log4j that proxies to slf4j. This means in your class path you have classes with same name and package, but very different implementation.

Since you use log4j in your system, it is safe to remove log4j-over-slf4j. in that case the library that needs log4j-over-slf4j will actually use the original log4j.

韬韬不绝 2024-11-18 16:57:24

最终我们手动修改了 pom.xml 并更改了依赖项的顺序,将 log4j 放在 rampart 之前 - 这解决了类路径顺序问题。

Eventually we modified the pom.xml manually and changed the order of dependencies to put log4j before rampart - which solved the classpath order problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文