zoukankan      html  css  js  c++  java
  • 项目启动异常

    最近公司让我帮忙部署一个环境,应用服务器用的tomcat,在启动时报如下错误:

    信息: Deploying web application directory chongYiDa
    java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
    Caused by: java.lang.OutOfMemoryError: PermGen space
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2820)
    at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1143)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1638)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
    at org.apache.catalina.startup.ContextConfig.checkHandlesTypes(ContextConfig.java:1937)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:1900)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1787)
    at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1746)
    at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1732)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1237)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:866)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:316)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4900)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:812)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:787)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:570)
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1010)
    at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:933)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:468)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1267)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:308)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:328)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:308)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1043)

    原因解析:

    加载时用了大量的反射,动态代理

    PermGen space的全称是Permanent Generation space,是指内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGen space中,它和存放类实例(Instance)的Heap区域不同,GC(Garbage Collection)不会在主程序运行期对PermGen space进行清理,所以如果你的应用中有很多CLASS的话,就很可能出现PermGen space错误,这种错误常见在web服务器对JSP进行pre compile的时候。如果你的WEB APP下都用了大量的第三方jar, 其大小超过了jvm默认的大小(4M)那么就会产生此错误信息了。

    解决办法:在catalina.bat第二行添加

    @echo off
    set JAVA_OPTS=-server -Xms256m -Xmx512m -XX:PermSize=512M -XX:MaxPermSize=1024M

  • 相关阅读:
    12月12日总结
    练习:请用索引取出下面list的指定元素:
    练习:小明身高1.75,体重80.5kg。请根据BMI公式(体重除以身高的平方)帮小明计算他的BMI指数,并根据BMI指数:
    练习:请利用循环依次对list中的每个名字打印出Hello, xxx!:
    练习:学员管理系统
    练习:请修改列表生成式,通过添加if语句保证列表生成式能正确地执行
    CF1067D Computer Game
    高等数学第三章
    CF755G PolandBall and Many Other Balls
    TS泛型工具
  • 原文地址:https://www.cnblogs.com/programmerblog/p/5407224.html
Copyright © 2011-2022 走看看