Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
SOLVED

ClassLoader Swapping Causing PermGen Issue

Avatar

Level 2

Hi Adobe,

 

We are trying to integrate CQ with CXF to consume webservices. As per recommendation by CQ from one of the posts, switching classloader makes the OSGI container aware of the class. We tried that option and were successful in integrating the webservice. But the classloader switching is causing a memory leak. With multiple deploys like around 5, the server is coming down. I am surprised that no one else faced this issue with classloader switching. Any help is greatly appreciated. Please see the code below,

ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(BusFactory.class.getClassLoader()); JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(new OsgiAwareClientFactoryBean()); factory.setServiceClass(pClass); factory.setAddress(pPortUrl); factory.setUsername(pUsername); factory.setPassword(pPassword); //This is where it blows up return (T) factory.create(); } Finally{ Switch back to the oldclass }
1 Accepted Solution

Avatar

Correct answer by
Level 5

I have used same mechanism with multiple server and deployment but never had any issue with memory. What application server are you using ?

Can you try BusFactory.getDefaultBus().setProperty("set-jaxb-validation-event-handler", "false"); before setting context ?

Yogesh

View solution in original post

2 Replies

Avatar

Correct answer by
Level 5

I have used same mechanism with multiple server and deployment but never had any issue with memory. What application server are you using ?

Can you try BusFactory.getDefaultBus().setProperty("set-jaxb-validation-event-handler", "false"); before setting context ?

Yogesh

Avatar

Level 2

Hi Yogesh,

Thanks for the reply.

This happens even on my local machine.  I run quick start, do multiple deploys, the permgen space increases up-to 10% for each deploy. I have analyzed the heap and looked at the classes getting loaded. For each deploy the cxf related classes are getting loaded , (sun.xml classes are getting loaded multiple times as well) and they are not getting unloaded. that is causing the increase in permgen. sad

 

On A Side note: I am using two-way ssl handshake authentication, i am sure that is not related to anything above, but just wanted to mention if you have run into something like with twoway ssl. Thanks.