Grails 2.3.5 War 在 Tomcat 7.0.47 中无法正常工作

Grails 2.3.5 War not correctly working in Tomcat 7.0.47

虽然 运行 应用程序正在开发中..它工作正常。 当我构建 war 并尝试在 tomcat 中部署时,出现以下错误:

log4j:ERROR Error initializing log4j: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory
    at org.slf4j.LoggerFactory.staticInitialize(LoggerFactory.java:83)
    at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:73)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
    at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:131)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at org.codehaus.groovy.grails.commons.DefaultGrailsApplication.<clinit>(DefaultGrailsApplication.java:82)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:379)
    at org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener.createGrailsApplication(Log4jConfigListener.java:54)
    at org.codehaus.groovy.grails.plugins.log4j.web.util.Log4jConfigListener.contextInitialized(Log4jConfigListener.java:42)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5017)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5531)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

根据 SLF4j FAQs

This error is caused by the static initializer of the LoggerFactory class attempting to directly access the SINGLETON field of org.slf4j.impl.StaticLoggerBinder. While this was allowed in SLF4J 1.5.5 and earlier, in 1.5.6 and later the SINGLETON field has been marked as private access.

If you get the exception shown above, then you are using an older version of slf4j-api, e.g. 1.4.3, with a new version of a slf4j binding, e.g. 1.5.6. Typically, this occurs when your Maven pom.ml file incorporates hibernate 3.3.0 which declares a dependency on slf4j-api version 1.4.2. If your pom.xml declares a dependency on an slf4j binding, say slf4j-log4j12 version 1.5.6, then you will get illegal access errors. In your pom.xml file, explicitly declaring a dependency on slf4j-api matching the version of the declared binding will make the problem go away.

另请参阅此 answer。 您可能需要验证您的服务器不包含 slf4j-api.

的旧版本