The error is misleading due to a JAXP bug in some factories. The solution is to ensure that you have your threads current context class loader set to the calling modules class loader and that that module have a service import on the com.sun jaxb impl module.
My above answer is not entirely accurate. The TCCL needs to point to any module classloader (all of them can see __redirected). In some cases TCCL might be null, in which case, due to a JAXP bug, the boot classpath is used and __redirected is not seen. Before calling into any JAXP factory (any newInstance()) just make sure you set TCCL to point to your module classloader (and reset it back to the original in finally block)
One important clarification point though is that if this is an EE deployment executing in an EE context (like say servlet init), then it has TCCL set to the deployment (which is correct). If you are taking an action on behalf of the user (e.g. it is expected that THEIR JAXP impls be used), then you can safely reuse this. If however it is an implementation detail of your subsystem, then you want your versions to be used and not theirs.
Thanks for reply Jason.
Yes, this was not an EE deployment, but is Teiid specific deployment I was trying to use it for. once I set the TCCL it went beyond the CNFE exceptions.
However for some strange reason, a perfectly working JAXB class for marshelling & un-marshelling, now ignores the @XmlAccessorType, @XmlTransient and want to marshall all the methods even though they do not have JAXB annotations on and fails. Still needs to figure out what is the difference the environement contributing to this.
If it just 2-3 jaxb classes, Ramesh, a suggestion would be to get to Stax parsing and writing. Will save you all the trouble of using JAXB.
Yep, after looking around for half an hour not finding a solution, I spent another hour writing Stax parser. Now that works great!
Thanks all the answerers.