第二次被CXF+Oracle Weblogic11g 折磨

Tomcat上调试好的程序发布到weblogic上,又碰到jar包问题.

[b]问题现象1[/b]

Invocation of init method failed; 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

分析:工程之前已经设置weblogic.xml优先用web/lib下面的包

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

"javax/xml/namespace/QName"无法识别这个错误[url=http://tobato.iteye.com/blog/1483020]之前已经碰到过,[/url]因为 Apache CXF 里的类的时间晚于 Weblogic 里的类的时间,而且类的二进制内容也发生了改变,
于是原来 Weblogic 里的其它类由于我们通过了 prefer-web-inf-classes 设置为 true 后,而引用到了现在的 Apache CXF 里的类了,就发生了 java.lang.LinkageError 错误。

解决方式是把工程下所有带javax/xml/namespace/QName class的都删除掉。

[b]问题现象2.[/b]

Caused by: javax.xml.bind.JAXBException
- with linked exception:
[com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces.
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements
at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointRefer
ence.referenceProperties
at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
org.w3c.dom.Element does not have a no-arg default constructor.
this problem is related to the following location:
at org.w3c.dom.Element
at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements
at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointRefer
ence.referenceProperties
at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:217)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)

解决Qname继续启动,出现这个错误。分析原因还是Jar包问题,从com.sun.xml.ws分析可以看出来启动的时候还是没有使用CXF的包路径.

总结问题1和问题2,我们的目的就是要使用自己的包路径,如果冲突的包不多,将jar包加载到weblogic setDomainEnv里面是最简单的.
比如设置
set PRE_CLASSPATH=C:\temp\webroot\WEB-INF\lib\antlr-xxx.jar;


对于需要修正的类路径可以通过下面的方法进行设置,而不是只用" prefer-web-inf-classes=true" 这个锤子去敲所有的钉子。


<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<!--提示即使weblogic即使有这个包也要优先使用下面路径的内容-->
<prefer-application-resources>
<resource-name>META-INF/services/javax.xml.ws.spi.Provider</resource-name>
</prefer-application-resources>
<prefer-application-packages>
<package-name>org.python.core.*</package-name>
</prefer-application-packages>
</container-descriptor>
</weblogic-web-app>


折腾几个小时,服务启动了,天下太平了。。

新问题

Caused by: java.lang.NoSuchMethodError: org.joda.time.DateTime.<init>(IIIII)V


显然也是jar包找不到了,将org.joda.time.*加入

<prefer-application-packages>
<package-name>org.python.core.*</package-name>
<package-name>org.joda.time.*</package-name>
</prefer-application-packages>

搞定!
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值