Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink-Moxy Unable to load custom DomHandler in OSGI environment(EclipseLink-Moxy Unable to load custom DomHandler class while instantiating JAXB context)
EclipseLink-Moxy Unable to load custom DomHandler in OSGI environment [message #1793668] Mon, 13 August 2018 17:52
Murli Hiware is currently offline Murli HiwareFriend
Messages: 1
Registered: August 2018
Junior Member
I am using Eclipselink Moxy Implementation of JAXB in my project to map complex XML to String Object using XmlAnyElement. For this I have implemented DomHandler named as LayoutHandler. I am using JAXB for resteasy web services deployed in JBoss 6.

I am facing Below issue intermittently -
  Exception [EclipseLink-50033] (Eclipse Persistence Services - 2.5.0.v20130507-3faac2b): 
org.eclipse.persistence.exceptions.JAXBException
Exception Description: The DomHandlerConverter for DomHandler 
[com.**.LayoutHandler] set on property [layoutXml] could not be 
initialized.
Internal Exception: java.lang.ClassNotFoundException: 
com.**.LayoutHandler from 
BaseClassLoader@5c0b3ad0{vfs:///*/*/jboss-server/server/all/deployers/resteasy.deployer}
    While EclipseLink Moxy is instantiating JAXBContext using JAXBContext.newInstance(classes, properties)


After spending some time in debugging and analyzing the issue I could figure out that ClassLoader of resteasy is getting used to load LayoutHandler class instead of my application class loader(vfs://///jboss-server/server/all/deploy/app_name.ear/app_name.war/) which is causing the issue as its unable to find the LayoutHandler class.

Further debugging into org.eclipse.persistence.jaxb.JAXBContextFactory revealed that below two classes are getting passed to createContext() method of JAXBContextFactory -


    org.jboss.resteasy.plugins.providers.jaxb.JaxbCollection
    com.**.Model_class



public static javax.xml.bind.JAXBContext createContext(Class[] classesToBeBound, Map properties) throws JAXBException {
        ClassLoader loader = null;
        if (classesToBeBound.length > 0) {
            loader = classesToBeBound[0].getClassLoader();
        }
        return createContext(classesToBeBound, properties, loader);
    }


In above method classloader of first class is getting used to load the custom DomHandler later on.
When first element in array is model class at that time code is working fine as application context class loader is getting used but when the first element in array is JaxbCollection rest easy context class loader is getting used and its throwing mentioned exception.

This issue is occurring intermittently as order of elements in array is varying.
Previous Topic:Using XmlJavaTypeAdapter(s) to map a third party class
Next Topic:Cache L2 sharing objects with managed entities
Goto Forum:
  


Current Time: Sun Sep 23 06:16:57 GMT 2018

Powered by FUDForum. Page generated in 0.01272 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top