weblogic javax/xml/namespace/QName報錯

項目在tomcat已調試好,部署到weblogic後報錯,如下

org.springframework.beans.factory.Bea
nCreationException: Error creating bean with name 'org.apache.cxf.wsdl.WSDLManager' defined in class path resource [META-INF/cxf/cxf.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.apache.cxf.wsdl11.WSDLManagerImpl]: Constructor threw exception; nested exception is java.lang.LinkageError: loader constraint violation: when resolving field "DATETIME" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the referring class, javax/xml/datatype/DatatypeConstants, and the class loader (instance of <bootloader>) for the field's resolved type, javax/xml/namespace/QName, have different Class objects for that type

分析:應該是屬於jar包問題,工程需要設置weblogic.xml優先用web/lib下面的包

<weblogic-web-app>
    <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        </container-descriptor>
  </weblogic-web-app> 

因爲 Apache CXF 裏的類的時間晚於 Weblogic 裏的類的時間,而且類的二進制內容也發生了改變,
於是原來 Weblogic 裏的其它類由於我們通過了 prefer-web-inf-classes 設置爲 true 後,而引用到了現在的 Apache CXF 裏的類了,就發生了 java.lang.LinkageError 錯誤。

解決方式是使用ifind.jar工具把工程下所有帶javax/xml/namespace/QName class的都刪除掉。
ifind.jar工具下載地址: http://pan.baidu.com/s/1dEBCGN3

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章