-
1. Re: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
jason.greene Aug 24, 2011 11:40 PM (in response to rareddy)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.
-
2. Re: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
jason.greene Aug 25, 2011 11:54 AM (in response to jason.greene)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.
-
3. Re: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
rareddy Aug 25, 2011 11:43 AM (in response to jason.greene)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.
Thanks.
Ramesh..
-
4. Re: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
anil.saldhana Aug 26, 2011 10:58 AM (in response to rareddy)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.
-
5. Re: Using JAXB and see java.lang.ClassNotFoundException: __redirected/__DatatypeFactory
rareddy Aug 26, 2011 4:31 PM (in response to anil.saldhana)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.
Ramesh..