JAXB exception on AEM 5.6.1 | Community
Skip to main content
Level 3
March 18, 2016
Solved

JAXB exception on AEM 5.6.1

  • March 18, 2016
  • 1 reply
  • 1318 views

Hi

I am getting an exception with JAXB in one my OSGI Service in my bundle. This happens only when a jax-b api 2.2.12 manually is installed in console. As JAX-b(2.1.0) is already provided internally in AEM by below bundle. This exception doesn't happen when the 2.2.12 is not present. However this is being used by some other bundles built by another vendor. Hence I cant remove this 2.2.12 bundle from felix console.

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.fragment.xml</artifactId>
<version>1.0.2</version>
</dependency>


I was just wondering how could I force my bundle to ignore looking for jax-b 2.2.12 and take only the system default 2.1.0 version. Is it possible to define this behaviour by maven bundle plugin in the POM. 

@Activate
public void activate(ComponentContext ctx) throws JAXBException {
        abcContext = JAXBContext.newInstance(ABC.class);


    }

BUndle plugin import package definition
                        <Import-Package>                            
                            *;resolution:=optional
                        </Import-Package>


Exception
 
16.03.2016 03:13:05.709 *ERROR* [Background Update foo.barsupport-bundle (606)] foo.barsupport-bundle [foo.bar.calendar.impl.CalendarEventParserImpl] The activate method has thrown an exception (javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by cqse-httpservice [25]]) javax.xml.bind.JAXBException
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.internal.bind.v2.ContextFactory not found by cqse-httpservice [25]]
         at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:241)
         at javax.xml.bind.ContextFinder.find(ContextFinder.java:477)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656)
         at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599)
         at foo.bar.integration.calendar.impl.CalendarEventParserImpl.activate(CalendarEventParserImpl.java:33)
 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

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>

1 reply

Kunal_Gaba_
Kunal_Gaba_Accepted solution
March 18, 2016

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>