无法将布尔值添加到 cxf bean 中 JAXBDataBinding 的 contextProperties 映射 xml
Unable to add boolean value to contextProperties map of JAXBDataBinding in cxf beans xml
我正在尝试将 com.sun.xml.bind.treatEverythingNillable 属性 设置为文档中提到的 true。但是是抛出错误。
如何将 com.sun.xml.bind.treatEverythingNillable 设置为 Boolean TRUE 对象?
https://cxf.apache.org/docs/jaxb.html
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- <import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> -->
<jaxws:endpoint
xmlns:tns="http://xmlns.chetan.com/oxp/service/v2"
id="StudentService"
implementor="com.chetan.webservices.cxf.StudentService"
wsdlLocation="WEB-INF/wsdl/StudentService.wsdl"
endpointName="tns:StudentService"
serviceName="tns:StudentService"
address="/v2/StudentService">
<jaxws:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding">
<property name="contextProperties">
<map>
<entry>
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value>true</value>
</entry>
</map>
</property>
</bean>
</jaxws:dataBinding>
</jaxws:endpoint>
<bean id="DocumentBuilderFactory" class="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl">
</bean>
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"/>
<cxf:bus>
<cxf:properties>
<entry key="org.apache.cxf.stax.maxChildElements" value="250000"/>
<entry key="org.apache.cxf.stax.maxElementDepth" value="500"/>
<!--<entry key="org.apache.cxf.stax.maxAttributeCount" value="500/>-->
<!-- <entry key="org.apache.cxf.stax.maxAttributeSize" value="65536"/>-->
<entry key="org.apache.cxf.stax.maxTextLength" value="1073741824"/>
</cxf:properties>
</cxf:bus>
</beans>
错误
Caused by: javax.xml.bind.JAXBException: true is not a valid value for property "com.sun.xml.bind.treatEverythingNillable"
at com.sun.xml.bind.v2.ContextFactory.getPropertyValue(ContextFactory.java:177)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at org.apache.cxf.common.jaxb.JAXBContextCache.run(JAXBContextCache.java:345)
at org.apache.cxf.common.jaxb.JAXBContextCache.run(JAXBContextCache.java:343)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:343)
at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:245)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:496)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355)
... 44 more
Windows10+JDK8+Tomcat8.75+JAXB 3.3.10
复制/粘贴工单中的答案 (https://issues.apache.org/jira/browse/CXF-8656)。问题是您使用字符串值“true”初始化此 属性,而不是 属性 期望的布尔值 true
:
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value>true</value>
请使用:
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value type="java.lang.Boolean">true</value>
我正在尝试将 com.sun.xml.bind.treatEverythingNillable 属性 设置为文档中提到的 true。但是是抛出错误。
如何将 com.sun.xml.bind.treatEverythingNillable 设置为 Boolean TRUE 对象?
https://cxf.apache.org/docs/jaxb.html
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- <import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> -->
<jaxws:endpoint
xmlns:tns="http://xmlns.chetan.com/oxp/service/v2"
id="StudentService"
implementor="com.chetan.webservices.cxf.StudentService"
wsdlLocation="WEB-INF/wsdl/StudentService.wsdl"
endpointName="tns:StudentService"
serviceName="tns:StudentService"
address="/v2/StudentService">
<jaxws:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding">
<property name="contextProperties">
<map>
<entry>
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value>true</value>
</entry>
</map>
</property>
</bean>
</jaxws:dataBinding>
</jaxws:endpoint>
<bean id="DocumentBuilderFactory" class="com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl">
</bean>
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus"/>
<cxf:bus>
<cxf:properties>
<entry key="org.apache.cxf.stax.maxChildElements" value="250000"/>
<entry key="org.apache.cxf.stax.maxElementDepth" value="500"/>
<!--<entry key="org.apache.cxf.stax.maxAttributeCount" value="500/>-->
<!-- <entry key="org.apache.cxf.stax.maxAttributeSize" value="65536"/>-->
<entry key="org.apache.cxf.stax.maxTextLength" value="1073741824"/>
</cxf:properties>
</cxf:bus>
</beans>
错误
Caused by: javax.xml.bind.JAXBException: true is not a valid value for property "com.sun.xml.bind.treatEverythingNillable"
at com.sun.xml.bind.v2.ContextFactory.getPropertyValue(ContextFactory.java:177)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
at org.apache.cxf.common.jaxb.JAXBContextCache.run(JAXBContextCache.java:345)
at org.apache.cxf.common.jaxb.JAXBContextCache.run(JAXBContextCache.java:343)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.common.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:343)
at org.apache.cxf.common.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:245)
at org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:496)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:355)
... 44 more
Windows10+JDK8+Tomcat8.75+JAXB 3.3.10
复制/粘贴工单中的答案 (https://issues.apache.org/jira/browse/CXF-8656)。问题是您使用字符串值“true”初始化此 属性,而不是 属性 期望的布尔值 true
:
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value>true</value>
请使用:
<key><value>com.sun.xml.bind.treatEverythingNillable</value></key>
<value type="java.lang.Boolean">true</value>