6

We came across a JaxB class loading issue as highlighted by Jaxb classCastException.

To fix that I added com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true and that actually FIXED the issue.

However, I read that this will disable Jaxb's ability to directly interact with bytecode and go through Java Reflection API and so might have a slight performance hit while initilazation of new Jaxb Contexts via "JAXBContext.newInstance".

To test the performance I added a simple method which invokes JAXBContext.newInstance in a for loop some 500 times. And I ran this with the flag=true and =false.

In the worst case, I saw a performance hit of only about 3.5 ms on an average per invocation.

Has anyone had a similar issue and tried the above fix? What were your findings? I couldn't find much information on the com.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize. Can you share more info on its behavior and impact?

Ashish Thukral
  • 1,445
  • 1
  • 16
  • 26

2 Answers2

2

This document from IBM about the JAXB Context initialization might help you: JAXBContext Initialization Takes A Long Time

Problem(Abstract)

JAXBContext initialization slows down application performance.

Symptom

Slow performance in WebSphere Application Server.

Cause

JAXB context (javax.xml.bind.JAXBContext) object instantiation is a resource intensive operation. JAXB Context instantiation involves the pre-load and pre-creation of contexts (called the pre-caching process) of all packages and classes associated with the context, and then all of the packages and classes which are statically (directly and indirectly) referenced from those. Performance latency will correlate with the number of classes which are passed during JAXB creation during this pre-caching process.

tk421
  • 5,775
  • 6
  • 23
  • 34
rieckpil
  • 10,470
  • 3
  • 32
  • 56
0

In a project, we faced a problem with OutOfMemoryError: Metaspace on a daily and regular basis. By adding this setting, the problem was completely resolved and no problem was observed in the overall performance of the service.