将 Rampart 添加到 POM 依赖项时出现 IllegalAccessError
我们尝试将 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 中 -
log4j
和 log4j-over-slf4j
。 在 log4j
中 - 有一个构造函数:
protected Logger(String name)
在 log4j-over-slf4j
中有一个构造函数:
Logger(String name) //Package access only
似乎由于某种原因 Rampart
触发了一个错误类路径顺序并将 log4j-over-slf4j
放置在 log4j
之前。
然而,最麻烦的问题是我们无法更改 ear
的清单来更改顺序 - 因此最终我们通过将 log4j
jar 添加到系统类路径
我的问题有两个部分:
Rampart
问题是否熟悉以及是否有解决方案?- 这可能是什么原因 改变耳朵的表现 不会影响类路径吗? (我是 没有那么有经验 应用程序服务器 - 如此明显 欢迎回答)
我们使用的是 Weblogic 10.3
和 Rampart 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:
- Is the
Rampart
problem familiar and does it have a solution? - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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.
最终我们手动修改了
pom.xml
并更改了依赖项的顺序,将log4j
放在rampart
之前 - 这解决了类路径顺序问题。Eventually we modified the
pom.xml
manually and changed the order of dependencies to putlog4j
beforerampart
- which solved the classpath order problem.