我有一个正在Tomcat 7.0.57中部署的Grails 2.3.6版本应用程序
我已将WAR文件放在Tomcat的webapps文件夹中。当我启动服务器时,在控制台窗口中会出现异常。看起来部署正在进行中,并且在一段时间后引发了异常。
请参阅下面的stacktrace:当我转到Windows任务管理器时,jave.exe占用了将近70-80%的CPU。
INFO: Deploying web application archive C:\Tomcat7\apache-tomcat-7.0.57\webapps\ MY-1.0.2.war Dec 22, 2014 3:58:17 PM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/core is already defined Dec 22, 2014 3:58:17 PM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://java.sun.com/jsp/jstl/fmt is already defined Dec 22, 2014 3:58:18 PM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://www.springframework.org/tags is already defined Dec 22, 2014 3:58:18 PM org.apache.catalina.startup.TaglibUriRule body INFO: TLD skipped. URI: http://www.springframework.org/tags/form is already defi ned log4j:WARN No appenders could be found for logger (org.codehaus.groovy.grails.co mmons.cfg.ConfigurationHelper). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more in fo. Configuring Spring Security Core ... ... finished configuring Spring Security Core Dec 22, 2014 3:58:55 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Tomcat7\apache-tomcat-7.0.57\webapp s\docs Dec 22, 2014 3:58:55 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deployment of web application directory C:\Tomcat7\apache-tomcat-7.0.57\we bapps\docs has finished in 30 ms Dec 22, 2014 3:58:55 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Tomcat7\apache-tomcat-7.0.57\webapp s\examples Dec 22, 2014 3:58:56 PM org.apache.tomcat.util.digester.Digester startElement SEVERE: Begin event threw error java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:800) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14 2) at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at java.net.URLClassLoader$1.run(URLClassLoader.java:361) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.apache.catalina.deploy.SecurityConstraint.<init>(SecurityConstrai nt.java:94) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct orAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC onstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:379) at org.apache.tomcat.util.digester.ObjectCreateRule.begin(ObjectCreateRu le.java:145) at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1 288) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startEle ment(AbstractSAXParser.java:509) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp l.scanStartElement(XMLDocumentFragmentScannerImpl.java:1363) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp l$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(X MLDocumentScannerImpl.java:606) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp l.scanDocument(XMLDocumentFragmentScannerImpl.java:510) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X ML11Configuration.java:848) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(X ML11Configuration.java:777) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser. java:141) at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab stractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p arse(SAXParserImpl.java:648) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561) at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.j ava:1825) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav a:1263) Dec 22, 2014 3:58:57 PM org.apache.catalina.startup.HostConfig deployDirectories SEVERE: Error waiting for multi-thread deployment of directories to complete java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen spa ce at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j ava:1148) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1611) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :330) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa se.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase .java:402) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34 7) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja va:1140) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java :816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1565) 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) Caused by: java.lang.OutOfMemoryError: PermGen space at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Ab stractSAXParser.java:1213) at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.p arse(SAXParserImpl.java:648) at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1561) at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.j ava:1825) at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.jav a:1263) at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfi g.java:889) at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfi g.java:386) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa se.java:90) at org.apache.catalina.core.StandardContext.startInternal(StandardContex t.java:5380) 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:87 7) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.jav a:1245) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig .java:1895) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:47 1) ... 4 more Dec 22, 2014 3:58:57 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Tomcat7\apache-tomcat-7.0.57\webapp s\host-manager Dec 22, 2014 3:59:19 PM org.apache.catalina.startup.HostConfig deployDirectories SEVERE: Error waiting for multi-thread deployment of directories to complete java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen spa ce at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j ava:1148) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1611) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :330) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa se.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase .java:402) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34 7) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja va:1140) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java :816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1565) 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) Caused by: java.lang.OutOfMemoryError: PermGen space Dec 22, 2014 3:59:19 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Tomcat7\apache-tomcat-7.0.57\webapp s\manager Dec 22, 2014 3:59:20 PM org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory C:\Tomcat7\apache-tomcat-7.0.57\webapp s\ROOT Dec 22, 2014 3:59:20 PM org.apache.catalina.startup.HostConfig deployDirectories SEVERE: Error waiting for multi-thread deployment of directories to complete java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen spa ce at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j ava:1148) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1611) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :330) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa se.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase .java:402) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34 7) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja va:1140) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java :816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1565) 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) Caused by: java.lang.OutOfMemoryError: PermGen space Exception in thread "quartzScheduler_QuartzSchedulerThread" Dec 22, 2014 3:59:21 PM org.apache.catalina.startup.HostConfig deployDirectories SEVERE: Error waiting for multi-thread deployment of directories to complete java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: PermGen spa ce at java.util.concurrent.FutureTask.report(FutureTask.java:122) at java.util.concurrent.FutureTask.get(FutureTask.java:188) at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.j ava:1148) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490 ) at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1611) at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java :330) at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(Lifecycl eSupport.java:117) at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBa se.java:90) at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase .java:402) at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:34 7) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.ja va:1140) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java :816) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1575) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase. java:1565) 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) Caused by: java.lang.OutOfMemoryError: PermGen space Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i n thread "quartzScheduler_QuartzSchedulerThread" Exception in thread "main" Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler i n thread "main"
由于在运行时创建了动态代码,Grails使用的内存超出了您的预期,并且使用了更多的permgen。您无需过多增加permgen- 首先尝试将其设置为256MB。
为permgen和其他类似设置放置JVM args的最佳位置是在Tomcat的bin目录中的setenv.sh(或Windows上的.bat)中。它不是默认创建的,不需要可执行,但是它使用与Shell脚本相同的格式。任何导出的变量都将在catalina.sh中使用
这应该是足够的总堆和permgen:
export CATALINA_OPTS="-Xms256m -Xmx768m -XX:MaxPermSize=256m"