I am writing a plugin for Jira which involves parsing of XML documents. I am using JAXB to do so (XML to pojos and vice versa)
So have a class which 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();
}
}
The mentioned packages will come with JDK distribution (rt.jar). so i haven’t relayed on anything else to run the class.
when i launch it from command line using ‘java’ it’s working properly. but, when i package
it as a jar and put it as plugin in Jira it’s failing with 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)
This is on the same machine. only difference i could see is unlike launching from command line, when i deployed it in Jira, it’s not calling the main() but m1() by instantiating.
I am wondering what is happening ! it’s on the same machine. i do not know how Jira launches the application (as i am launching from command line).
The
com.sun.xml.bindpackage is part of the JAXB RI (http://jaxb.dev.java.net/), so you probably have that on your classpath somewhere.Java6 has it’s own version of JAXB included, in the
com.sun.xml.internal.bindpackage, so you don’t usually need the RI in Java6 .The RI can made made to work with Java6 , but it’s uphill battle, and usually ends up with this sort of problem.