Expand my Community achievements bar.

SOLVED

Critical issue in AEM while using JAXB : Dynamic class loader has already been deactivated.

Avatar

Level 5

We have an event listener that listens to a xml file created under a folder. JAXB is used to convert that XML to a class. It keeps failing with error

s/metadata/95308.xml] org.apache.sling.commons.classloader.impl.ClassLoaderFacade Dynamic class loader has already been deactivated.
08.01.2016 14:02:10.538 *ERROR* [JobHandler: /etc/workflow/instances/2016-01-08/model_5139962994559875:/content/imf/boarddocuments/metadata/95308.xml] org.apache.sling.commons.classloader.impl.ClassLoaderFacade Dynamic class loader has already been deactivated.
08.01.2016 14:02:10.538 *ERROR* [JobHandler: /etc/workflow/instances/2016-01-08/model_5139962994559875:/content/imf/boarddocuments/metadata/95308.xml] org.imf.imfconnect.tgs.workflow.BoardDocumentsProcessorV2 Board document import job failed.  Metadata Path = /content/imf/boarddocuments/metadata/95308.xml, Document Path = , Exception = null javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:227)
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:445)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:637)
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
    at org.imf.imfconnect.tgs.workflow.BoardDocumentsProcessorV2.execute(BoardDocumentsProcessorV2.java:111)

where line 111 is the line where we are parsing into the class.

Funny thing is, next time it's run, it works. But then we have to manually recreate the xml. 

Any ideas? We need a resolution fairly urgently. I read a similar thread that this has been fixed in AEM 6.0 SP1 here.

http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manage...

we have 5.6.1. How can this be fixed???

------------------------------

                logger.info("Processing XML  : "+path);
                metadataPath = path;
                adminResolver = resolverFactory.getAdministrativeResourceResolver(null);
                adminSession = adminResolver.adaptTo(Session.class);
                Node ntFileNode = adminResolver.getResource(path).adaptTo(Node.class); 
                Node ntResourceNode = ntFileNode.getNode(JcrConstants.JCR_CONTENT);
                is = ntResourceNode.getProperty(JcrConstants.JCR_DATA).getBinary().getStream();
                JAXBContext jaxbContext = JAXBContext.newInstance(BoardDocuments.class);
                Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();

1 Accepted Solution

Avatar

Correct answer by
Level 10

The referenced earlier forum post has no relation here.

Not all JVM classes are exported by default in Felix,

  1. You want to do it at a system level you need play with the org.osgi.framework.bootdelegation property to get the classes exported (in sling.properties). This is intended behaviour. So you need to Add the package "com.sun.xml.internal.bind.v2" to the sling.properties
  2. You could look a https://github.com/antonyh/cq5-cxf if you wanted to do it without changing system properties.
  3. any one of above 2 should solve your issue. In case not Just try with class loader with something like [1].

 

[1]

 final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
try {
....
Thread.currentThread().setContextClassLoader(javax.xml.bind.JAXBContext.class.getClassLoader());

  JAXBContext jaxbContext = JAXBContext.newInstance(BoardDocuments.class);
...

} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

The referenced earlier forum post has no relation here.

Not all JVM classes are exported by default in Felix,

  1. You want to do it at a system level you need play with the org.osgi.framework.bootdelegation property to get the classes exported (in sling.properties). This is intended behaviour. So you need to Add the package "com.sun.xml.internal.bind.v2" to the sling.properties
  2. You could look a https://github.com/antonyh/cq5-cxf if you wanted to do it without changing system properties.
  3. any one of above 2 should solve your issue. In case not Just try with class loader with something like [1].

 

[1]

 final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
try {
....
Thread.currentThread().setContextClassLoader(javax.xml.bind.JAXBContext.class.getClassLoader());

  JAXBContext jaxbContext = JAXBContext.newInstance(BoardDocuments.class);
...

} finally {
Thread.currentThread().setContextClassLoader(oldLoader);
}