You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by sub3 <st...@subwest.com> on 2008/01/21 03:00:28 UTC

Camel & Sending CXF generated objects

Hi,
I am just starting to learn camel.  I seem to be routing/sending simple
objects fine.  As soon as I start to use objects generated by cxf's
wsdl2java, they come across as null.

What is it about these objects that cause this, and is there a way to stop
it?  I can only assume it has something to do with the way it gets
serialized.

Thanks for any help.
-- 
View this message in context: http://www.nabble.com/Camel---Sending-CXF-generated-objects-tp14989933s22882p14989933.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel & Sending CXF generated objects

Posted by sub3 <st...@subwest.com>.

Found the problem.  CXF generated objects aren't serializable, so camel must
just be dropping it somewhere & not tell me.

If I changed the generated object to extend java.io.Serializable, it will
works.  I thought that since camel handle the cxf objects, it would handle
them being passed around as well.

So, I guess the solution here is to convert them to xml before pass through
camel.

Thanks for the help.
-- 
View this message in context: http://www.nabble.com/Camel---Sending-CXF-generated-objects-tp14989933s22882p15005823.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel & Sending CXF generated objects

Posted by sub3 <st...@subwest.com>.

So here is how I send:

> CamelContext context = new DefaultCamelContext(jcontext);
> ConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory("tcp://localhost:61616");
> context.addComponent("test-jms",
> JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
> CamelTemplate template = new CamelTemplate(context);
> context.start();
> Order o = new Order();
> template.sendBody("test-jms:queue:PA", o);

If Order is my several field class, it gets to the other machine.  If it is
any type of cxf object it is null.
So, if it toString() the whole message I get:
          [java] Received exchange: JmsMessage: ActiveMQMessage {commandId =
5, responseRequired = true, messageId =
ID:norfolk-37596-1200941899204-0:7:1:1:1, originalDestination = null,
originalTransactionId = null, producerId =
ID:norfolk-37596-1200941899204-0:7:1:1, destination = queue://PA,
transactionId = null, expiration = 0, timestamp = 1200941899439, arrival =
0, brokerInTime = 1200941899439, brokerOutTime = 1200941899516,
correlationId = null, replyTo = null, persistent = true, type = null,
priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null,
compressed = false, userID = null, content = null, marshalledProperties =
null, dataStructure = null, redeliveryCounter = 7, size = 0, properties =
null, readOnlyProperties = true, readOnlyBody = true, droppable = false}

If I used my own Order class, I get a
org.apache.activemq.util.ByteSequence@f47bf5 is the context field.
     
Where else can I put debugging?
Thanks.




James.Strachan wrote:
> 
> On 21/01/2008, sub3 <st...@subwest.com> wrote:
>>
>> Yes, I know I didn't use camel-cxf component.  But that is only when I
>> want
>> to hit a web service right?
> 
> Or process SOAP encoding of messages
> 
> 
>> So I have a wsdl for my order system. The message is
>> OrderSystemRequestMessage.  Inside that is OrderRequest, inside that is a
>> list of Order.
>>
>> Right now, I want to pass around the Order class. Eventually, it will
>> make
>> it to the web service; but I am not at that point yet.  (It need to
>> verify
>> the Order, Check Inventory, Assign item, etc).
>>
>> When I try to pass just the Order class around (using the previous
>> example),
>> it becomes null.  Like the cxf objects & camel aren't serializing them at
>> all.  If I create my own Order class (simple class w/a few fields), it
>> works
>> fine.
>>
>> Is there something I need to do with cxf generated classes so it will
>> work
>> in camel.
> 
> AFAIK the only special thing with CXF generated classes is they use by
> default JAXB for marshalling themselves to and from XML.
> 
> Could you describe how and when the payload turns to null? e.g. any
> chance you could create a little Camel route example of how to take
> one of your CXF-generated beans and making it go wrong? In your
> previous mail you used this code...
> 
>      context.addRoutes(new RouteBuilder() {
>                    public void configure() {
>                        // set up a listener on the file component
>                        from("test-jms:queue:PA").process(new Processor() {
> 
>                                public void process(Exchange e) {
>                                    Object obj = e.getIn().getBody();
>                                    System.out.println("OBJ IS: "+obj);
>                                }
>                            });
>                    }
>                });
> 
> I'm just wondering, do the messages on the queue definitely contain a
> valid body, and if so what format is it? Or to say that another way,
> what code sends the messages?
> 
> Am wondering if its JAXB2 related. e.g. does adding the
> @XmlRootElement to your hand crafted Order class, does that cause your
> code to break too?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://open.iona.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel---Sending-CXF-generated-objects-tp14989933s22882p15003866.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel & Sending CXF generated objects

Posted by James Strachan <ja...@gmail.com>.
On 21/01/2008, sub3 <st...@subwest.com> wrote:
>
> Yes, I know I didn't use camel-cxf component.  But that is only when I want
> to hit a web service right?

Or process SOAP encoding of messages


> So I have a wsdl for my order system. The message is
> OrderSystemRequestMessage.  Inside that is OrderRequest, inside that is a
> list of Order.
>
> Right now, I want to pass around the Order class. Eventually, it will make
> it to the web service; but I am not at that point yet.  (It need to verify
> the Order, Check Inventory, Assign item, etc).
>
> When I try to pass just the Order class around (using the previous example),
> it becomes null.  Like the cxf objects & camel aren't serializing them at
> all.  If I create my own Order class (simple class w/a few fields), it works
> fine.
>
> Is there something I need to do with cxf generated classes so it will work
> in camel.

AFAIK the only special thing with CXF generated classes is they use by
default JAXB for marshalling themselves to and from XML.

Could you describe how and when the payload turns to null? e.g. any
chance you could create a little Camel route example of how to take
one of your CXF-generated beans and making it go wrong? In your
previous mail you used this code...

     context.addRoutes(new RouteBuilder() {
                   public void configure() {
                       // set up a listener on the file component
                       from("test-jms:queue:PA").process(new Processor() {

                               public void process(Exchange e) {
                                   Object obj = e.getIn().getBody();
                                   System.out.println("OBJ IS: "+obj);
                               }
                           });
                   }
               });

I'm just wondering, do the messages on the queue definitely contain a
valid body, and if so what format is it? Or to say that another way,
what code sends the messages?

Am wondering if its JAXB2 related. e.g. does adding the
@XmlRootElement to your hand crafted Order class, does that cause your
code to break too?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://open.iona.com

Re: Camel & Sending CXF generated objects

Posted by sub3 <st...@subwest.com>.
Yes, I know I didn't use camel-cxf component.  But that is only when I want
to hit a web service right?

So I have a wsdl for my order system. The message is
OrderSystemRequestMessage.  Inside that is OrderRequest, inside that is a
list of Order.

Right now, I want to pass around the Order class. Eventually, it will make
it to the web service; but I am not at that point yet.  (It need to verify
the Order, Check Inventory, Assign item, etc).

When I try to pass just the Order class around (using the previous example),
it becomes null.  Like the cxf objects & camel aren't serializing them at
all.  If I create my own Order class (simple class w/a few fields), it works
fine.

Is there something I need to do with cxf generated classes so it will work
in camel.

Thanks.




willem.jiang wrote:
> 
> Hi,
> 
> Yes, it looks like you do not use the camel-cxf component.
> I think you start with the CamelJmsToFile example which start an in JVM 
> jms transport.
> If you want to send the messages to this jms endpoint, you need to use 
> the template to send them.
> 
> Willem.
> sub3 wrote:
>> Hi,
>> Thanks for the quick reply.  I am using 1.2.0.
>>
>> I have simplified things greatly & I am still getting null.
>> So on one end, I am sending to through JMS, on the other:
>> 	    context.addRoutes(new RouteBuilder() {
>> 		    public void configure() {
>> 			// set up a listener on the file component
>> 			from("test-jms:queue:PA").process(new Processor() {
>> 				
>> 				public void process(Exchange e) {
>> 				    Object obj = e.getIn().getBody();
>> 				    System.out.println("OBJ IS: "+obj);
>> 				}
>> 			    });
>> 		    }
>> 		});
>>
>> I don't believe I am using the 'camel-cxf' component.  I am just using
>> some
>> cxf generated objects (no need to hit an endpoint yet, that would be
>> several
>> steps later).  So it might be ActiveMQ making it null, but I don't know. 
>> I
>> guess I need a little direction so I can determine where it is being
>> dropped.
>>
>> Thanks in advance.
>>
>>
>>
>> willem.jiang wrote:
>>   
>>> Hi ,
>>>
>>> Which version of Camel that you use ?
>>> Can you show me your router configuration code ?
>>> We just fixed some bugs of the camel-cxf component , The recent fix is 
>>> CAMEL-286[1]
>>>
>>> [1] https://issues.apache.org/activemq/browse/CAMEL-286
>>>
>>> Willem.
>>>
>>> sub3 wrote:
>>>     
>>>> Hi,
>>>> I am just starting to learn camel.  I seem to be routing/sending simple
>>>> objects fine.  As soon as I start to use objects generated by cxf's
>>>> wsdl2java, they come across as null.
>>>>
>>>> What is it about these objects that cause this, and is there a way to
>>>> stop
>>>> it?  I can only assume it has something to do with the way it gets
>>>> serialized.
>>>>
>>>> Thanks for any help.
>>>>   
>>>>       
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel---Sending-CXF-generated-objects-tp14989933s22882p14997477.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel & Sending CXF generated objects

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

Yes, it looks like you do not use the camel-cxf component.
I think you start with the CamelJmsToFile example which start an in JVM 
jms transport.
If you want to send the messages to this jms endpoint, you need to use 
the template to send them.

Willem.
sub3 wrote:
> Hi,
> Thanks for the quick reply.  I am using 1.2.0.
>
> I have simplified things greatly & I am still getting null.
> So on one end, I am sending to through JMS, on the other:
> 	    context.addRoutes(new RouteBuilder() {
> 		    public void configure() {
> 			// set up a listener on the file component
> 			from("test-jms:queue:PA").process(new Processor() {
> 				
> 				public void process(Exchange e) {
> 				    Object obj = e.getIn().getBody();
> 				    System.out.println("OBJ IS: "+obj);
> 				}
> 			    });
> 		    }
> 		});
>
> I don't believe I am using the 'camel-cxf' component.  I am just using some
> cxf generated objects (no need to hit an endpoint yet, that would be several
> steps later).  So it might be ActiveMQ making it null, but I don't know.  I
> guess I need a little direction so I can determine where it is being
> dropped.
>
> Thanks in advance.
>
>
>
> willem.jiang wrote:
>   
>> Hi ,
>>
>> Which version of Camel that you use ?
>> Can you show me your router configuration code ?
>> We just fixed some bugs of the camel-cxf component , The recent fix is 
>> CAMEL-286[1]
>>
>> [1] https://issues.apache.org/activemq/browse/CAMEL-286
>>
>> Willem.
>>
>> sub3 wrote:
>>     
>>> Hi,
>>> I am just starting to learn camel.  I seem to be routing/sending simple
>>> objects fine.  As soon as I start to use objects generated by cxf's
>>> wsdl2java, they come across as null.
>>>
>>> What is it about these objects that cause this, and is there a way to
>>> stop
>>> it?  I can only assume it has something to do with the way it gets
>>> serialized.
>>>
>>> Thanks for any help.
>>>   
>>>       
>>
>>     
>
>   


Re: Camel & Sending CXF generated objects

Posted by sub3 <st...@subwest.com>.
Hi,
Thanks for the quick reply.  I am using 1.2.0.

I have simplified things greatly & I am still getting null.
So on one end, I am sending to through JMS, on the other:
	    context.addRoutes(new RouteBuilder() {
		    public void configure() {
			// set up a listener on the file component
			from("test-jms:queue:PA").process(new Processor() {
				
				public void process(Exchange e) {
				    Object obj = e.getIn().getBody();
				    System.out.println("OBJ IS: "+obj);
				}
			    });
		    }
		});

I don't believe I am using the 'camel-cxf' component.  I am just using some
cxf generated objects (no need to hit an endpoint yet, that would be several
steps later).  So it might be ActiveMQ making it null, but I don't know.  I
guess I need a little direction so I can determine where it is being
dropped.

Thanks in advance.



willem.jiang wrote:
> 
> Hi ,
> 
> Which version of Camel that you use ?
> Can you show me your router configuration code ?
> We just fixed some bugs of the camel-cxf component , The recent fix is 
> CAMEL-286[1]
> 
> [1] https://issues.apache.org/activemq/browse/CAMEL-286
> 
> Willem.
> 
> sub3 wrote:
>> Hi,
>> I am just starting to learn camel.  I seem to be routing/sending simple
>> objects fine.  As soon as I start to use objects generated by cxf's
>> wsdl2java, they come across as null.
>>
>> What is it about these objects that cause this, and is there a way to
>> stop
>> it?  I can only assume it has something to do with the way it gets
>> serialized.
>>
>> Thanks for any help.
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Camel---Sending-CXF-generated-objects-tp14989933s22882p14990116.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel & Sending CXF generated objects

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

Which version of Camel that you use ?
Can you show me your router configuration code ?
We just fixed some bugs of the camel-cxf component , The recent fix is 
CAMEL-286[1]

[1] https://issues.apache.org/activemq/browse/CAMEL-286

Willem.

sub3 wrote:
> Hi,
> I am just starting to learn camel.  I seem to be routing/sending simple
> objects fine.  As soon as I start to use objects generated by cxf's
> wsdl2java, they come across as null.
>
> What is it about these objects that cause this, and is there a way to stop
> it?  I can only assume it has something to do with the way it gets
> serialized.
>
> Thanks for any help.
>