web-dev-qa-db-fra.com

java.lang.OutOfMemoryError (espace PermGen) et Java.lang.ClassNotFoundException à l'ouverture de la page jsp

J'utilise SpringSource Tool Suite 3.0.1, serveur Tomcat 7.0.21, maven-2.2.1. J'ai réussi à construire mon application Web et à exécuter le serveur Tomcat. L'application a fonctionné avec succès. Après avoir redémarré le serveur Tomcat, j’ai vu tour à tour les erreurs suivantes avec des exceptions sur la page Web login.jsp:

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

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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.www.BasicAuthenticationFilter.doFilter(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.<init>(Parser.Java:889)
    org.Eclipse.jdt.internal.compiler.Compiler.initializeParser(Compiler.Java:685)
    org.Eclipse.jdt.internal.compiler.Compiler.<init>(Compiler.Java:283)
    org.Eclipse.jdt.internal.compiler.Compiler.<init>(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)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.21 logs.

et

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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.www.BasicAuthenticationFilter.doFilter(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.www.BasicAuthenticationFilter.doFilter(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.

login.jsp - la page d'accueil est configurée par SpringSecurity.

Je ne comprends pas la source du problème, car je n'ai pas reconstruit le projet. Après cela, j'essaie de plusieurs manières de récupérer les erreurs:

  • Actualiser le projet
  • Nettoyer et reconstruire le projet
  • Mettre à jour la dépendance maven
  • Nettoyer le répertoire de travail Tomcat
  • Nettoyer ... bouton du menu du serveur

Rien des moyens ne m'a pas aidé. Mais la logique interne de l'application fonctionne correctement (elle n'est pas associée à l'interface Web). Je reçois des messages de journal appropriés. Mais dès que j'ouvre la page login.jsp, je reçois les messages d'erreur. Ensuite, j'ai essayé de revenir à la version stable précédente du projet. Malheureusement, j'ai les mêmes erreurs.

Le journal de la console affiche les messages suivants avant de générer les messages d'erreur sur la page logon.jsp:

02.04.2012 11:22:41 org.Apache.jasper.compiler.TldLocationsCache tldScanJar
INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
02.04.2012 11:22:44 org.Apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [appServlet] in context with path [/main] threw exception [Handler processing failed; nested exception is Java.lang.OutOfMemoryError: PermGen space] with root cause
Java.lang.OutOfMemoryError: PermGen space

J'ai trouvé des questions similaires: http://www.mail-archive.com/[email protected]/msg54797.html et http://wiki.metawerx.net/wiki/Org.Apache .jasper.JasperException . Mais cela ne m'a pas aidé.

Comment résoudre ce problème?

9
Didgeridoo

Pour l'erreur OutOfMemory, assurez-vous que les paramètres suivants sont définis (et avec une valeur respectable)

-Xmx1024m -XX:MaxPermSize=512m

EDIT:

512m et 1024m ne sont que des suggestions! Vous devrez peut-être ajuster ces paramètres à vos ressources matérielles.

Habituellement, vous devriez commencer à environ 128 m et chaque fois que vous obtenez une erreur OutOfMemory, essayez de doubler le montant alloué.

Pour exemple:

  • vous avez 256 m pour MaxPermSize et vous obtenez OutOfMemory - le nouveau seuil doit être défini sur 512 m

  • vous avez 512m pour MaxPermSize et vous obtenez OutOfMemory - le nouveau seuil doit être défini sur 1G

Pour plus d'informations sur le réglage des paramètres JVM, reportez-vous à la documentation officielle de Java à l'adresse Oracle .

19

Juste une version développée de La réponse de Bogdan
1. Au Menu principal _ allez à Fenêtre -> Afficher la vue -> Serveurs
2. Dans la vue 'Serveurs} _', double-cliquez sur 'Tomcat'
3. Une page Présentation de Tomcat sera ouverte.
4. Recherchez la section 'Informations générales} _' et cliquez sur 'Ouvrir la configuration de lancement}'
5. Dans la fenêtre contextuelle 'Edit Configuration} _', accédez à l'onglet Arguments
6. Recherchez la section 'VM _ arguments} _' et placez -Xmx1024m -XX: MaxPermSize = 512m there
7. Cliquez sur 'OK' et démarrez votre Tomcat.

14
Anton Shchastnyi

On dirait que Tomcat est en train de compiler les JSP, vous pouvez envisager de les précompiler (ce qui présenterait l'avantage supplémentaire de rechercher dans les JSP des erreurs de syntaxe avant de déployer votre application).

Voir aussi: Comment puis-je faire en sorte que les JSP pré-compilés de Tomcat soient démarrés?

1
beny23

Cela dépend du fichier que vous utilisez, soit catalina.bat ou catalina.sh. Définissez les options Java comme ci-dessous et essayez:

set Java_OPTS=%Java_OPTS% %LOGGING_CONFIG% -Xms512m -Xmx512m -XX:PermSize=512m -XX:MaxPermSize=1024m
0
Jyotshna Pardhia