Expand my Community achievements bar.

JAXB parser giving error

Avatar

Level 2

Hi, 

I am trying to parse an xml into Java POJO using JAXB on CQ 5.6.1. 

While creating new instance of JAXBContext that is JAXBContext jaxbContext = JAXBContext.newInstance(SomeClass.class);

 I am getting below error:

java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory]
        at javax.xml.bind.ContextFinder.newInstance(Unknown Source)
        at javax.xml.bind.ContextFinder.find(Unknown Source)
        at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
        at javax.xml.bind.JAXBContext.newInstance(Unknown Source)
        at com.bsc.gwc.common.OutputFacetListController.getParseXML(OutputFacetListController.java:115)
        at org.apache.jsp.libs.cq.searchpromote.components.linklist.facetcontent_jsp._jspService(facetcontent_jsp.java:235)
        at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:502)
        ... 226 more

 

I have added jaxb-api and jaxb-impl dependencies in pom.xml. 

Can anyone tell how to overcome to this error: 

Thanks in advance!

3 Replies

Avatar

Employee Advisor

Hi,

how do you add these dependencies to your pom? Are these classes available to OSGI?

Avatar

Employee

Just recompile classes by/var/classes and see if that works. 

Avatar

Administrator

Hi 

Please have a look at this forum post:

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

// 

You can configure the maven bundle plugin of you third party bundle to import the explicit version of the JAXB API. Example given below (Replace the JAXB package and the version numbers appropriately)

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
        <instructions>
            <Import-Package> 
               org.apache.sling.event.jobs.consumer;version="[1.0.0,1.10)",
                *
            </Import-Package>

I hope this would help you.

~kautuk



Kautuk Sahni