Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

View: New views
8 Messages — Rating Filter:   Alert me  

Parent Message unknown Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by ehildebrandt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello all,

first of all I'd like to thank you for you good work. I'm really
enjoying working with Apache Camel.

I'd like to use Apache CXF with Apache Camel as transport and trying
to implement a webservice using SOAP over JMS. I'm thinking that I
identified some bugs in Apache Camel.

ISSUE #1:
First of all I tried to implement a CXF webservice _client_ using
Apache Camel as transport.
My code runs into a org.springframework.jms.MessageFormatException
(see attached stacktrace1.txt). According to JMS API Specification the
operation "getObjectProperty" supports only primitive values (see
http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html). It's
not allowed to put an object of type java.lang.reflect.Method using
this method.

I pached this bug (see JmsBinding.java.patch) by converting all
non-primitive objects to a string. It's working now but the author of
the CXF component should really rethink if it's really necessary to
put all the unimportant header properties inside the message. Other
more important header properties like "SoapAction" are missing
instead.

In case you like to reproduce this issue, you can find my sample
project at http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip.
This project is configured to use TIBCO as JMS-Server. But you can use
ActiveMQ as well.

ISSUE #2:
The next issue was that the JMS-Components creates JMS-Messages based
on the object type. For example:

JmsBinding.java
221 if (body instanceof String) {
222   return session.createTextMessage((String)body);
223 }
224 if (body instanceof Serializable) {
225    return session.createObjectMessage((Serializable)body);
226 }

The CXF-Component puts an InputStream on the camel exchange:

CamelConduit.java
165 ex.getIn().setBody(outputStream.getInputStream());


For the JMS-Compontent it's an object type Serializable for this
reason it creates an JMS-ObjectMessage. But this is not the expected
behaviour of my service. I'm using SOAP over JMS and like to create a
JMS-TextMessage because the content is XML.

I solved this issue by implementing an own Processor and converting
the message content on camel exchange to a string (see
BodyProcessor.java). I think the better solution will be if the JMS
component allows to configure the JMS-Message-Type and/or the CXF
component puts an String to the camel exchange.

Now my client was sending correct requests (except the missing
"SoapAction" property). But this was not the end of the journey…

ISSUE #3:
The next issue was that the response message could not be associated
with the CXF service because the CXF context was missing. I pached
this (see CamelConduit.java.patch) by adding following line in
CamelConduit.java:

170 exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());

After adding this line the response could be processed correctly.
However I'm not really sure if this is the right place for this and it
should be reviewed by the original author.

My client was working now. Hura! :-)

Next I wanted to implement the server side implementation of the
service as well with Apache CXF and Apache Camel as transport.

But now I'm stuck on a NullPointerException at
org.apache.camel.component.cxf.transport.CamelDestination.activate(CamelDestination.java:91)
(see stacktrace2.txt). The reason is that CamelTransportFactory does
not have a CamelContext even if I configure it in my spring
configuration. I think that CXF is using an own spring context and
does not use (or does not see) my camel context configuration.

Maybe I'm doing something wrong… Maybe a developer who is more
familiar with Apache CXF and Apache Camel can have a look at it. You
help is very appreciated.

Thank you very much!

Many greeting from Germany.

Best regards,

Eduard Hildebrandt

--
Meinen Weblog: http://www.eduard-hildebrandt.de



--
Meinen Weblog: http://www.eduard-hildebrandt.de

29.02.2008 11:20:47 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@18385e3: display name [org.springframework.context.support.ClassPathXmlApplicationContext@18385e3]; startup date [Fri Feb 29 11:20:47 CET 2008]; root of context hierarchy
29.02.2008 11:20:47 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config/server-applicationContext.xml]
29.02.2008 11:20:48 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring-config/jms-applicationContext.xml]
29.02.2008 11:20:49 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@18385e3]: org.springframework.beans.factory.support.DefaultListableBeanFactory@10c0f66
29.02.2008 11:20:49 org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'camelContext' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
29.02.2008 11:20:49 org.springframework.context.support.AbstractApplicationContext$BeanPostProcessorChecker postProcessAfterInitialization
INFO: Bean 'camelContext' is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
29.02.2008 11:20:49 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@10c0f66: defining beans [jms,jmsConnectionFactory,org.apache.camel.component.cxf.transport.CamelTransportFactory,camelContext:beanPostProcessor,camelContext,customerWebServiceV1,{http://www.mycompany.com/examples/customerrelations}CustomerServiceV1CamelPort.camel-destination,soapActionProcessor]; root of factory hierarchy
29.02.2008 11:20:49 org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.apache.cxf.bus.spring.BusApplicationContext@739f3f: display name [org.apache.cxf.bus.spring.BusApplicationContext@739f3f]; startup date [Fri Feb 29 11:20:49 CET 2008]; root of context hierarchy
29.02.2008 11:20:49 org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
INFO: No cxf.xml configuration file detected, relying on defaults.
29.02.2008 11:20:49 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
29.02.2008 11:20:49 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
29.02.2008 11:20:49 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-xml.xml]
29.02.2008 11:20:49 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-jaxws.xml]
29.02.2008 11:20:49 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-addr.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-camel.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-management.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http-jetty.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-http.xml]
29.02.2008 11:20:50 org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder': replacing [Generic bean: class [org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class [org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]]
29.02.2008 11:20:50 org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder': replacing [Generic bean: class [org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class [org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]]
29.02.2008 11:20:50 org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider': replacing [Generic bean: class [org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class [org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]]
29.02.2008 11:20:50 org.springframework.beans.factory.support.DefaultListableBeanFactory registerBeanDefinition
INFO: Overriding bean definition for bean 'org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory': replacing [Generic bean: class [org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory]; scope=singleton; abstract=false; lazyInit=true; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]] with [Generic bean: class [org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory]; scope=singleton; abstract=false; lazyInit=true; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in class path resource [META-INF/cxf/cxf-extension-http.xml]]
29.02.2008 11:20:50 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/cxf/cxf-extension-local.xml]
29.02.2008 11:20:50 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
INFO: Bean factory for application context [org.apache.cxf.bus.spring.BusApplicationContext@739f3f]: org.springframework.beans.factory.support.DefaultListableBeanFactory@40ece0
29.02.2008 11:20:50 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@40ece0: defining beans [cxf,org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor,org.apache.cxf.bus.spring.Jsr250BeanPostProcessor,org.apache.cxf.bus.spring.BusExtensionPostProcessor,org.apache.cxf.resource.ResourceManager,org.apache.cxf.configuration.Configurer,org.apache.cxf.binding.BindingFactoryManager,org.apache.cxf.transport.DestinationFactoryManager,org.apache.cxf.transport.ConduitInitiatorManager,org.apache.cxf.wsdl.WSDLManager,org.apache.cxf.phase.PhaseManager,org.apache.cxf.workqueue.WorkQueueManager,org.apache.cxf.buslifecycle.BusLifeCycleManager,org.apache.cxf.endpoint.ServerRegistry,org.apache.cxf.endpoint.ServerLifeCycleManager,org.apache.cxf.endpoint.ClientLifeCycleManager,org.apache.cxf.transports.http.QueryHandlerRegistry,org.apache.cxf.endpoint.EndpointResolverRegistry,org.apache.cxf.headers.HeaderManager,org.apache.cxf.catalog.OASISCatalogManager,org.apache.cxf.endpoint.ServiceContractResolverRegistry,org.apache.cxf.binding.soap.SoapBindingFactory,org.apache.cxf.binding.soap.SoapTransportFactory,org.apache.cxf.binding.soap.customEditorConfigurer,org.apache.cxf.binding.xml.XMLBindingFactory,org.apache.cxf.jaxws.context.WebServiceContextResourceResolver,org.apache.cxf.jaxws.context.WebServiceContextImpl,org.apache.cxf.ws.addressing.policy.AddressingAssertionBuilder,org.apache.cxf.ws.addressing.policy.AddressingPolicyInterceptorProvider,org.apache.cxf.ws.addressing.policy.UsingAddressingAssertionBuilder,org.apache.camel.component.cxf.transport.CamelTransportFactory#0,org.apache.cxf.management.jmx.InstrumentationManagerImpl,org.apache.cxf.transport.http.policy.HTTPClientAssertionBuilder,org.apache.cxf.transport.http.policy.HTTPServerAssertionBuilder,org.apache.cxf.transport.http.policy.NoOpPolicyInterceptorProvider,org.apache.cxf.transport.http.ClientOnlyHTTPTransportFactory,org.apache.cxf.transport.http_jetty.JettyHTTPTransportFactory,org.apache.cxf.transport.local.LocalTransportFactory]; root of factory hierarchy
29.02.2008 11:20:51 org.apache.cxf.service.factory.ReflectionServiceFactoryBean buildServiceFromClass
INFO: Creating Service {http://customerrelations.examples.mycompany.com/}CustomerServiceV1ImplService from class com.mycompany.examples.customerrelations.CustomerServiceV1
29.02.2008 11:20:51 org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be camel://direct:customerServiceV1
29.02.2008 11:20:51 org.apache.camel.component.cxf.transport.CamelDestination activate
SCHWERWIEGEND: Camel connect failed with Exception :
java.lang.NullPointerException
        at org.apache.camel.component.cxf.transport.CamelDestination.activate(CamelDestination.java:91)
        at org.apache.cxf.transport.AbstractObservable.setMessageObserver(AbstractObservable.java:48)
        at org.apache.cxf.binding.AbstractBindingFactory.addListener(AbstractBindingFactory.java:166)
        at org.apache.cxf.binding.soap.SoapBindingFactory.addListener(SoapBindingFactory.java:681)
        at org.apache.cxf.endpoint.ServerImpl.start(ServerImpl.java:122)
        at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:261)
        at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:201)
        at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:392)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1413)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1374)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:729)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
        at com.mycompany.examples.customerrelations.ServiceServer.main(ServiceServer.java:15)
SCHWERWIEGEND: Failed delivery for exchangeId: ID-DE-L067381/12991-1204287965437/0-0. On delivery attempt: 0 caught: org.springframework.jms.MessageFormatException: Invalid property value of class java.lang.reflect.Method; nested exception is javax.jms.MessageFormatException: Invalid property value of class java.lang.reflect.Method
org.springframework.jms.MessageFormatException: Invalid property value of class java.lang.reflect.Method; nested exception is javax.jms.MessageFormatException: Invalid property value of class java.lang.reflect.Method
        at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:273)
        at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:168)
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:474)
        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate.send(JmsConfiguration.java:173)
        at org.apache.camel.component.jms.JmsProducer.process(JmsProducer.java:172)
        at org.apache.camel.impl.converter.AsyncProcessorTypeConverter$ProcessorToAsyncProcessorBridge.process(AsyncProcessorTypeConverter.java:43)
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:75)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:57)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:155)
        at org.apache.camel.processor.DeadLetterChannel.process(DeadLetterChannel.java:91)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:85)
        at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:57)
        at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:39)
        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.direct.DirectProducer.process(DirectProducer.java:47)
        at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:149)
        at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:134)
        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:92)
        at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:74)
        at org.apache.camel.component.cxf.transport.CamelConduit$CamelOutputStream.commitOutputMessage(CamelConduit.java:160)
        at org.apache.camel.component.cxf.transport.CamelConduit$CamelOutputStream.doClose(CamelConduit.java:143)
        at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:156)
        at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66)
        at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
        at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:221)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:296)
        at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:242)
        at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
        at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:178)
        at $Proxy47.getCustomer(Unknown Source)
        at com.mycompany.examples.customerrelations.ServiceClient.main(ServiceClient.java:41)
Caused by: javax.jms.MessageFormatException: Invalid property value of class java.lang.reflect.Method
        at com.tibco.tibjms.TibjmsMessage.setObjectProperty(TibjmsMessage.java:558)
        at org.apache.camel.component.jms.JmsBinding.appendJmsProperty(JmsBinding.java:185)
        at org.apache.camel.component.jms.JmsBinding.appendJmsProperties(JmsBinding.java:157)
        at org.apache.camel.component.jms.JmsBinding.makeJmsMessage(JmsBinding.java:135)
        at org.apache.camel.component.jms.JmsProducer$1.createMessage(JmsProducer.java:174)
        at org.apache.camel.component.jms.JmsConfiguration$CamelJmsTemplate$1.doInJms(JmsConfiguration.java:180)
        at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:471)
        ... 30 more

Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Woo, You show me lots of issues and patches in one mail. It will take a
time for me to digest them ;)

First I should thank you for chosing the CXF and Camel.

I' will head to the CamelDestination error first, but I can't get the
project for the url that your mentioned in the mail.
Can you show me the spring configuration file that you use?

BTW, You can fill the JIRA[1] if you think that is a bug of camel.

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

Willem

Eduard Hildebrandt wrote:

> Hello all,
>
> first of all I'd like to thank you for you good work. I'm really
> enjoying working with Apache Camel.
>
> I'd like to use Apache CXF with Apache Camel as transport and trying
> to implement a webservice using SOAP over JMS. I'm thinking that I
> identified some bugs in Apache Camel.
>
> ISSUE #1:
> First of all I tried to implement a CXF webservice _client_ using
> Apache Camel as transport.
> My code runs into a org.springframework.jms.MessageFormatException
> (see attached stacktrace1.txt). According to JMS API Specification the
> operation "getObjectProperty" supports only primitive values (see
> http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Message.html). It's
> not allowed to put an object of type java.lang.reflect.Method using
> this method.
>
> I pached this bug (see JmsBinding.java.patch) by converting all
> non-primitive objects to a string. It's working now but the author of
> the CXF component should really rethink if it's really necessary to
> put all the unimportant header properties inside the message. Other
> more important header properties like "SoapAction" are missing
> instead.
>
> In case you like to reproduce this issue, you can find my sample
> project at http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip.
> This project is configured to use TIBCO as JMS-Server. But you can use
> ActiveMQ as well.
>
> ISSUE #2:
> The next issue was that the JMS-Components creates JMS-Messages based
> on the object type. For example:
>
> JmsBinding.java
> 221 if (body instanceof String) {
> 222   return session.createTextMessage((String)body);
> 223 }
> 224 if (body instanceof Serializable) {
> 225    return session.createObjectMessage((Serializable)body);
> 226 }
>
> The CXF-Component puts an InputStream on the camel exchange:
>
> CamelConduit.java
> 165 ex.getIn().setBody(outputStream.getInputStream());
>
>
> For the JMS-Compontent it's an object type Serializable for this
> reason it creates an JMS-ObjectMessage. But this is not the expected
> behaviour of my service. I'm using SOAP over JMS and like to create a
> JMS-TextMessage because the content is XML.
>
> I solved this issue by implementing an own Processor and converting
> the message content on camel exchange to a string (see
> BodyProcessor.java). I think the better solution will be if the JMS
> component allows to configure the JMS-Message-Type and/or the CXF
> component puts an String to the camel exchange.
>
> Now my client was sending correct requests (except the missing
> "SoapAction" property). But this was not the end of the journey…
>
> ISSUE #3:
> The next issue was that the response message could not be associated
> with the CXF service because the CXF context was missing. I pached
> this (see CamelConduit.java.patch) by adding following line in
> CamelConduit.java:
>
> 170 exchange.setProperty(CxfConstants.CXF_EXCHANGE, outMessage.getExchange());
>
> After adding this line the response could be processed correctly.
> However I'm not really sure if this is the right place for this and it
> should be reviewed by the original author.
>
> My client was working now. Hura! :-)
>
> Next I wanted to implement the server side implementation of the
> service as well with Apache CXF and Apache Camel as transport.
>
> But now I'm stuck on a NullPointerException at
> org.apache.camel.component.cxf.transport.CamelDestination.activate(CamelDestination.java:91)
> (see stacktrace2.txt). The reason is that CamelTransportFactory does
> not have a CamelContext even if I configure it in my spring
> configuration. I think that CXF is using an own spring context and
> does not use (or does not see) my camel context configuration.
>
> Maybe I'm doing something wrong… Maybe a developer who is more
> familiar with Apache CXF and Apache Camel can have a look at it. You
> help is very appreciated.
>
> Thank you very much!
>
> Many greeting from Germany.
>
> Best regards,
>
> Eduard Hildebrandt
>
> --
> Meinen Weblog: http://www.eduard-hildebrandt.de
>
>
>
>  


Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by ehildebrandt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Willem,

> I' will head to the CamelDestination error first, but I can't get the
> project for the url that your mentioned in the mail.

Seems that something went wrong during the upload. Please try again
using following URL:
http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip

In the mean time I could fix the NullPointer problem and some other
issues. My example is now working (client and server). The webservice
is using CXF and Camel as transport.

I tested this configuration with TIBCO EMS and ActiveMQ. Both
configurations are working now.

Please consider applying following patches:
http://family-hildebrandt.com/eduard/wp-content/uploads/camel-jms.patch
http://family-hildebrandt.com/eduard/wp-content/uploads/camel-cxf.patch

Best regards,

Eduard

--
My Weblog: http://www.eduard-hildebrandt.de

RE: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by Claus Ibsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Eduard

Thanks a lot for the feedback on Camel, new logo and patches. Great work. Glad it gives you work as well and that your presentation was a success.

Willem I will look into the JMS part as I have done the latest fixes there with the header properties to allow propagation over the JMS wire.

I have created tickets for the two issues
- CXF related CAMEL-686
- JMS related CAMEL-685



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: eduard.hildebrandt@... [mailto:eduard.hildebrandt@...] On Behalf Of Eduard Hildebrandt
Sent: 8. juli 2008 11:41
To: camel-user@...
Subject: Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

Hi Willem,

> I' will head to the CamelDestination error first, but I can't get the
> project for the url that your mentioned in the mail.

Seems that something went wrong during the upload. Please try again
using following URL:
http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip

In the mean time I could fix the NullPointer problem and some other
issues. My example is now working (client and server). The webservice
is using CXF and Camel as transport.

I tested this configuration with TIBCO EMS and ActiveMQ. Both
configurations are working now.

Please consider applying following patches:
http://family-hildebrandt.com/eduard/wp-content/uploads/camel-jms.patch
http://family-hildebrandt.com/eduard/wp-content/uploads/camel-cxf.patch

Best regards,

Eduard

--
My Weblog: http://www.eduard-hildebrandt.de

Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Eduard,

I just applied the CXF part of patch in the Camel trunk, and I also did
some refactoring work take the common expression codes as utile method
in CxfSoapBinding.

Thanks for your great demo, I take it as an integration test case for
the CAMEL-686 :)

We have some discussion about how to handle the protocol header here[1],
you solution is very simple and effective for using camel transport in
CXF. We may go further by thinking the use case in a more common way.

Thought?

[1]http://www.nabble.com/-PROPOSAL--ProtocolMessage-to18078001s22882.html#a18078001

Willem.


Eduard Hildebrandt wrote:

> Hi Willem,
>
>  
>> I' will head to the CamelDestination error first, but I can't get the
>> project for the url that your mentioned in the mail.
>>    
>
> Seems that something went wrong during the upload. Please try again
> using following URL:
> http://family-hildebrandt.com/eduard/wp-content/uploads/serviceruntime.zip
>
> In the mean time I could fix the NullPointer problem and some other
> issues. My example is now working (client and server). The webservice
> is using CXF and Camel as transport.
>
> I tested this configuration with TIBCO EMS and ActiveMQ. Both
> configurations are working now.
>
> Please consider applying following patches:
> http://family-hildebrandt.com/eduard/wp-content/uploads/camel-jms.patch
> http://family-hildebrandt.com/eduard/wp-content/uploads/camel-cxf.patch
>
> Best regards,
>
> Eduard
>
>  


Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by ehildebrandt :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Willem,

thanks for applying the patch. One of my customers is planning to use
the next release of Apache Camel and CXF in production environment and
this was an important bugfix for them. I'm looking forward for Apache
Camel 1.4 :-)

I have some additional comments:

Using a byte-array as message body
("ex.getIn().setBody(outputStream.getBytes());") like I did  works for
in the demo. But as I mentioned before I think this is not an elegant
solution. What happens if my service implementation expects a
JMS-TextMessage?

FEATURE REQUEST #1:
It should be possible to configure the message type (TextMessage,
BytesMessage, …) in JMS component. The current implementation can be
the default behaviour. But if the user configure a JMS message type
than the JMS component must convert the content in the requested
message type format.

FEATURE REQUEST #2 (depends on #1):
If the user specify TextMessage as JMS message type than it must be
possible to specify the encoding (UTF-8, ISO-8856-1, …) of the text
message. This feature is tricky because if the content is a byte array
then the JMS component does not know the current encoding of the data.
Maybe we need an additional property in Camel context that specifies
the encoding of the message content.

Let me know what you are thinking about this feature requests. If you
are interested I can try to implement these features and send you a
patch.

Best regards,

Eduard

2008/7/9 Willem Jiang <willem.jiang@...>:

> Hi Eduard,
>
> I just applied the CXF part of patch in the Camel trunk, and I also did some
> refactoring work take the common expression codes as utile method in
> CxfSoapBinding.
>
> Thanks for your great demo, I take it as an integration test case for the
> CAMEL-686 :)
>
> We have some discussion about how to handle the protocol header here[1], you
> solution is very simple and effective for using camel transport in CXF. We
> may go further by thinking the use case in a more common way.
>
> Thought?
>
> [1]http://www.nabble.com/-PROPOSAL--ProtocolMessage-to18078001s22882.html#a18078001
>
> Willem.

Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by willem.jiang :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Eduard,

I admit that set the message body
with("ex.getIn().setBody(outputStream.getBytes());") is not a good solution.

So let's work it out and I am looking forward  for your contribution :)

BTW, you can fill a JIRA[1] for tracking it.

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

Cheers,

Willem



Eduard Hildebrandt wrote:

> Hi Willem,
>
> thanks for applying the patch. One of my customers is planning to use
> the next release of Apache Camel and CXF in production environment and
> this was an important bugfix for them. I'm looking forward for Apache
> Camel 1.4 :-)
>
> I have some additional comments:
>
> Using a byte-array as message body
> ("ex.getIn().setBody(outputStream.getBytes());") like I did  works for
> in the demo. But as I mentioned before I think this is not an elegant
> solution. What happens if my service implementation expects a
> JMS-TextMessage?
>
> FEATURE REQUEST #1:
> It should be possible to configure the message type (TextMessage,
> BytesMessage, …) in JMS component. The current implementation can be
> the default behaviour. But if the user configure a JMS message type
> than the JMS component must convert the content in the requested
> message type format.
>
> FEATURE REQUEST #2 (depends on #1):
> If the user specify TextMessage as JMS message type than it must be
> possible to specify the encoding (UTF-8, ISO-8856-1, …) of the text
> message. This feature is tricky because if the content is a byte array
> then the JMS component does not know the current encoding of the data.
> Maybe we need an additional property in Camel context that specifies
> the encoding of the message content.
>
> Let me know what you are thinking about this feature requests. If you
> are interested I can try to implement these features and send you a
> patch.
>
> Best regards,
>
> Eduard
>
> 2008/7/9 Willem Jiang <willem.jiang@...>:
>  
>> Hi Eduard,
>>
>> I just applied the CXF part of patch in the Camel trunk, and I also did some
>> refactoring work take the common expression codes as utile method in
>> CxfSoapBinding.
>>
>> Thanks for your great demo, I take it as an integration test case for the
>> CAMEL-686 :)
>>
>> We have some discussion about how to handle the protocol header here[1], you
>> solution is very simple and effective for using camel transport in CXF. We
>> may go further by thinking the use case in a more common way.
>>
>> Thought?
>>
>> [1]http://www.nabble.com/-PROPOSAL--ProtocolMessage-to18078001s22882.html#a18078001
>>
>> Willem.
>>    
>
>  


RE: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

by Claus Ibsen :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

About feature request #2
========================
We have some tickets in JIRA to be able to configure encoding and then the camel built in converters to/from bytes should be able to use this encoding configuration. This is target for camel 1.5.

So it will be part of a master plan to fix all the to/from byte conversions.
But please feel free to comment/vote on these JIRA tickets.


Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@...]
Sent: 10. juli 2008 09:37
To: camel-user@...
Subject: Re: Fwd: Using Apache Camel as Transport for Apache CXF with SOAP over JMS

Hi Eduard,

I admit that set the message body
with("ex.getIn().setBody(outputStream.getBytes());") is not a good solution.

So let's work it out and I am looking forward  for your contribution :)

BTW, you can fill a JIRA[1] for tracking it.

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

Cheers,

Willem



Eduard Hildebrandt wrote:

> Hi Willem,
>
> thanks for applying the patch. One of my customers is planning to use
> the next release of Apache Camel and CXF in production environment and
> this was an important bugfix for them. I'm looking forward for Apache
> Camel 1.4 :-)
>
> I have some additional comments:
>
> Using a byte-array as message body
> ("ex.getIn().setBody(outputStream.getBytes());") like I did  works for
> in the demo. But as I mentioned before I think this is not an elegant
> solution. What happens if my service implementation expects a
> JMS-TextMessage?
>
> FEATURE REQUEST #1:
> It should be possible to configure the message type (TextMessage,
> BytesMessage, ...) in JMS component. The current implementation can be
> the default behaviour. But if the user configure a JMS message type
> than the JMS component must convert the content in the requested
> message type format.
>
> FEATURE REQUEST #2 (depends on #1):
> If the user specify TextMessage as JMS message type than it must be
> possible to specify the encoding (UTF-8, ISO-8856-1, ...) of the text
> message. This feature is tricky because if the content is a byte array
> then the JMS component does not know the current encoding of the data.
> Maybe we need an additional property in Camel context that specifies
> the encoding of the message content.
>
> Let me know what you are thinking about this feature requests. If you
> are interested I can try to implement these features and send you a
> patch.
>
> Best regards,
>
> Eduard
>
> 2008/7/9 Willem Jiang <willem.jiang@...>:
>  
>> Hi Eduard,
>>
>> I just applied the CXF part of patch in the Camel trunk, and I also did some
>> refactoring work take the common expression codes as utile method in
>> CxfSoapBinding.
>>
>> Thanks for your great demo, I take it as an integration test case for the
>> CAMEL-686 :)
>>
>> We have some discussion about how to handle the protocol header here[1], you
>> solution is very simple and effective for using camel transport in CXF. We
>> may go further by thinking the use case in a more common way.
>>
>> Thought?
>>
>> [1]http://www.nabble.com/-PROPOSAL--ProtocolMessage-to18078001s22882.html#a18078001
>>
>> Willem.
>>    
>
>  

Need professional support or training for Apache Camel? Graphic Design by Hiram and the Nabble Forum configured by James