Java Log4J影响JAXB

Java Log4J影响JAXB,java,jaxb,log4j,dependencies,weblogic,Java,Jaxb,Log4j,Dependencies,Weblogic,我正在将SOAP WS应用程序从WL10迁移到WL12。我们对JAXB如何解释这个XML元素有一个问题: <sch:testVar xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> 我们正在使用的JAXB上下文如下所示: [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ RJM-Training-SOAP-WS --- [

我正在将SOAP WS应用程序从WL10迁移到WL12。我们对JAXB如何解释这个XML元素有一个问题:

<sch:testVar xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
我们正在使用的JAXB上下文如下所示:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ RJM-Training-SOAP-WS ---
[INFO] com.mycompany:RJM-Training-SOAP-WS:war:0.0.1-SNAPSHOT
[INFO] +- org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] |  \- org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:3.1.1.RELEASE:compile
[INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile
[INFO] |  \- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile
[INFO] +- org.springframework.ws:spring-ws-core:jar:2.1.2.RELEASE:compile
[INFO] |  +- org.springframework.ws:spring-xml:jar:2.1.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-oxm:jar:3.1.3.RELEASE:compile
[INFO] |  |  \- commons-lang:commons-lang:jar:2.5:compile
[INFO] |  +- org.springframework:spring-webmvc:jar:3.1.3.RELEASE:compile
[INFO] |  \- wsdl4j:wsdl4j:jar:1.6.1:compile
[INFO] \- log4j:log4j:jar:1.2.16:compile
[user@server logs]$ grep JAXBContext WSServer01.log.out 
[Loaded javax.xml.bind.JAXBContext from /opt/weblogic/wl12.1.2.0/wlserver/../oracle_common/modules/endorsed/javax-xml-bind.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$5 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$6 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$3 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$7 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$1 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
[Loaded com.sun.xml.bind.v2.runtime.JAXBContextImpl$2 from file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/com.sun.xml.bind.jaxb-impl_2.2.jar]
我进入代码并记录了使用的JAXB类。这两种情况都是一样的

file:/opt/weblogic/wl12.1.2.0/oracle_common/modules/endorsed/javax-xml-bind.jar!/javax/xml/bind/JAXBContext.class

有人在内部找到了问题的根源。解决方案是更改SpringWS使用的messageFactory实现。我将此bean定义添加到我的项目中:

<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
     <property name="messageFactory">
        <bean class="com.sun.xml.internal.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl"/>
     </property>
</bean>

当log4j1.x被加载时,它正在加载saajapi的更新版本,这导致了nillable的问题。log4j2.x之所以能够工作,是因为它默认使用较旧的SAAJ实现


如果我们指定上面列出的messageFactory,我们可以使用Log4J 1.x。

您能在干净的环境中重现错误,然后转储依赖关系树吗?另外,转储JAXBContext的类名我从Maven构建中添加了依赖关系树。我还添加了JAXBContext信息。JAXBContext JAR(com.sun.xml.bind.jaxb-impl_2.2.jar)在两个版本中是否相同?