tags:

views:

376

answers:

3

Hi, I am getting the below error when running my deployed app. Going by the error, it seems JAXB is causing it. Please suggest.

java.lang.OutOfMemoryError: PermGen space com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:99) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:70) com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:228) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:89) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:70) com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:198) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:84) com.sun.xml.internal.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:70) com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:304) com.sun.xml.internal.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:319) com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:430) com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:277) com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1100) com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:143) com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:110) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) java.lang.reflect.Method.invoke(Method.java:597) javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202) javax.xml.bind.ContextFinder.find(ContextFinder.java:376) javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574) javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522) MyJava.GetUserProfile.user(GetUserProfile.java:87) com.myapp.struts.TokenDirected.execute(TokenDirected.java:81) org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:425) org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:228) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

A: 

Increase the size of your perm space first. This link shows you how.

Monitor your memory usage with Visual GC to see how this helps.

If it doesn't, get rid of JAXB. I shy away from it for exactly this reason. Better to do your OXM by hand than rely on it.

duffymo
A: 

It is not related to JAXB, but your Tomcat needs more memory from the JVM, so use something like

-Xms128m -Xmx512m -XX:128m
Lastnico
A: 

The problem is related to JaxBContext. Every time you use a new context new classes are loaded. If you reuse your context everything will be fine.

duffyno is right :)

Jordi Domingo