You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cgveld <j....@avisi.nl> on 2009/06/05 14:57:04 UTC
Exception on typeconversion, but result is ok?
Hi,
I recently started using Camel. It seems to be very powerful and useful, but
also sometimes a bit complex.
Anyway... Most things work great, but I do have a question.
I get an Exception when I try to read a Document from a JmsMessage.
I'll first try to explain what I am doing:
1. I get a message on an activemq queue
2. I take the id from this message and put a xml file on the 'IN'
(this happens in a processor)
exchange.getIn().setBody(new File(filename));
3. I process the message, this processor tries to read the message as a
document
Document document = exchange.getIn().getBody(Document.class);
This is where the following errors occur:
org.apache.camel.NoTypeConversionAvailableException: No type converter
available to convert from type: class
org.apache.camel.component.jms.JmsMessage to the required type:
java.io.InputStream with value JmsMessage: ActiveMQTextMessage
4. I evaluate an xpath expression on the document
5. I remove the result from the expression from the document
6. I put the document on the IN of the exchange again.
Strangely enough it seems the xpath expression can be evaluated and even the
nodes are deleted from the document. Although I got an exception reading the
document?
How is this possible? And even more important, how can I solve this?
Can anybody help me?
Thanks,
Jeroen
P.S. I noticed there are no converters from JmsMessage to anything in the
list so I could understand if my code wouldn't work at all. But it seems to
work fine, except for the exception.
--
View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p23887671.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Exception on typeconversion, but result is ok?
Posted by cgveld <j....@avisi.nl>.
Hi,
A colleague of mine found the problem. It seemed the problem wasn't in this
piece of code indeed.
The next piece of the total route picked up this exchange and caused the
problem.
In there, the xml was read from an InputStream. Since I put a Document on
the exchange, this didn't work anymore.
Object result = expr.evaluate(new
InputSource(exchange.getIn().getBody(InputStream.class)),
XPathConstants.NODESET);
My colleague changed this into:
Document document = exchange.getIn().getBody(Document.class);
Object result = expr.evaluate(document, XPathConstants.NODESET);
This solved everything.
Thanks for your support.
With kind regards,
Jeroen Veldhorst
--
View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p24032214.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Exception on typeconversion, but result is ok?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Ups the link was wrong. Here it is
http://svn.apache.org/viewvc?view=rev&revision=782887
On Tue, Jun 9, 2009 at 8:02 AM, Claus Ibsen<cl...@gmail.com> wrote:
> Hi
>
> I have re produced an unit test that is a bit similar to yours.
> I cannot get the type converter issue.
>
> I am using Camel 1.6.1.
>
> See the code here
> http://svn.apache.org/viewvc?view=rev
>
> I suggest that you check that the file really exists. That could be the issue.
> You can use the file.exist() to check if there is a file.
>
>
> On Mon, Jun 8, 2009 at 10:04 AM, cgveld<j....@avisi.nl> wrote:
>>
>> Hi,
>>
>> Thanks for your amazingly quick reply. :)
>>
>> Here is the part of the route what it is all about:
>> from("activemq:out." + getPortalId())
>> // Because the xml fragment does not contain the usual <?xml version...
>> etc.
>> // we have to force the encoding on the input read from the queue.
>> .setProperty(Exchange.CHARSET_NAME, constant("UTF-8"))
>>
>> .setHeader(AGENT_ID, new XPathExpression("/agent/@id"))
>>
>> .process(new FixateHeaderValuesProcessor())
>>
>> // reading objects per agent
>> .setHeader(FileComponent.HEADER_FILE_NAME, new
>> SimpleExpression(getCacheLocation() + "/${in.header." + AGENT_ID +
>> "}/agent.xml"))
>> .process(new ReadLocalFile())
>>
>> .to("direct:filterxml")
>>
>> .setHeader("portal.id", constant(getPortalId()))
>>
>> .multicast()
>> .to("direct:portalxml", "direct:historyxml")
>> ;
>>
>> from("direct:filterxml")
>> .process(new FilterProcessor())
>> ;
>>
>> from("direct:portalxml")
>> .to("xslt:" + getPortalXsltUri())
>> .setHeader(FileComponent.HEADER_FILE_NAME, new
>> SimpleExpression("${in.header." + AGENT_ID + "}/agent.xml"))
>> .to("file://" + getPublishLocation() + "/" + getPortalId() +
>> "?append=false")
>> ;
>>
>> from("direct:historyxml")
>> .to("xslt:" + getHistoryXsltUri())
>> .setHeader(FileComponent.HEADER_FILE_NAME, new
>> SimpleExpression("${in.header." + AGENT_ID + "}/history.xml"))
>> .to("file://" + getPublishLocation() + "/" + getPortalId() +
>> "?append=false")
>> ;
>>
>> And here are the custom processors:
>> /**
>> * type convert a few headers to string, otherwise they will not survive
>> hops to jms ques.
>> */
>> private class FixateHeaderValuesProcessor implements Processor {
>>
>> public void process(Exchange arg0) throws Exception {
>> String id = arg0.getIn().getHeader(AGENT_ID, String.class);
>> arg0.getIn().setHeader(AGENT_ID, id);
>> }
>> }
>>
>> /*
>> *
>> */
>> private class ReadLocalFile implements Processor {
>>
>> public void process(Exchange exchange) throws Exception {
>> // get the filename from our custom header
>> String filename =
>> exchange.getIn().getHeader(FileComponent.HEADER_FILE_NAME, String.class);
>> exchange.getIn().setBody(new File(filename));
>> }
>> }
>>
>> /*
>> * Remove objects from xml by xpath queries
>> */
>> private class FilterProcessor implements Processor {
>>
>> public void process(Exchange exchange) throws Exception {
>> String portalId = getPortalId();
>>
>> XPathFactory factory = XPathFactory.newInstance();
>> XPath xpath = factory.newXPath();
>>
>> List<String> expressions = new ArrayList<String>();
>> expressions.add("//object[count(.//portal[@id=" + portalId + "]) =
>> 0]");
>> expressions.add("//object[(.//action != 'DELETE') and
>> (language!='de')]");
>> expressions.add("//object[(.//action != 'DELETE') and
>> (string-length(postalcode) <= 0)]");
>> expressions.add("//object[(.//action != 'DELETE') and
>> (string-length(cityname) <= 0)]");
>>
>> Document document = exchange.getIn().getBody(Document.class);
>>
>> for (String expr : expressions) {
>>
>> NodeList nodes = (NodeList) xpath.compile(expr).evaluate(document,
>> XPathConstants.NODESET);
>>
>> for (int i = 0; i < nodes.getLength(); i++) {
>> Node node = nodes.item(i);
>> node.getParentNode().removeChild(node);
>> }
>> }
>>
>> exchange.getIn().setBody(document);
>> }
>> }
>>
>> I tried your solution with the default message. This gave me another
>> exception:
>> WARN efaultMessageListenerContainer - Execution of JMS message listener
>> failed
>> org.apache.camel.RuntimeCamelException: java.lang.ClassCastException:
>> org.apache.camel.impl.DefaultMessage
>> at
>> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:842)
>> at
>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:95)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
>> at
>> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
>> at
>> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
>> at
>> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:875)
>> at java.lang.Thread.run(Thread.java:613)
>> Caused by: java.lang.ClassCastException:
>> org.apache.camel.impl.DefaultMessage
>> at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:52)
>> at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:32)
>> at
>> org.apache.camel.processor.Pipeline.createNextExchange(Pipeline.java:185)
>> at org.apache.camel.processor.Pipeline.process(Pipeline.java:86)
>> at
>> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
>> at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
>> at
>> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
>> at
>> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
>> at
>> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
>> at
>> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
>> at
>> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:72)
>> ... 8 more
>>
>>
>> --
>> View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p23919884.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
>
>
> --
> Claus Ibsen
> Apache Camel Committer
>
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> Twitter: http://twitter.com/davsclaus
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Exception on typeconversion, but result is ok?
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I have re produced an unit test that is a bit similar to yours.
I cannot get the type converter issue.
I am using Camel 1.6.1.
See the code here
http://svn.apache.org/viewvc?view=rev
I suggest that you check that the file really exists. That could be the issue.
You can use the file.exist() to check if there is a file.
On Mon, Jun 8, 2009 at 10:04 AM, cgveld<j....@avisi.nl> wrote:
>
> Hi,
>
> Thanks for your amazingly quick reply. :)
>
> Here is the part of the route what it is all about:
> from("activemq:out." + getPortalId())
> // Because the xml fragment does not contain the usual <?xml version...
> etc.
> // we have to force the encoding on the input read from the queue.
> .setProperty(Exchange.CHARSET_NAME, constant("UTF-8"))
>
> .setHeader(AGENT_ID, new XPathExpression("/agent/@id"))
>
> .process(new FixateHeaderValuesProcessor())
>
> // reading objects per agent
> .setHeader(FileComponent.HEADER_FILE_NAME, new
> SimpleExpression(getCacheLocation() + "/${in.header." + AGENT_ID +
> "}/agent.xml"))
> .process(new ReadLocalFile())
>
> .to("direct:filterxml")
>
> .setHeader("portal.id", constant(getPortalId()))
>
> .multicast()
> .to("direct:portalxml", "direct:historyxml")
> ;
>
> from("direct:filterxml")
> .process(new FilterProcessor())
> ;
>
> from("direct:portalxml")
> .to("xslt:" + getPortalXsltUri())
> .setHeader(FileComponent.HEADER_FILE_NAME, new
> SimpleExpression("${in.header." + AGENT_ID + "}/agent.xml"))
> .to("file://" + getPublishLocation() + "/" + getPortalId() +
> "?append=false")
> ;
>
> from("direct:historyxml")
> .to("xslt:" + getHistoryXsltUri())
> .setHeader(FileComponent.HEADER_FILE_NAME, new
> SimpleExpression("${in.header." + AGENT_ID + "}/history.xml"))
> .to("file://" + getPublishLocation() + "/" + getPortalId() +
> "?append=false")
> ;
>
> And here are the custom processors:
> /**
> * type convert a few headers to string, otherwise they will not survive
> hops to jms ques.
> */
> private class FixateHeaderValuesProcessor implements Processor {
>
> public void process(Exchange arg0) throws Exception {
> String id = arg0.getIn().getHeader(AGENT_ID, String.class);
> arg0.getIn().setHeader(AGENT_ID, id);
> }
> }
>
> /*
> *
> */
> private class ReadLocalFile implements Processor {
>
> public void process(Exchange exchange) throws Exception {
> // get the filename from our custom header
> String filename =
> exchange.getIn().getHeader(FileComponent.HEADER_FILE_NAME, String.class);
> exchange.getIn().setBody(new File(filename));
> }
> }
>
> /*
> * Remove objects from xml by xpath queries
> */
> private class FilterProcessor implements Processor {
>
> public void process(Exchange exchange) throws Exception {
> String portalId = getPortalId();
>
> XPathFactory factory = XPathFactory.newInstance();
> XPath xpath = factory.newXPath();
>
> List<String> expressions = new ArrayList<String>();
> expressions.add("//object[count(.//portal[@id=" + portalId + "]) =
> 0]");
> expressions.add("//object[(.//action != 'DELETE') and
> (language!='de')]");
> expressions.add("//object[(.//action != 'DELETE') and
> (string-length(postalcode) <= 0)]");
> expressions.add("//object[(.//action != 'DELETE') and
> (string-length(cityname) <= 0)]");
>
> Document document = exchange.getIn().getBody(Document.class);
>
> for (String expr : expressions) {
>
> NodeList nodes = (NodeList) xpath.compile(expr).evaluate(document,
> XPathConstants.NODESET);
>
> for (int i = 0; i < nodes.getLength(); i++) {
> Node node = nodes.item(i);
> node.getParentNode().removeChild(node);
> }
> }
>
> exchange.getIn().setBody(document);
> }
> }
>
> I tried your solution with the default message. This gave me another
> exception:
> WARN efaultMessageListenerContainer - Execution of JMS message listener
> failed
> org.apache.camel.RuntimeCamelException: java.lang.ClassCastException:
> org.apache.camel.impl.DefaultMessage
> at
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:842)
> at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:95)
> at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
> at
> org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
> at
> org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
> at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
> at
> org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
> at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
> at
> org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:875)
> at java.lang.Thread.run(Thread.java:613)
> Caused by: java.lang.ClassCastException:
> org.apache.camel.impl.DefaultMessage
> at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:52)
> at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:32)
> at
> org.apache.camel.processor.Pipeline.createNextExchange(Pipeline.java:185)
> at org.apache.camel.processor.Pipeline.process(Pipeline.java:86)
> at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
> at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
> at
> org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
> at
> org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
> at
> org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
> at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
> at
> org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:72)
> ... 8 more
>
>
> --
> View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p23919884.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Exception on typeconversion, but result is ok?
Posted by cgveld <j....@avisi.nl>.
Hi,
Thanks for your amazingly quick reply. :)
Here is the part of the route what it is all about:
from("activemq:out." + getPortalId())
// Because the xml fragment does not contain the usual <?xml version...
etc.
// we have to force the encoding on the input read from the queue.
.setProperty(Exchange.CHARSET_NAME, constant("UTF-8"))
.setHeader(AGENT_ID, new XPathExpression("/agent/@id"))
.process(new FixateHeaderValuesProcessor())
// reading objects per agent
.setHeader(FileComponent.HEADER_FILE_NAME, new
SimpleExpression(getCacheLocation() + "/${in.header." + AGENT_ID +
"}/agent.xml"))
.process(new ReadLocalFile())
.to("direct:filterxml")
.setHeader("portal.id", constant(getPortalId()))
.multicast()
.to("direct:portalxml", "direct:historyxml")
;
from("direct:filterxml")
.process(new FilterProcessor())
;
from("direct:portalxml")
.to("xslt:" + getPortalXsltUri())
.setHeader(FileComponent.HEADER_FILE_NAME, new
SimpleExpression("${in.header." + AGENT_ID + "}/agent.xml"))
.to("file://" + getPublishLocation() + "/" + getPortalId() +
"?append=false")
;
from("direct:historyxml")
.to("xslt:" + getHistoryXsltUri())
.setHeader(FileComponent.HEADER_FILE_NAME, new
SimpleExpression("${in.header." + AGENT_ID + "}/history.xml"))
.to("file://" + getPublishLocation() + "/" + getPortalId() +
"?append=false")
;
And here are the custom processors:
/**
* type convert a few headers to string, otherwise they will not survive
hops to jms ques.
*/
private class FixateHeaderValuesProcessor implements Processor {
public void process(Exchange arg0) throws Exception {
String id = arg0.getIn().getHeader(AGENT_ID, String.class);
arg0.getIn().setHeader(AGENT_ID, id);
}
}
/*
*
*/
private class ReadLocalFile implements Processor {
public void process(Exchange exchange) throws Exception {
// get the filename from our custom header
String filename =
exchange.getIn().getHeader(FileComponent.HEADER_FILE_NAME, String.class);
exchange.getIn().setBody(new File(filename));
}
}
/*
* Remove objects from xml by xpath queries
*/
private class FilterProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String portalId = getPortalId();
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
List<String> expressions = new ArrayList<String>();
expressions.add("//object[count(.//portal[@id=" + portalId + "]) =
0]");
expressions.add("//object[(.//action != 'DELETE') and
(language!='de')]");
expressions.add("//object[(.//action != 'DELETE') and
(string-length(postalcode) <= 0)]");
expressions.add("//object[(.//action != 'DELETE') and
(string-length(cityname) <= 0)]");
Document document = exchange.getIn().getBody(Document.class);
for (String expr : expressions) {
NodeList nodes = (NodeList) xpath.compile(expr).evaluate(document,
XPathConstants.NODESET);
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
node.getParentNode().removeChild(node);
}
}
exchange.getIn().setBody(document);
}
}
I tried your solution with the default message. This gave me another
exception:
WARN efaultMessageListenerContainer - Execution of JMS message listener
failed
org.apache.camel.RuntimeCamelException: java.lang.ClassCastException:
org.apache.camel.impl.DefaultMessage
at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:842)
at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:95)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:531)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:466)
at
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:435)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:322)
at
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:260)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:944)
at
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:875)
at java.lang.Thread.run(Thread.java:613)
Caused by: java.lang.ClassCastException:
org.apache.camel.impl.DefaultMessage
at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:52)
at org.apache.camel.component.jms.JmsExchange.getIn(JmsExchange.java:32)
at
org.apache.camel.processor.Pipeline.createNextExchange(Pipeline.java:185)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:86)
at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:68)
at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.proceed(StreamCachingInterceptor.java:87)
at
org.apache.camel.processor.interceptor.StreamCachingInterceptor.process(StreamCachingInterceptor.java:82)
at
org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:52)
at
org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:41)
at
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:66)
at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:72)
... 8 more
--
View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p23919884.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Exception on typeconversion, but result is ok?
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 5, 2009 at 2:57 PM, cgveld<j....@avisi.nl> wrote:
>
> Hi,
>
> I recently started using Camel. It seems to be very powerful and useful, but
> also sometimes a bit complex.
> Anyway... Most things work great, but I do have a question.
> I get an Exception when I try to read a Document from a JmsMessage.
>
> I'll first try to explain what I am doing:
> 1. I get a message on an activemq queue
> 2. I take the id from this message and put a xml file on the 'IN'
> (this happens in a processor)
> exchange.getIn().setBody(new File(filename));
> 3. I process the message, this processor tries to read the message as a
> document
> Document document = exchange.getIn().getBody(Document.class);
>
> This is where the following errors occur:
> org.apache.camel.NoTypeConversionAvailableException: No type converter
> available to convert from type: class
> org.apache.camel.component.jms.JmsMessage to the required type:
> java.io.InputStream with value JmsMessage: ActiveMQTextMessage
>
> 4. I evaluate an xpath expression on the document
> 5. I remove the result from the expression from the document
> 6. I put the document on the IN of the exchange again.
>
> Strangely enough it seems the xpath expression can be evaluated and even the
> nodes are deleted from the document. Although I got an exception reading the
> document?
> How is this possible? And even more important, how can I solve this?
>
> Can anybody help me?
Hi
Welcome on board the Camel ride.
Can you post the route and what version of Camel you are using.
It would help understand what you do.
The problem could be the fact that you kinda wreck the JmsMessage as
you replace it with a File body.
So you should probably replace the entire Message with a neutral
message that is not JMS specific.
Message msg = new DefaultMessage();
msg.setBody(new File...)
// replace with our neutral message
exchange.setIn(msg);
>
> Thanks,
>
> Jeroen
>
> P.S. I noticed there are no converters from JmsMessage to anything in the
> list so I could understand if my code wouldn't work at all. But it seems to
> work fine, except for the exception.
> --
> View this message in context: http://www.nabble.com/Exception-on-typeconversion%2C-but-result-is-ok--tp23887671p23887671.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
--
Claus Ibsen
Apache Camel Committer
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus