Aby
Aby

Reputation:

JAXB - permGen error on Tomcat server

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.<init>(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)

Upvotes: 1

Views: 2268

Answers (4)

Eric
Eric

Reputation: 11

Had the same problem in Tomcat 5.5 JAXB will cause a lot of memory leaks for you, since it creates heaps of static variables in the server.

References: http://blogs.oracle.com/fkieviet/entry/classloader_leaks_the_dreaded_java http://blogs.oracle.com/fkieviet/entry/how_to_fix_the_dreaded

Upvotes: 1

user3481057
user3481057

Reputation: 1

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 :)

Upvotes: 0

Lastnico
Lastnico

Reputation: 1471

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

-Xms128m -Xmx512m -XX:128m

Upvotes: 0

duffymo
duffymo

Reputation: 308958

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.

Upvotes: 0

Related Questions