使用Gretty运行我的Web应用程序时出现问题。我正在使用以下配置
gretty {
httpPort = 8080
servletContainer = 'tomcat9'
reloadOnClassChange = true
managedClassReload = true
loggingLevel = 'ALL'
springBootVersion = '2.1.1'
contextPath = '/iC'
interactiveMode = 'restartOnKeyPress'
jvmArgs = [
'-Xms512m',
'-Xmx2500m'
]
logDir = 'logs'
}
farm {
webapp "build/dist/${app_name}.war"
}
project.afterEvaluate {
tasks.farmRun.dependsOn build_war
}
运行时出现以下错误
SEVERE: Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
java.lang.ExceptionInInitializerError
at org.slf4j.log4j12.Log4j12ServiceProvider.initialize(Log4j12ServiceProvider.java:35)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:153)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:419)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:405)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:354)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:655)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:301)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4643)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5109)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1432)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1422)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:944)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:261)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:801)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Tomcat.start(Tomcat.java:372)
at org.apache.catalina.startup.Tomcat$start$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at org.akhikhl.gretty.TomcatServerManager.startServer(TomcatServerManager.groovy:52)
at org.akhikhl.gretty.ServerManager$startServer$0.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
at org.akhikhl.gretty.Runner.run(Runner.groovy:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1427)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:210)
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:120)
at org.akhikhl.gretty.Runner.main(Runner.groovy:48)
Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path, preempting StackOverflowError. See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.
at org.slf4j.log4j12.Log4jLoggerFactory.<clinit>(Log4jLoggerFactory.java:54)
... 56 more
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
Dec 13, 2018 3:06:36 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Dec 13, 2018 3:06:36 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/iC] startup failed due to previous errors
15:06:36 INFO springloaded shutdown: Thread[FileSystemWatcher: files=#7 cl=TomcatEmbeddedWebappClassLoader
context: iC
delegate: true
----------> Parent Classloader:
java.net.URLClassLoader@246f8b8b
,5,main]
Dec 13, 2018 3:06:37 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Dec 13, 2018 3:06:37 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
WARNING: The web application [iC] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Dec 13, 2018 3:06:37 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
WARNING: The web application [iC] registered the JDBC driver [com.mysql.fabric.jdbc.FabricMySQLDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Dec 13, 2018 3:06:37 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [iC] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.io.WinNTFileSystem.getLastModifiedTime(Native Method)
java.io.File.lastModified(File.java:943)
org.apache.catalina.webresources.FileResource.getLastModified(FileResource.java:95)
org.apache.catalina.webresources.CachedResource.getLastModified(CachedResource.java:172)
org.apache.catalina.webresources.CachedResource.validateResource(CachedResource.java:89)
org.apache.catalina.webresources.Cache.getResource(Cache.java:87)
org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:216)
org.apache.catalina.webresources.StandardRoot.getClassLoaderResource(StandardRoot.java:225)
org.apache.catalina.loader.WebappClassLoaderBase.findResource(WebappClassLoaderBase.java:907)
org.apache.catalina.loader.WebappClassLoaderBase.getResource(WebappClassLoaderBase.java:1026)
com.mysql.jdbc.AbandonedConnectionCleanupThread.checkContextClassLoaders(AbandonedConnectionCleanupThread.java:90)
com.mysql.jdbc.AbandonedConnectionCleanupThread.run(AbandonedConnectionCleanupThread.java:63)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)
Dec 13, 2018 3:06:37 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-nio-8080"]
15:06:37 INFO Tomcat 9.0.13 started and listening on port 8080
15:06:37 INFO iC runs at:
15:06:37 INFO http://localhost:8080/iC
15:06:37 DEBUG Tomcat 9.0.13 started.
奇怪的是,我可以在一个独立的tomcat实例中运行该Web应用程序(我已经确保了tomcat的版本和servlet相同)。
gretty插件对我的另一个webapp来说很好用,所以我认为这与实际的webapp本身有关,但我不知道从哪里开始找到问题的根源,因为它在独立的tomcat实例中工作这使这项任务变得困难得多。