这几日把webservice部署到WebLogic上,问题重重啊,搞了2日啊,头都大了,各种冲突。
第一个问题:org.apache.cxf.binding.soap.SoapFault: Cannot create a secure XMLInputFactory
在WEB-INF文件夹下,加上weblogic.xml
<?xml version="1.0" encoding="UTF-8" ?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-web-app http://www.bea.com/ns/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<container-descriptor>
<index-directory-enabled>true</index-directory-enabled>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
第二个问题: java.lang.ClassCastException: weblogic.xml.jaxp.RegistryDocumentBuilderFactory at javax.xml.parsers.DocumentBuilderFactory
jar包冲突导致,网上的资料大都说是xml-apis 冲突,从war包里删除掉xml-apis,这个网址上也说的很清楚
我用的是maven管理jar包,上网找了下,http://stackoverflow.com/questions/4925901/classcastexception-while-parsing-xml-with-weblogic
因为使用的是公司的框架,刚好公司框架中依赖了这个xml-apis
<dependency>
<groupId>***</groupId>
<artifactId>***</artifactId>
<version>1.0.1</version>
<exclusions>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>
第二个问题:
java.lang.LinkageError: loader constraint violation: loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader)
previously initiated loading for a different type with name "javax/xml/namespace/QName"
也是jar包与WebLogic冲突,这次冲突的是stax的 stax-api,
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
第三个问题:
java.lang.LinkageError: loader constraint violation:
when resolving overridden method "com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Ljavax/xml/stream/XMLStreamReader;Ljava/lang/Class;)Ljavax/xml/bind/JAXBElement;" the class loader (
instance of weblogic/utils/classloaders/ChangeAwareClassLoader) of the current class,
com/sun/xml/bind/v2/runtime/unmarshaller/UnmarshallerImpl, and its superclass loader (instance of <bootloader>),
have different Class objects for the type allerImpl.unmarshal(Ljavax/xml/stream/XMLStreamReader;Ljava/lang/Class;)Ljavax/xml/bind/JAXBElement;
used in the signature
依旧还是jar包冲突,这次是 javax.xml.stream的stax-api
<exclusion>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
总体上来说,使用mvn查看依赖树,mvn dependency:tree,查看依赖去除冲突jar包。