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
Finally I was able find out the reason.
There are many ClassLoaders involved while loading the plugins in JIRA (Felix). which will not delegate to 'bootstrap' ClassLoader. And hence the problem.
To know which ClassLoader loaded the JAXBContext class, use JAXBContext.class.getClassLoader() which will print some Felix ClassLoader.
It loaded the class from jaxb-api.jar instead of relying on rt.jar but they implemented the classes slightly different. rt.jar version uses
com.sun.xml.bind.internal.v2.ContextFactory where jaxb-api version uses com.sun.xml.bind.v2.ContextFactory.
I am able to solve the issue using overlaoded method of JAXB which will take another parameter as ClassLoader.
It took quite some time. But, I am surprised by the inner details & my ignorance