小编use*_*236的帖子

java.lang.ClassCastException:无法转换为javax.xml.bind.JAXBElement

我使用Spring启动来调用web服务.

我的配置类如下:

@Configuration
public class ClientAppConfig {
@Bean
public Jaxb2Marshaller marshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setPackagesToScan("com.client.stub");
    return marshaller;
}

@Bean
public ARTestClient arTestClient(Jaxb2Marshaller marshaller) {
    ARTestClient client = new ARTestClient();
    client.setDefaultUri("uri");
    client.setMarshaller(marshaller);
    client.setUnmarshaller(marshaller);
   return client;
}
Run Code Online (Sandbox Code Playgroud)

我打电话给服务如下:

    OutputMessageType response = (OutputMessageType) getWebServiceTemplate().marshalSendAndReceive(
            inputMessageType, new SoapActionCallback("http://Serviceuri"));
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

   [2016-03-18 14:45:43.697] boot - 10272 ERROR [http-nio-8080-exec-1] --- [dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception 
  [Request processing failed; nested exception is java.lang.ClassCastException: javax.xml.bind.JAXBElement 
  cannot be cast to …
Run Code Online (Sandbox Code Playgroud)

spring jaxb unmarshalling spring-boot

10
推荐指数
2
解决办法
1万
查看次数

Spring JMS 监听器 - 如何根据条件读取消息

我已经在我的项目中配置了Spring JMS。现在我的要求是,仅当属性文件中的标志处于 ON 时才读取消息。

在Spring中有哪些方法可以实现这一点?

spring jms spring-jms

2
推荐指数
1
解决办法
1403
查看次数

标签 统计

spring ×2

jaxb ×1

jms ×1

spring-boot ×1

spring-jms ×1

unmarshalling ×1