Reputation: 21
I am using the WebSphere Liberty Profile server, version 8.5.5.3. I have an ear containing multiple wars. I deploy them all exploded (ear and the war's of the modules inside it as well).
When deploying it I get the following class cast exception:
java.lang.RuntimeException: javax.xml.bind.JAXBException:
ClassCastException: attempting to cast bundleresource://67.fwk-1166858817/javax/xml/bind/JAXBContext.class
to jar:file:/C:/ws/IBM/java_1.7_64/jre/lib/rt.jar!/javax/xml/bind/JAXBContext.class.
Please make sure that you are specifying the proper ClassLoader.
I figured that the problem is that my bundled jax-api
and jaxb-impl
jars are not loaded, so I added to the server.xml
the parentLast
class loading option:
<enterpriseApplication id="ear-app" location="C:/ws/ear/exploded/ear-app.ear" name="ear-app" >
<classloader delegation="parentLast" commonLibraryRef="provided-jars" privateLibraryRef="shared-libs"/>
</enterpriseApplication>
I added my jax-api
and jax-impl
jars to this folder
<library id="shared-libs">
<fileset dir="${server.config.dir}/lib/global" include="*.jar"/>
</library>
However I still have the ClassCastException
, it looks like it is still using the parentFirst
classloading?
I found other jaxb ClassCastException threads, but not when using the Liberty profile..
Upvotes: 1
Views: 2278
Reputation: 21
I worked aroud the problem by not using the parentLast. Thanks for the help.
Upvotes: 0
Reputation: 18030
Maybe it is a typo, but in your post you have delegation="parentFirst"
instead of parentLast
.
Did you check to just change delegation for application like this:
<enterpriseApplication id="ear-app" location="C:/ws/ear/exploded/ear-app.ear" name="ear-app" >
<classloader delegation="parentLast"/>
</enterpriseApplication>
For more details see Overriding a provided API with an alternative version
Upvotes: 1