【发布时间】:2015-02-03 18:00:58
【问题描述】:
我正在使用 WebSphere Liberty Profile 服务器,版本 8.5.5.3。我的耳朵包含了多次战争。我部署它们都爆炸了(耳朵和里面的模块的战争也是如此)。
在部署它时,我得到以下类转换异常:
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.
我认为问题在于我捆绑的jax-api 和jaxb-impl jar 没有加载,所以我在server.xml 中添加了parentLast 类加载选项:
<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>
我已将我的 jax-api 和 jax-impl jar 添加到此文件夹中
<library id="shared-libs">
<fileset dir="${server.config.dir}/lib/global" include="*.jar"/>
</library>
但是我仍然有ClassCastException,看起来它仍在使用parentFirst 类加载?
我发现了其他 jaxb ClassCastException 线程,但在使用 Liberty 配置文件时没有。
【问题讨论】:
-
您是否尝试从应用程序中删除这些 jar 以仅加载服务器类?
-
不,我没有尝试过,因为我们需要更新的库版本,而不是 WebSphere 提供的那些。
-
Liberty 拥有
jaxb-2.2。你需要哪一个?还有您在server.xml中启用了哪些功能? -
好吧,我以为 Liberty 是旧的。我将删除 server.xml 中的 parentLast。我启用了以下功能:
servlet-3.0 wasJmsServer-1.0 wasJmsClient-1.1 jndi-1.0 jdbc-4.0
标签: jaxb websphere classcastexception websphere-liberty