简体   繁体   English

从 Eclipse 运行 Tomcat 6 时出现 ClassCircularityError

[英]ClassCircularityError when running Tomcat 6 from Eclipse

I'm using Eclipse 3.5, with my Tomcat runtime set as Tomcat 6.0.26.我正在使用 Eclipse 3.5,我的 Tomcat 运行时设置为 Tomcat 6.0.26。 My Java VM is JDK 1.6.17 (Mac OS X).我的 Java VM 是 JDK 1.6.17 (Mac OS X)。

When I try to run a web application from an Eclipse Java EE perspective I keep seeing this error in the console:当我尝试从 Eclipse Java EE 角度运行 Web 应用程序时,我一直在控制台中看到此错误:

Caused by: java.lang.ClassCircularityError: java/util/logging/LogRecord
 at com.adsafe.util.SimpleFormatter.format(SimpleFormatter.java:11)
 at java.util.logging.StreamHandler.publish(StreamHandler.java:179)
 at java.util.logging.ConsoleHandler.publish(ConsoleHandler.java:88)
 at java.util.logging.Logger.log(Logger.java:458)
 at java.util.logging.Logger.doLog(Logger.java:480)
 at java.util.logging.Logger.logp(Logger.java:596)
 at org.apache.juli.logging.DirectJDKLog.log(DirectJDKLog.java:165)
 at org.apache.juli.logging.DirectJDKLog.info(DirectJDKLog.java:115)
 at org.apache.catalina.core.ApplicationContext.log(ApplicationContext.java:644)
 at org.apache.catalina.core.ApplicationContextFacade.log(ApplicationContextFacade.java:251)
 at org.apache.catalina.core.StandardWrapper.unavailable(StandardWrapper.java:1327)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1130)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:519)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
 ... 6 more

java/util/logging/ LogRecord implements Serializable , so I am not sure where the circular reference could have creeped in. java/util/logging/ LogRecord实现了Serializable ,所以我不确定循环引用可能潜入何处。

Has anyone seen this before and know how to fix this?有没有人以前见过这个并知道如何解决这个问题?

I was able to circumvent this problem by moving the <contextListener ...> to the very end of the configuration file (previously, I had it at the beginning of the file).我能够通过将<contextListener ...>移到配置文件的最后来规避这个问题(以前,我在文件的开头有它)。 The error remains really weird, though.不过,这个错误仍然很奇怪。

The problem is solved if you insert this snippet into your logback configuration:如果您将此代码段插入到 logback 配置中,问题就解决了:

<!-- LEVEL CAN NOT BE DEBUG -->
<logger name="org.apache" level="INFO"></logger>

I'm not sure why this resolved the problem, but setting the default level to INFO made this go away for me我不确定为什么这解决了这个问题,但是将默认级别设置为 INFO 使这对我来说消失了

.level = INFO .level = 信息

In had the same error when using Logback.在使用 Logback 时有同样的错误。

In my case, the problem was I used JUL LevelChangePropagator in my Logback configuration file.就我而言,问题是我在 Logback 配置文件中使用了 JUL LevelChangePropagator。

So I just had to remove the following listener所以我只需要删除以下侦听器

<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
    <resetJUL>true</resetJUL>
</contextListener>

First of all, a bit of context: I personally see this message when adding a listener in my web.xml to install the SLF4JBridgeHandler to bridge java.util.logging (JUL) calls to SLF4J.首先,有点上下文:我个人在我的web.xml添加侦听器以安装SLF4JBridgeHandler以将java.util.logging (JUL) 调用桥接到 SLF4J 时看到此消息。 I started to see this as soon as I increased the JUL root logger level from the default ( INFO ) to FINE , in order to forward all (well, almost all) messages to SLF4J.一旦我将 JUL 根记录器级别从默认值 ( INFO ) 增加到FINE ,我就开始看到这一点,以便将所有(几乎所有)消息转发到 SLF4J。

user2543253 comment above was indeed useful, it's a problem that happens at classloading time. user2543253 上面的评论确实很有用,这是在类加载时发生的问题。 I personally solved it by adding a fake direct JUL log call (using a LogRecord ) before installing the SLF4JBridgeHandler, in order to trigger classloading of JUL classes early.我个人通过在安装 SLF4JBridgeHandler 之前添加一个假的直接 JUL 日志调用(使用LogRecord )来解决它,以便及早触发 JUL 类的类加载。 So my listener now does:所以我的听众现在这样做:

java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger("");
rootLogger.log(new LogRecord(Level.ALL, "bridging of java.uil.logging to SLF4J requested"));
SLF4JBridgeHandler.removeHandlersForRootLogger();
rootLogger.setLevel(Level.FINE);
SLF4JBridgeHandler.install();

By the way: it's not strictly a Logback problem, I experience this while not using Logback at all (I'm using the Log4j 1.2 binding).顺便说一句:严格来说,这不是一个 Logback 问题,我在完全不使用 Logback 时遇到了这个问题(我使用的是 Log4j 1.2 绑定)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM