骆驼航线使用Spring-WS客户端偶尔会抛出异常javax.xml.transform.stax.StAXSource [英] Camel route using spring-ws client occasionally throws javax.xml.transform.stax.StAXSource exception

查看:142
本文介绍了骆驼航线使用Spring-WS客户端偶尔会抛出异常javax.xml.transform.stax.StAXSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个骆驼SEDA路线包含code大致是:

I have a camel 'seda' route that contains code roughly:

JaxbDataFormat jaxb = new JaxbDataFormat(false);
jaxb.setContextPath("com.example.data.api");

from("seda:validate")
   .marshal(jaxb)
   .to("spring-ws:" + getDataServiceURL())
   .unmarshal(jaxb)

我从com.example.data.api发送对象,JaxbDataFormat格式设置它作为一个SOAP请求,并将它传递WO弹簧WS实际发送到我的服务。这就像一个魅力的大部分时间。

I send an object from com.example.data.api, the JaxbDataFormat formatter sets it up as a SOAP request and passes it along wo spring-ws to actually send to my service. This works like a charm most of the time.

我说最,因为飘飞,弹簧WS抛出像这样的异常:

I say "most" because every now and then, spring-ws throws an exception like so:

org.springframework.ws.client.WebServiceTransformerException: Transformation error: Can't transform a Source of type javax.xml.transform.stax.StAXSource; nested exception is javax.xml.transform.TransformerException: Can't transform a Source of type javax.xml.transform.stax.StAXSource
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:608)
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:537)
    at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:492)
    at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceive(WebServiceTemplate.java:479)
    at org.springframework.ws.client.core.WebServiceTemplate.sendSourceAndReceive(WebServiceTemplate.java:470)
    at org.apache.camel.component.spring.ws.SpringWebserviceProducer.process(SpringWebserviceProducer.java:81)
    at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
    at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:73)

那的核心是此错误消息:无法转换类型javax.xml.transform.stax.StAXSource的源泉

The core of that is this error message: "Can't transform a Source of type javax.xml.transform.stax.StAXSource".

这些都不是有道理的。 JAXB的编组将已经作出了肯定有问题的对象是一个XML字符串(按照任何调试日志我做的)。此外,这个确切的code工作的大部分时间,只是偶尔会失败。这似乎是随机的。

None of that makes sense. The Jaxb marshalling will have already made sure that the object in question is an XML string (according to any debug logging I do). Furthermore, this exact code works most of the time and only occasionally will fail. It appears random.

比如说,我跑测试短短几分钟前,我传话到我的路线和得到这个错误。然后我重新启动我的服务,然后重新发送的确切的同样的信息......和它的工作就像一个魅力。同样的code;同样的环境;同样的测试。 - 两种不同的结果

For instance, I ran a test just a few minutes ago where I sent a message into my route and got this error. I then restarted my service and resend the exact same message... and it worked like a charm. Same code; same environment; same test -- two different results.

这是这个随机性,使这个如此郁闷了。我应该寻找到确保这个的从不的情况?

It's this randomness that makes this so maddening. Any ideas what I should be looking for to making sure this never happens?

推荐答案

这个问题是不是骆驼,但春天-WS。在修改模板WS config中的transformerFactoryClass会工作

The issue is not with Camel but Spring-WS. Modifying the transformerFactoryClass in WS template config would work

<bean id="baseCamelMarshallerWSTemplate" class="org.springframework.ws.client.core.WebServiceTemplate" scope="prototype">
        <constructor-arg ref="messageFactory" />
        <property name="messageSender">
            <ref bean="httpSender"/>
        </property>
        <property name="checkConnectionForError" value="true"/>
        **<property name="transformerFactoryClass" value="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"/>**
    </bean>

如果您仍然面临着问题,请分享春天的WS的配置和测试案例

If you still face the issue, please share spring WS config and a test case

这篇关于骆驼航线使用Spring-WS客户端偶尔会抛出异常javax.xml.transform.stax.StAXSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆