You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tapdur <ta...@gmail.com> on 2010/02/11 12:06:41 UTC

in.getBody() Bug ???

Hi community

in the process method, i want to get a body of type wich is generated by
xjc, how to pass to the getBody() the jaxb option ignoreJAXBElement="false"
(used in the unmarshall) ?

this line fail (within the correct object in the echange.in.value
attribute):  GreetingRequestType user = (GreetingRequestType)
exchange.getIn().getBody(GreetingRequestType.class);

is it a bug or is there any workaround ?

Thx
Bruno




-- 
View this message in context: http://old.nabble.com/in.getBody%28%29-Bug-----tp27544321p27544321.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: in.getBody() Bug ???

Posted by Tapdur <ta...@gmail.com>.
thx

it works !

in fact, the errors are due to the xsd delcaration and jaxb side (not camel
side). it works well with XmlRootElement but not with complex type ;-)

thx for all now i can go forward with lovely camel

Bruno

willem.jiang wrote:
> 
> Hi,
> 
> I think you need to let the jaxb unmarshal the xml without wrapping with 
> JAXBElement, just like this
> 
> <jaxb ignoreJAXBElement="ture" prettyPrint="true"
> contextPath="poc.camel.echange" />
> 
> 
> Willem
> 
> Tapdur wrote:
>> no exception just return null object
>> 
>> 2010-02-11 15:19:04,197 : Logger.process :
>> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
>> from(http://127.0.0.1:9090/greeting) -->  <<< Pattern:InOut,
>> Headers:{org.restlet.http.version=HTTP/1.0,
>> CamelHttpUri=http://127.0.0.1:9090/greeting,
>> org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
>> User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
>> Content-Length: 57], CamelHttpMethod=POST,
>> org.restlet.startTime=1265897944026}, BodyType:String,
>> Body:<GreetingRequest>
>>        <name>Tapdur</name>
>> </GreetingRequest>
>> 
>> 2010-02-11 15:19:04,369 : Logger.process :
>> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)  -->
>> log://poc.camel.greeting?level=DEBUG <<< Pattern:InOut,
>> Headers:{org.restlet.http.headers=[Accept: xml/application, Content-Type:
>> ,
>> User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
>> Content-Length: 57], CamelHttpUri=http://127.0.0.1:9090/greeting,
>> org.restlet.startTime=1265897944026, org.restlet.http.version=HTTP/1.0,
>> CamelHttpMethod=POST}, BodyType:javax.xml.bind.JAXBElement,
>> Body:javax.xml.bind.JAXBElement@143c268
>> 
>> 2010-02-11 15:19:04,432 : Logger.process :
>> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
>> log://poc.camel.greeting?level=DEBUG --> ref:greeting <<< Pattern:InOut,
>> Headers:{CamelHttpUri=http://127.0.0.1:9090/greeting,
>> org.restlet.startTime=1265897944026, org.restlet.http.headers=[Accept:
>> xml/application, Content-Type: , User-Agent: Jakarta
>> Commons-HttpClient/3.1,
>> Host: 127.0.0.1:9090, Content-Length: 57],
>> org.restlet.http.version=HTTP/1.0, CamelHttpMethod=POST},
>> BodyType:javax.xml.bind.JAXBElement,
>> Body:javax.xml.bind.JAXBElement@143c268
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> Ashwin Karpe wrote:
>>> Hi,
>>>
>>> Can you also post the exception that is being thrown...? 
>>>
>>> In addition is the payload being sent to the processor a serializable
>>> object of GreetingRequestType.class?
>>>
>>> You may want to introduce a log() in the DSL to get a sense of the
>>> contents of the exchange
>>>
>>> Cheers,
>>>
>>> Ashwin...
>>>
>>>
>>> Tapdur wrote:
>>>> Hi community
>>>>
>>>> in the process method, i want to get a body of type wich is generated
>>>> by
>>>> xjc, how to pass to the getBody() the jaxb option
>>>> ignoreJAXBElement="false" (used in the unmarshall) ?
>>>>
>>>> this line fail (within the correct object in the echange.in.value
>>>> attribute):  GreetingRequestType user = (GreetingRequestType)
>>>> exchange.getIn().getBody(GreetingRequestType.class);
>>>>
>>>> is it a bug or is there any workaround ?
>>>>
>>>> Thx
>>>> Bruno
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>> 
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/in.getBody%28%29-Bug-----tp27544321p27570760.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: in.getBody() Bug ???

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I think you need to let the jaxb unmarshal the xml without wrapping with 
JAXBElement, just like this

<jaxb ignoreJAXBElement="ture" prettyPrint="true"
contextPath="poc.camel.echange" />


Willem

Tapdur wrote:
> no exception just return null object
> 
> 2010-02-11 15:19:04,197 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
> from(http://127.0.0.1:9090/greeting) -->  <<< Pattern:InOut,
> Headers:{org.restlet.http.version=HTTP/1.0,
> CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
> User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
> Content-Length: 57], CamelHttpMethod=POST,
> org.restlet.startTime=1265897944026}, BodyType:String,
> Body:<GreetingRequest>
>        <name>Tapdur</name>
> </GreetingRequest>
> 
> 2010-02-11 15:19:04,369 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)  -->
> log://poc.camel.greeting?level=DEBUG <<< Pattern:InOut,
> Headers:{org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
> User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
> Content-Length: 57], CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.startTime=1265897944026, org.restlet.http.version=HTTP/1.0,
> CamelHttpMethod=POST}, BodyType:javax.xml.bind.JAXBElement,
> Body:javax.xml.bind.JAXBElement@143c268
> 
> 2010-02-11 15:19:04,432 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
> log://poc.camel.greeting?level=DEBUG --> ref:greeting <<< Pattern:InOut,
> Headers:{CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.startTime=1265897944026, org.restlet.http.headers=[Accept:
> xml/application, Content-Type: , User-Agent: Jakarta Commons-HttpClient/3.1,
> Host: 127.0.0.1:9090, Content-Length: 57],
> org.restlet.http.version=HTTP/1.0, CamelHttpMethod=POST},
> BodyType:javax.xml.bind.JAXBElement, Body:javax.xml.bind.JAXBElement@143c268
> 
> 
> 
> 
> 
> 
> 
> 
> Ashwin Karpe wrote:
>> Hi,
>>
>> Can you also post the exception that is being thrown...? 
>>
>> In addition is the payload being sent to the processor a serializable
>> object of GreetingRequestType.class?
>>
>> You may want to introduce a log() in the DSL to get a sense of the
>> contents of the exchange
>>
>> Cheers,
>>
>> Ashwin...
>>
>>
>> Tapdur wrote:
>>> Hi community
>>>
>>> in the process method, i want to get a body of type wich is generated by
>>> xjc, how to pass to the getBody() the jaxb option
>>> ignoreJAXBElement="false" (used in the unmarshall) ?
>>>
>>> this line fail (within the correct object in the echange.in.value
>>> attribute):  GreetingRequestType user = (GreetingRequestType)
>>> exchange.getIn().getBody(GreetingRequestType.class);
>>>
>>> is it a bug or is there any workaround ?
>>>
>>> Thx
>>> Bruno
>>>
>>>
>>>
>>>
>>>
>>
> 


Re: in.getBody() Bug ???

Posted by Ashwin Karpe <as...@progress.com>.
This sounds suspiciously like a case of the problem being earlier in the DSL
and prior to reaching the processor getBody(). Have you checked the JAXB
object to not be null before passing it downstream...? Also, have you
checked if the payload is not being stomped somewhere earlier in the DSL
prior to reaching the processor? 

I would very very surprised if a bug is present in the getBody() since it is
a well worn & high traffic operation and if there were such problems they
would be picked up earlier during unit testing...

Can you please verify this...?

Cheers,

Ashwin...


Tapdur wrote:
> 
> no exception just return null object
> 
> 2010-02-11 15:19:04,197 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
> from(http://127.0.0.1:9090/greeting) -->  <<< Pattern:InOut,
> Headers:{org.restlet.http.version=HTTP/1.0,
> CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
> User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
> Content-Length: 57], CamelHttpMethod=POST,
> org.restlet.startTime=1265897944026}, BodyType:String,
> Body:<GreetingRequest>
>        <name>Tapdur</name>
> </GreetingRequest>
> 
> 2010-02-11 15:19:04,369 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)  -->
> log://poc.camel.greeting?level=DEBUG <<< Pattern:InOut,
> Headers:{org.restlet.http.headers=[Accept: xml/application, Content-Type:
> , User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
> Content-Length: 57], CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.startTime=1265897944026, org.restlet.http.version=HTTP/1.0,
> CamelHttpMethod=POST}, BodyType:javax.xml.bind.JAXBElement,
> Body:javax.xml.bind.JAXBElement@143c268
> 
> 2010-02-11 15:19:04,432 : Logger.process :
> 37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
> log://poc.camel.greeting?level=DEBUG --> ref:greeting <<< Pattern:InOut,
> Headers:{CamelHttpUri=http://127.0.0.1:9090/greeting,
> org.restlet.startTime=1265897944026, org.restlet.http.headers=[Accept:
> xml/application, Content-Type: , User-Agent: Jakarta
> Commons-HttpClient/3.1, Host: 127.0.0.1:9090, Content-Length: 57],
> org.restlet.http.version=HTTP/1.0, CamelHttpMethod=POST},
> BodyType:javax.xml.bind.JAXBElement,
> Body:javax.xml.bind.JAXBElement@143c268
> 
> 
> 
> 
> 
> 
> 
> 
> Ashwin Karpe wrote:
>> 
>> Hi,
>> 
>> Can you also post the exception that is being thrown...? 
>> 
>> In addition is the payload being sent to the processor a serializable
>> object of GreetingRequestType.class?
>> 
>> You may want to introduce a log() in the DSL to get a sense of the
>> contents of the exchange
>> 
>> Cheers,
>> 
>> Ashwin...
>> 
>> 
>> Tapdur wrote:
>>> 
>>> Hi community
>>> 
>>> in the process method, i want to get a body of type wich is generated by
>>> xjc, how to pass to the getBody() the jaxb option
>>> ignoreJAXBElement="false" (used in the unmarshall) ?
>>> 
>>> this line fail (within the correct object in the echange.in.value
>>> attribute):  GreetingRequestType user = (GreetingRequestType)
>>> exchange.getIn().getBody(GreetingRequestType.class);
>>> 
>>> is it a bug or is there any workaround ?
>>> 
>>> Thx
>>> Bruno
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/in.getBody%28%29-Bug-----tp27544321p27548627.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: in.getBody() Bug ???

Posted by Tapdur <ta...@gmail.com>.
no exception just return null object

2010-02-11 15:19:04,197 : Logger.process :
37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
from(http://127.0.0.1:9090/greeting) -->  <<< Pattern:InOut,
Headers:{org.restlet.http.version=HTTP/1.0,
CamelHttpUri=http://127.0.0.1:9090/greeting,
org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
Content-Length: 57], CamelHttpMethod=POST,
org.restlet.startTime=1265897944026}, BodyType:String,
Body:<GreetingRequest>
       <name>Tapdur</name>
</GreetingRequest>

2010-02-11 15:19:04,369 : Logger.process :
37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)  -->
log://poc.camel.greeting?level=DEBUG <<< Pattern:InOut,
Headers:{org.restlet.http.headers=[Accept: xml/application, Content-Type: ,
User-Agent: Jakarta Commons-HttpClient/3.1, Host: 127.0.0.1:9090,
Content-Length: 57], CamelHttpUri=http://127.0.0.1:9090/greeting,
org.restlet.startTime=1265897944026, org.restlet.http.version=HTTP/1.0,
CamelHttpMethod=POST}, BodyType:javax.xml.bind.JAXBElement,
Body:javax.xml.bind.JAXBElement@143c268

2010-02-11 15:19:04,432 : Logger.process :
37b63738-e0c4-46aa-9906-a3a25805896f >>> (route1)
log://poc.camel.greeting?level=DEBUG --> ref:greeting <<< Pattern:InOut,
Headers:{CamelHttpUri=http://127.0.0.1:9090/greeting,
org.restlet.startTime=1265897944026, org.restlet.http.headers=[Accept:
xml/application, Content-Type: , User-Agent: Jakarta Commons-HttpClient/3.1,
Host: 127.0.0.1:9090, Content-Length: 57],
org.restlet.http.version=HTTP/1.0, CamelHttpMethod=POST},
BodyType:javax.xml.bind.JAXBElement, Body:javax.xml.bind.JAXBElement@143c268








Ashwin Karpe wrote:
> 
> Hi,
> 
> Can you also post the exception that is being thrown...? 
> 
> In addition is the payload being sent to the processor a serializable
> object of GreetingRequestType.class?
> 
> You may want to introduce a log() in the DSL to get a sense of the
> contents of the exchange
> 
> Cheers,
> 
> Ashwin...
> 
> 
> Tapdur wrote:
>> 
>> Hi community
>> 
>> in the process method, i want to get a body of type wich is generated by
>> xjc, how to pass to the getBody() the jaxb option
>> ignoreJAXBElement="false" (used in the unmarshall) ?
>> 
>> this line fail (within the correct object in the echange.in.value
>> attribute):  GreetingRequestType user = (GreetingRequestType)
>> exchange.getIn().getBody(GreetingRequestType.class);
>> 
>> is it a bug or is there any workaround ?
>> 
>> Thx
>> Bruno
>> 
>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/in.getBody%28%29-Bug-----tp27544321p27545970.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: in.getBody() Bug ???

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

Can you also post the exception that is being thrown...? 

In addition is the payload being sent to the processor a serializable object
of GreetingRequestType.class?

You may want to introduce a log() in the DSL to get a sense of the contents
of the exchange

Cheers,

Ashwin...


Tapdur wrote:
> 
> Hi community
> 
> in the process method, i want to get a body of type wich is generated by
> xjc, how to pass to the getBody() the jaxb option
> ignoreJAXBElement="false" (used in the unmarshall) ?
> 
> this line fail (within the correct object in the echange.in.value
> attribute):  GreetingRequestType user = (GreetingRequestType)
> exchange.getIn().getBody(GreetingRequestType.class);
> 
> is it a bug or is there any workaround ?
> 
> Thx
> Bruno
> 
> 
> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/in.getBody%28%29-Bug-----tp27544321p27544548.html
Sent from the Camel - Users mailing list archive at Nabble.com.