Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » MOXy/JAXB ClassCastException: attempting to cast bundleresource://.../JAXBContext.class to jar:file:
MOXy/JAXB ClassCastException: attempting to cast bundleresource://.../JAXBContext.class to jar:file: [message #630236] Fri, 01 October 2010 09:34 Go to next message
Eclipse UserFriend
Originally posted by: guen.my-lounge.net

Hi,

the marshaller throws in my equinox osgi environment the following
exception:

Caused by: javax.xml.bind.JAXBException: ClassCastException: attempting
to cast
bundleresource://150.fwk29293232:5/javax/xml/bind/JAXBContex t.class to
jar:file:/C:/Programme/Java/jdk1.6.0_14/jre/lib/rt.jar!/java x/xml/bind/JAXBContext.class.
Please make sure that you are specifying the proper ClassLoader.

The code for marhalling looks like this:

JAXBContext context = JAXBContext.newInstance( someObj.getClass() );
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
marshaller.marshal( someObj, writer );

The "someObj" is JAXB annotated, but sits in a different bundle. The
wired thing is, that I have running JUnit-Plugin test where marschalling
throws no exception. If I run the same code with a OSGi launch config,
the exception occurs!? Where is the difference? - I totally stuck on
this :-(

Thanks for any help!

greetz,
guen




Part of Exception StackTrace:

Caused by: javax.xml.bind.JAXBException: ClassCastException: attempting
to cast
bundleresource://150.fwk29293232:5/javax/xml/bind/JAXBContex t.class to
jar:file:/C:/Programme/Java/jdk1.6.0_14/jre/lib/rt.jar!/java x/xml/bind/JAXBContext.class.
Please make sure that you are specifying the proper ClassLoader.
at
javax.xml.bind.ContextFinder.handleClassCastException(Contex tFinder.java:96)
~[jaxb-api-2.1.jar:na]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java: 205)
~[jaxb-api-2.1.jar:na]
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
~[jaxb-api-2.1.jar:na]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
~[jaxb-api-2.1.jar:na]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
~[jaxb-api-2.1.jar:na]
at
de.goldmind.bizpanel.reporting.core.cdo.manager.ReportManage r.createReportJob(ReportManager.java:56)
~[na:na]
... 59 common frames omitted
Re: MOXy/JAXB ClassCastException: attempting to cast bundleresource://.../JAXBContext.class to jar:f [message #630921 is a reply to message #630236] Tue, 05 October 2010 15:04 Go to previous message
Blaise Doughan is currently offline Blaise DoughanFriend
Messages: 163
Registered: July 2009
Senior Member

Have you included the JAXB API bundle? One is provided in the EclipseLink install at:

<ECLIPSELINK_HOME> /eclipselink/jlib/moxy/javax.xml.bind_2.2.0.v201005080402.ja r

-Blaise
Previous Topic:Problem with bidirectional OneToMany relationship
Next Topic:Compatibility of TABLE_PER_CLASS inheritance strategy with composite keys
Goto Forum:
  


Current Time: Sun Nov 23 07:27:00 GMT 2014

Powered by FUDForum. Page generated in 0.02276 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software