Java class using jaxb api not working in jira with: Provider com.sun.xml.bind.v2.ContextFactory not found

I am writing a plugin for Jira that includes parsing XML documents. I am using JAXB for this (XML for pojos and vice versa) So you have a class that generates XML from pojos using JAXB. it looks like...

import javax.xml.bind.*;

Class Parser {
  public void m1() {
    ...
    // code which uses classes in javax.xml.bind.*
  }

  public static void main(String args[]){
   Parser p=new Parser();
   p.m1();

  } 
}

These packages will ship with the JDK distribution (rt.jar). so I did not pass anything else to run the class.

when I run it from the command line using "java", it works fine. but, when I pack it like a jug and put it in a plugin in Jira, if it did not fulfill the following error:

javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory not found
 - with linked exception:
[java.lang.ClassNotFoundException: com.sun.xml.bind.v2.ContextFactory]
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:152)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:299)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:372)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:337)

. , , , Jira, main(), m1() .

, ! . , Jira ( ).

+5
3

com.sun.xml.bind JAXB RI (http://jaxb.dev.java.net/), , , .

Java6 JAXB, com.sun.xml.internal.bind, RI Java6.

RI Java6, .

0

, , , , , , JIRA ( Atlassian).

JIRA, , , Atlassian, , . 1 2

ClassNotFoundException ( JIRA v4.0.1), , 2, JIRA v4 .

JIRA v4 JIRA OSGi, , , Plugin2 OSGi. OSGi . , , . , JDK . , OSGi - Atlassian Developers. OSGi Springsource. NoClassDefFoundError: com.sun...

.

JIRA Atlassian SDK Maven , . Atlasian Plugin SDK. , pom.xml. JDK- , <SystemProperties> maven-jira-plugin ( Atlassian maven ) bootdelegation ( java 1.6 maven-compiler-plugin):

...
<build>
    <plugins>
        <plugin>
            <groupId>com.atlassian.maven.plugins</groupId>
            <artifactId>maven-jira-plugin</artifactId>
            <version>3.7.3</version>
            <extensions>true</extensions>
            <configuration>
                <productVersion>${jira.version}</productVersion>
                <productDataVersion>${jira.data.version}</productDataVersion>
                <systemProperties>
                    <property>
                        <name>atlassian.org.osgi.framework.bootdelegation</name>
                        <value>sun.*,com.sun.*</value>
                    </property>
                </systemProperties>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        ...
    </plugins>
</build>
...

. , . Loader.

jaxb-api:

...
<dependencies>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>atlassian-jira</artifactId>
        <version>${jira.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.atlassian.plugins.rest</groupId>
        <artifactId>atlassian-rest-common</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.4</version>
        <scope>provided</scope>
    </dependency>
    ...
</dependencies>
...

jaxb-api. , atlassian-rest-common jaxb-api. . OSGi Manifest ( , , OSGi, ).

OSGi Alliance OSGi Community Wiki.

+6

, .

JIRA (Felix) ClassLoaders. 'bootstrap' ClassLoader. , , .

, ClassLoader JAXBContext, JAXBContext.class.getClassLoader(), Felix ClassLoader.

jaxb-api.jar , rt.jar, , . rt.jar com.sun.xml.bind.internal.v2.ContextFactory jaxb-api com.sun.xml.bind.v2.ContextFactory.

, overlaoded JAXB, ClassLoader.

Quite a lot of time has passed. But I am surprised at the inner details and my ignorance.

+5
source

All Articles