Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Adobe Summit 2023 [19th to 23rd March, Las Vegas and Virtual] | Complete AEM Session & Lab list
SOLVED

JAXB exception on AEM 5.6.1

Avatar

Level 4

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)
 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

Avatar

Correct answer by
Employee Advisor

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>