执行<g:render> Grails 3.0.5时出错

时间:2015-11-04 17:07:22

标签: grails out-of-memory permgen

我正在使用Grails 3.0.5

尝试使用java -Dgrails.env=prod -jar

进行部署时出现此错误
    Configuring Spring Security Core ...
... finished configuring Spring Security Core

Grails application running at http://localhost:8080 in environment: production
ERROR StackTrace - Full Stack Trace:
org.grails.taglib.GrailsTagException: [views/layouts/secure0.gsp:142] Error executing tag <g:render>: PermGen space
        at org.grails.gsp.GroovyPage.throwRootCause(GroovyPage.java:445) ~[grails-gsp-3.0.5.jar!/:3.0.5]
        at org.grails.gsp.GroovyPage.invokeTag(GroovyPage.java:388) ~[grails-gsp-3.0.5.jar!/:3.0.5]
        at sun.reflect.GeneratedMethodAccessor263.invoke(Unknown Source) ~[na:na]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_79]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_79]
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) ~[groovy-2.4.4.jar!/:2.4.4]
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2.4.4.jar!/:2.4.4]
        at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:384) ~[groovy-2.4.4.jar!/:2.4.4]
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1019) ~[groovy-2.4.4.jar!/:2.4.4]
        at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) ~[groovy-2.4.4.jar!/:2.4.4]

在部署之前,我在localhost中测试,它运行时没有任何错误。

但是在部署之后我得到了这个错误。

我的代码出了什么问题?

Configuring Spring Security Core ...
... finished configuring Spring Security Core

Grails application running at http://localhost:80 in environment: production
ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[grailsDis           patcherServlet] - Servlet.service() for servlet [grailsDispatcherServlet] in con           text with path [] threw exception [Handler processing failed; nested exception i           s java.lang.OutOfMemoryError: PermGen space] with root cause
java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_79]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[na:1.7.0_79           ]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14           2) ~[na:1.7.0_79]
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[na:1.7           .0_79]
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[na:1.7.0           _79]
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.7.0_79]
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_79]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0           _79]
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0           _79]
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(La           unchedURLClassLoader.java:163) ~[ChatV3-0.1.jar!/:na]
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(Laun           chedURLClassLoader.java:136) ~[ChatV3-0.1.jar!/:na]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ~[na:1.7.0_79]
        at org.grails.buffer.StreamCharBuffer$MultipartCharBufferChunk.asStringC           hunk(StreamCharBuffer.java:1864) ~[grails-encoder-3.0.5.jar!/:3.0.5]
        at org.grails.buffer.StreamCharBuffer.readToSingleStringChunk(StreamChar           Buffer.java:720) ~[grails-encoder-3.0.5.jar!/:3.0.5]
        at org.grails.buffer.StreamCharBuffer.toString(StreamCharBuffer.java:700           ) ~[grails-encoder-3.0.5.jar!/:3.0.5]
        at org.grails.buffer.FastStringWriter.getValue(FastStringWriter.java:63)            ~[grails-encoder-3.0.5.jar!/:3.0.5]
        at org.grails.buffer.FastStringWriter.toString(FastStringWriter.java:59)            ~[grails-encoder-3.0.5.jar!/:3.0.5]
        at org.grails.web.pages.GroovyPagesUriSupport.getAbsoluteViewURIInternal           (GroovyPagesUriSupport.java:225) ~[grails-web-common-3.0.5.jar!/:3.0.5]
        at org.grails.web.pages.GroovyPagesUriSupport.getAbsoluteViewURI(GroovyP           agesUriSupport.java:161) ~[grails-web-common-3.0.5.jar!/:3.0.5]
        at org.grails.web.gsp.io.GrailsConventionGroovyPageLocator.findViewByPat           h(GrailsConventionGroovyPageLocator.java:68) ~[grails-web-gsp-3.0.5.jar!/:3.0.5]
        at org.grails.web.servlet.view.GroovyPageViewResolver.createGrailsView(G           roovyPageViewResolver.java:186) ~[grails-web-gsp-3.0.5.jar!/:3.0.5]
        at org.grails.web.servlet.view.GroovyPageViewResolver$1.call(GroovyPageV           iewResolver.java:113) ~[grails-web-gsp-3.0.5.jar!/:3.0.5]
        at org.grails.web.servlet.view.GroovyPageViewResolver$1.call(GroovyPageV           iewResolver.java:110) ~[grails-web-gsp-3.0.5.jar!/:3.0.5]
        at grails.util.CacheEntry.updateValue(CacheEntry.java:170) ~[grails-core           -3.0.5.jar!/:3.0.5]
        at grails.util.CacheEntry.getValue(CacheEntry.java:144) ~[grails-core-3.           0.5.jar!/:3.0.5]
        at grails.util.CacheEntry.getValue(CacheEntry.java:84) ~[grails-core-3.0           .5.jar!/:3.0.5]
        at grails.util.CacheEntry.getValue(CacheEntry.java:102) ~[grails-core-3.           0.5.jar!/:3.0.5]
        at org.grails.web.servlet.view.GroovyPageViewResolver.loadView(GroovyPag           eViewResolver.java:124) ~[grails-web-gsp-3.0.5.jar!/:3.0.5]
        at grails.plugin.scaffolding.ScaffoldingViewResolver.loadView(Scaffoldin           gViewResolver.groovy:36) ~[scaffolding-3.1.1.jar!/:na]
        at org.springframework.web.servlet.view.AbstractCachingViewResolver.crea           teView(AbstractCachingViewResolver.java:244) ~[spring-webmvc-4.1.7.RELEASE.jar!/           :4.1.7.RELEASE]
        at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(           UrlBasedViewResolver.java:446) ~[spring-webmvc-4.1.7.RELEASE.jar!/:4.1.7.RELEASE           ]
        at org.springframework.web.servlet.view.AbstractCachingViewResolver.reso           lveViewName(AbstractCachingViewResolver.java:146) ~[spring-webmvc-4.1.7.RELEASE.           jar!/:4.1.7.RELEASE]
ERROR StackTrace - Full Stack Trace:
org.grails.taglib.GrailsTagException: [views/layouts/main.gsp:8] Error executing            tag <asset:stylesheet>: PermGen space
        at org.grails.gsp.GroovyPage.throwRootCause(GroovyPage.java:445) ~[grail           s-gsp-3.0.5.jar!/:3.0.5]
        at org.grails.gsp.GroovyPage.invokeTag(GroovyPage.java:388) ~[grails-gsp           -3.0.5.jar!/:3.0.5]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.           0_79]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.           java:57) ~[na:1.7.0_79]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces           sorImpl.java:43) ~[na:1.7.0_79]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_79]
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:           93) ~[groovy-2.4.4.jar!/:2.4.4]
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) ~[groovy-2 

ERROR org.apache.catalina.core.ContainerBase - Unexpected death of background thread ContainerBackgroundProcessor[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]
java.lang.OutOfMemoryError: PermGen space
Exception in thread "ContainerBackgroundProcessor[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]"
Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "ContainerBackgroundProcessor[StandardEngine[Tomcat].StandardHost[localhost].StandardContext[]]"

这是我尝试做的事情..

[root@server chat]# export GRAILS_OPTS="-server -d64 -XX:MaxPermSize=1024 -Xmx1024m"
[root@server chat]# java -Dgrails.env=prod -jar ChatV3-0.1.jar

Configuring Spring Security Core ...
... finished configuring Spring Security Core

Grails application running at http://localhost:80 in environment: production
ERROR asset.pipeline.AssetSpecLoader - Error loading asset specification asset.pipeline.CssAssetFile: PermGen space
java.lang.OutOfMemoryError: PermGen space
        at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.7.0_79]
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800) ~[na:1.7.0_79]
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.7.0_79]
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) ~[na:1.7.0_79]
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71) ~[na:1.7.0_79]
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361) ~[na:1.7.0_79]
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_79]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_79]
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_79]
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:163) ~[ChatV3-0.1.jar!/:na]
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136) ~[ChatV3-0.1.jar!/:na]

当我试图获取Java

[root@server chat]# ps -ax | grep java
 3700 ?        Sl     1:27 /usr/java/jdk1.7.0_79/bin/java -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/root/apache-activemq/conf/login.config -Dcom.sun.management.jmxremote -Djava.awt.headless=true -Djava.io.tmpdir=/root/apache-activemq/tmp -Dactivemq.classpath=/root/apache-activemq/conf; -Dactivemq.home=/root/apache-activemq -Dactivemq.base=/root/apache-activemq -Dactivemq.conf=/root/apache-activemq/conf -Dactivemq.data=/root/apache-activemq/data -jar /root/apache-activemq/bin/activemq.jar start
11544 pts/0    S+     0:00 grep --color=auto java

2 个答案:

答案 0 :(得分:1)

您遇到PermGen错误。 尝试使用像:

这样的想法
$ export GRAILS_OPTS="-XX:MaxPermSize=1024m -Xmx1024M -server" 
$ java -Dgrails.env=prod -jar

看看这些问题/答案,他们会帮助你:

答案 1 :(得分:0)

我用

解决了我的问题
java -XX:MaxPermSize:1024m -Dgrails.env=prod -jar hellowWorld.jar