Announcement Announcement Module
Collapse
No announcement yet.
java.lang.OutOfMemoryError: PermGen space Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • java.lang.OutOfMemoryError: PermGen space

    I got the following error after I have deployed my application 5-6 times and it's being repeated every time.

    I'm using spring with hibernate and tomcat.

    What could be the cause of the problem?

    Error:
    Code:
    javax.servlet.ServletException: Servlet.init() for servlet mywebapp threw exception
    	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
    	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
    	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
    	org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
    	org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
    	org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
    	org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
    	java.lang.Thread.run(Unknown Source)
    
    root cause
    
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.OutOfMemoryError: PermGen space
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1113)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:281)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:241)
    	org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    	org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:82)
    	javax.servlet.GenericServlet.init(GenericServlet.java:212)
    	org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1176)
    	org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:369)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    
    root cause
    
    java.lang.OutOfMemoryError: PermGen space
    	java.lang.ClassLoader.defineClass1(Native Method)
    	java.lang.ClassLoader.defineClass(Unknown Source)
    	java.security.SecureClassLoader.defineClass(Unknown Source)
    	org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1847)
    	org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:873)
    	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1326)
    	org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
    	java.lang.ClassLoader.loadClassInternal(Unknown Source)
    	org.hibernate.mapping.Table.createForeignKey(Table.java:570)
    	org.hibernate.mapping.Table.createForeignKey(Table.java:561)
    	org.hibernate.mapping.SimpleValue.createForeignKeyOfEntity(SimpleValue.java:94)
    	org.hibernate.mapping.ManyToOne.createForeignKey(ManyToOne.java:39)
    	org.hibernate.mapping.Collection.createForeignKeys(Collection.java:378)
    	org.hibernate.mapping.Collection.createAllKeys(Collection.java:387)
    	org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:44)
    	org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
    	org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
    	org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
    	org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
    	org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
    	org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
    	org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
    	org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
    	org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
    	org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:281)
    	org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
    	org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:241)
    	org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)
    	org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:82)

    my applicationContext.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    
    <beans>	
    
    	<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    		<property name="configLocation" value="WEB-INF/classes/hibernate.cfg.xml"/>
    	</bean>
    
    	<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
    	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    		<property name="sessionFactory" ref="sessionFactory"/>
    	</bean>
    	<bean id="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true">
    		<property name="transactionManager" ref="transactionManager"/>
    		<property name="transactionAttributes">
    			<props>
    				<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
    				<prop key="persist*">PROPAGATION_REQUIRED,-Exception</prop>
    				<prop key="remove*">PROPAGATION_REQUIRED,-Exception</prop>
    			</props>
    		</property>
    	</bean>
    	<bean id="MywebappService" parent="baseTransactionProxy">
    		<property name="target">
    			<bean class="dao.MywebappSpringService">
    				<property name="dao">
    					<bean class="dao.MywebappHibernateDao">
    						<property name="sessionFactory" ref="sessionFactory"/>
    					</bean>
    				</property>
    			</bean>
    		</property>
    	</bean>
    	</beans>

  • #2
    Cause of the problem is a bug 8or rather design flaw) in Sun JVM starting from 1.5. E.g. Eclipse 3.2 is heavily affected by this bug (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=153485 for details), Tomcat is influenced as well. I do not have references on hands right now, but it quite easily may be goodled out. The easiest solution is to use JVM from nother vendor (e.g. BEA JRockit or IBM J9).

    Regards,
    Oleksandr

    Comment

    Working...
    X