问题描述
在windows系统下。 我将一个大的项目拷贝到tomcat/webapps该目录下,在启动tomcat时报内存溢出,也试过在bin/catalina目录下添加set JAVA_OPTS此内容,启动后结果还是一样报错,敬请帮忙 [size=xx-small][/size]以下是部分报错信息: - Closing Hibernate SessionFactory - closing - Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityEngine' defined in class path resource [conf/app-resou rces.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at com.htsoft.core.web.listener.StartupListener.contextInitialized(StartupListener.java:22) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardHost.start(StandardHost.java:840) at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057) at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) at org.apache.catalina.core.StandardService.start(StandardService.java:525) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 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:2818) at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) at org.apache.velocity.runtime.RuntimeInstance.getString(RuntimeInstance.java:1656) at org.apache.velocity.runtime.RuntimeInstance.initializeResourceManager(RuntimeInstance.java:625) at org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:251) at org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:107) at org.springframework.ui.velocity.VelocityEngineFactory.createVelocityEngine(VelocityEngineFactory.java:256) at org.springframework.ui.velocity.VelocityEngineFactoryBean.afterPropertiesSet(VelocityEngineFactoryBean.java:57) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369 ) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380) at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) at com.htsoft.core.web.listener.StartupListener.contextInitialized(StartupListener.java:22) 2011-9-27 14:39:51 org.apache.catalina.core.StandardContext listenerStart 严重: Exception sending context initialized event to listener instance of class com.htsoft.core.web.listener.StartupListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'velocityEngine' defined in class path resource [conf/app-resou rces.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423) 问题补充:Wind_ZhongGang 写道
解决方案
那你别把工程copy到webapps下啊.其他任何地方都可以..然后在<Context path="" docBase="D:/apache-tomcat-6.0.33/webapps/joffice20" debug="0"> 指过去,就可以了..
解决方案二:
http://gaojingsong.iteye.com/blog/1164814
解决方案三:
晕,你在webapp下放着,又在server.xml里配置..会造成重复的..这个重复会不会出问题..我没试过..你可以试试把server.xml里的工程加载配置删除,直接启动,然后访问
解决方案四:
<Context path="" docBase="D:/apache-tomcat-6.0.33/webapps/joffice20" debug="0"> 这句就是指向工程目录的,怎么会没加载哦.呵呵
解决方案五:
你把工程放到tomcat下,他需要加载这么多class类信息等等,所以造成的永久代溢出的..你不加载工程当然就不会有溢出.你能看到对应永久代的大小不..用visualVM
解决方案六:
@Wind_ZhongGang 你们这个服务器配置,我的建议是 -Xms512m -Xmx1024m 这两个值设置成一样,否则在堆扩容或者降容的时候都会造成额外的full gc.而这个是完全可以避免的..
解决方案七:
引用就是你改过的bin/cataline.bat文件中的 set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m 修改后在管理,服务里面重新启动下 如果还不好用,建议换个其他版本的服务器 上面这个方法是对的..至于这个修改是否生效,再说一次,打开visualVM看看
解决方案八:
-Xms512m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m我是这样在服务器配置中进行设置的。
解决方案九:
如果你是用eclipse跑的话,参考上面那位仁兄的位置,加上 -XX:MaxPermSize=512m 试试看.你打开visualVM看看,这个配置是否生效了.visualVM就在jdk的bin目录..JVisualVM .
解决方案十:
就是你改过的bin/cataline.bat文件中的 set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m 修改后在管理,服务里面重新启动下如果还不好用,建议换个其他版本的服务器
解决方案十一:
我很好奇,你竟然连256m都不够..你可以开visualVM看看..具体的PermGen占了多少
解决方案十二:
configure server ->server->tomcat->jdk->java VM下面方框里数据配置信息
解决方案十三:
Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space 已经很明确的告诉你 PermGen溢出了..你只要增加permGen大小就可以了..具体的配置就是-XX:MaxPermSize=512m如果你的工程连512m都不够,那么我觉得可能是死循环造成的..因为整个eclipse也就一百多m..
解决方案十四:
那就只能通过修改配置文件了。
解决方案十五:
配置下jvm大小
解决方案:我用的是TOMCAT5.0,你看看有没有..bintomcat6w.exe或者类似的文件。
其他方案:
魔力猫咪 写道JAVA_OPTS没有设置对。你仔细看一下。我是将下面的内容设置在bin/cataline.bat文件中的 set JAVA_OPTS=-Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=256m 这种方式我曾经试过,但是不知道为什么不好用,你最好试试设置系统环境变量。
解决方案:JAVA_OPTS没有设置对。你仔细看一下。
解决方案:双击..bintomcat5w.exe打开,点击java按钮,修改Inital memory pool和Maximum memory pool的大小。如果还不行就配置系统环境变量:变量名:JAVA_OPTS变量值:-Xms64m -Xmx512m根据自己的机器调整变量值的大小。
解决方案:调整服务器启动时的内存分配。缺省服务器的内存容量,各个区的容量一般偏小,请根据自己的情况进行调整。
解决方案:重新打包一下项目 rebuild