【发布时间】:2019-01-29 15:23:28
【问题描述】:
我有一个需要用作 SOAP 客户端的 Java Spring Web 应用程序。
我正在使用 Maven,我有一个带有自定义代码的主模块 (WAR) 和一个带有 WSDL(我有两个 WSDL)生成的类的子模块(JAR 依赖项)。
正如您在标题中看到的,当我运行应用程序时发生错误
javax.xml.bind.JAXBException: doesn't contain ObjectFactory.class or jaxb.index
这是主模块的ApplicationContext.xml:
<bean id="messageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory"/>
<bean id="webServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<constructor-arg ref="messageFactory"/>
<property name="marshaller" ref="marshaller" />
<property name="unmarshaller" ref="marshaller" />
<property name="interceptors">
<list>
<ref bean="wsSecurityInterceptor" />
</list>
</property>
</bean>
<bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.wss4j2.Wss4jSecurityInterceptor">
<property name="securementActions" value="UsernameToken" />
<property name="securementUsername" value="xxx" />
<property name="securementPassword" value="xxxx" />
<property name="securementPasswordType" value="PasswordText" />
</bean>
<bean id="marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPaths">
<list value-type="java.lang.String">
<value>my.package.path.wsdl</value>
<value>my.package.path.wsdlserver</value>
</list>
</property>
</bean>
在子模块中正确生成了 WSDL 类,并且每个包中都有两个 ObjectFactory.class:
my.package.path.wsdl
my.package.path.wsdlserver
在 Marshaller Bean 期间引发错误:
Error creating bean with name 'marshaller' defined in ServletContext resource
...
javax.xml.bind.JAXBException: "my.package.path.wsdl" doesn't contains ObjectFactory.class or jaxb.index
我找到了几个关于这个问题的线程,但由于 ObjectFactory.class 存在这一事实(由 maven-jaxb2-plugin 自动创建。
提前感谢您的支持,对不起我的英语。
【问题讨论】:
标签: java maven soap jaxb spring-ws