简体   繁体   English

春季4迁移:OutOfMemoryError:PermGen空间

[英]Spring 4 Migration: OutOfMemoryError: PermGen Space

While Migrating Spring 3.2 to Spring 4.1 I am getting the following error while hitting the JSP. 在将Spring 3.2迁移到Spring 4.1时,遇到JSP时出现以下错误。

    java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9910)
    at org.eclipse.jdt.internal.compiler.parser.Parser.parse(Parser.java:9890)
    at org.eclipse.jdt.internal.compiler.parser.Parser.dietParse(Parser.java:8454)
    at org.eclipse.jdt.internal.compiler.Compiler.internalBeginToCompile(Compiler.java:718)
    at org.eclipse.jdt.internal.compiler.Compiler.beginToCompile(Compiler.java:383)
    at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:428)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:450)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)       

The rest services and other internal business logics of the application works fine. 应用程序的其余服务和其他内部业务逻辑运行良好。 whenever I try to hit any jsp, i got the following error. 每当我尝试击中任何jsp时,都会出现以下错误。

These are the JSP related dependencies I use in my app. 这些是我在应用程序中使用的与JSP相关的依赖关系。

    <dependency>
        <groupId>jstl</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>2.3.1</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.0.1</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.0</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>jsp-api</artifactId>
        <version>2.1</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

I use tile 3 and added all the related dependencies of Tiles. 我使用图块3并添加了图块的所有相关依赖项。 Any idea how to resolve this???? 任何想法如何解决这个??? Also, help me out with the Dependencies, I have Spring MVC application with Apache Tiles and JSPs as the front-end. 另外,请帮助我解决依赖关系,我有Spring MVC应用程序,其中以Apache Tiles和JSP为前端。

Your stack trace says that you've run out of PermGen space so you need to allocate some more. 您的堆栈跟踪表明您已经用完了PermGen空间,因此您需要分配更多空间。 There's a link here which guides you through the steps to do this for tomcat: http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/ 这里有一个链接,可指导您完成针对tomcat的步骤: http : //www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/

Basically, you just need to add 基本上,您只需要添加

-XX:MaxPermSize=<size>

to the JVM arguments used to start tomcat, where <size> is the amount of perm gen space to allocate. 用于启动tomcat的JVM参数,其中<size>是要分配的perm gen空间量。 eg 例如

-XX:MaxPermSize=512m

In case you're interested, this isn't a direct result of upgrading your dependencies, more like a side effect - the newer versions of the libraries require more Perm Gen space, so during the upgrade, your app has gone over the existing limit, and thus you need to add more. 如果您有兴趣,这不是升级依赖项的直接结果,更像是副作用-较新版本的库需要更多的Perm Gen空间,因此在升级过程中,您的应用已超出了现有限制,因此您需要添加更多。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM