tomcat 報錯 java.lang.OutOfMemoryErro

germo發表於2021-09-09

tomcat 報錯 java.lang.OutOfMemoryError ( PermGen space)異常的解決方法

我使用SpringSource Tool Suite 3.0.1,Tomcat 7,我成功的編譯了我的web程式,tomcat可以正常執行,但是當重啟tomcat server時會出現下面的異常資訊:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: PermGen space

詳細的異常資訊如下:

org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: PermGen space     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)     javax.servlet.http.HttpServlet.service(HttpServlet.java:621)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:112)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.(BasicAuthenticationFilter.java:177)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)     org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)     org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) root cause java.lang.OutOfMemoryError: PermGen space     java.lang.ClassLoader.defineClass1(Native Method)     java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)     java.lang.ClassLoader.defineClass(ClassLoader.java:615)     java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)     java.net.URLClassLoader.defineClass(URLClassLoader.java:283)     java.net.URLClassLoader.access$000(URLClassLoader.java:58)     java.net.URLClassLoader$1.run(URLClassLoader.java:197)     java.security.AccessController.doPrivileged(Native Method)     java.net.URLClassLoader.findClass(URLClassLoader.java:190)     java.lang.ClassLoader.loadClass(ClassLoader.java:306)     java.lang.ClassLoader.loadClass(ClassLoader.java:247)     org.eclipse.jdt.internal.compiler.parser.Parser.createJavadocParser(Parser.java:8256)     org.eclipse.jdt.internal.compiler.parser.Parser.(Parser.java:889)     org.eclipse.jdt.internal.compiler.Compiler.initializeParser(Compiler.java:685)     org.eclipse.jdt.internal.compiler.Compiler.(Compiler.java:283)     org.eclipse.jdt.internal.compiler.Compiler.(Compiler.java:204)     org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:442)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)     org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)     org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

在tomcat的日誌中可以看到具體的異常資訊

org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.login_jsp     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:178)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)     org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)     org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)     javax.servlet.http.HttpServlet.service(HttpServlet.java:621)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:112)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.(BasicAuthenticationFilter.java:177)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)     org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)     org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) root cause java.lang.ClassNotFoundException: org.apache.jsp.WEB_002dINF.views.login_jsp     java.net.URLClassLoader$1.run(URLClassLoader.java:202)     java.security.AccessController.doPrivileged(Native Method)     java.net.URLClassLoader.findClass(URLClassLoader.java:190)     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:132)     org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:63)     org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:172)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:370)     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)     org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)     org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)     org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)     org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)     org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)     org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)     javax.servlet.http.HttpServlet.service(HttpServlet.java:621)     javax.servlet.http.HttpServlet.service(HttpServlet.java:722)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:368)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)     org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:97)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:100)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:78)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:112)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:35)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.(BasicAuthenticationFilter.java:177)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:187)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)     org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)     org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)     org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)     org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167) note The full stack trace of the root cause is available in the Apache Tomcat/7.0.21 logs.

這個問題是典型的記憶體溢位異常,”java.lang.OutOfMemoryError: PermGen space“表示記憶體永久區溢位了。

要解決這個問題需要配置jvm引數,增加永久區的記憶體大小,如下配置引數:

-Xmx1024m -XX:MaxPermSize=512m

原文連結:

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/1868/viewspace-2811191/,如需轉載,請註明出處,否則將追究法律責任。

相關文章