【问题标题】:WebSphere Liberty profile JAXBContext ClassCastExceptionWebSphere Liberty 配置文件 JAXBContext ClassCastException
【发布时间】: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-apijaxb-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-apijax-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.0wasJmsServer-1.0wasJmsClient-1.1jndi-1.0 jdbc-4.0

标签: jaxb websphere classcastexception websphere-liberty


【解决方案1】:

我通过不使用 parentLast 解决了这个问题。谢谢您的帮助。

【讨论】:

    【解决方案2】:

    也许这是一个错字,但在你的帖子中你有delegation="parentFirst"而不是parentLast

    您是否检查过只是像这样更改应用程序的委派:

    <enterpriseApplication id="ear-app" location="C:/ws/ear/exploded/ear-app.ear" name="ear-app" >
        <classloader delegation="parentLast"/>
    </enterpriseApplication> 
    

    更多详情见Overriding a provided API with an alternative version

    【讨论】:

    • 哦,是的,这是一个错字,我使用了 parentLast
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多