Log4J在部署战争时抛出stackoverflow错误

时间:2012-10-15 09:22:40

标签: tomcat log4j war stack-overflow

我们最近将我的应用程序迁移到多模块maven架构,现在在Tomcat中部署时会抛出 stackoverflow错误。

堆栈跟踪包含在下方:

GRAVE: Error waiting for multi-thread deployment of WAR files to complete
java.util.concurrent.ExecutionException: java.lang.StackOverflowError
    at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
    at java.util.concurrent.FutureTask.get(FutureTask.java:83)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:757)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:477)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1393)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:318)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:401)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:346)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1140)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:800)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.StackOverflowError
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:390)
    at java.lang.StringBuffer.append(StringBuffer.java:224)
    at org.apache.log4j.helpers.OptionConverter.getSystemProperty(OptionConverter.java:105)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:417)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)
    at org.apache.log4j.helpers.OptionConverter.substVars(OptionConverter.java:429)

有谁能告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

您在配置中使用了System属性,并且该属性的值为${name},即-Dname=${name}

当Log4j尝试展开${name}的值时,它会获得${name} - >循环。

如果很难判断哪个变量导致问题,请在OptionConverter.java:105中设置断点或使用-Dlog4j.debug=true启用调试