You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by stevenmaring <st...@gmail.com> on 2009/06/02 23:04:16 UTC

using ProducerTemplate for JMS with Spring

I'm probably doing something stupidly wrong here but I can't seem to figure
it out.  I keep getting a NullPointerException when I try to use my
camelTemplate property in my class.  I think, perhaps, I'm not understanding
how camel:template gets instrumented by JmsComponent, but I can't find the
documentation on this.



<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:camel="http://camel.apache.org/schema/spring"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:jee="http://www.springframework.org/schema/jee"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://cxf.apache.org/jaxws
       http://cxf.apache.org/schemas/jaxws.xsd
       http://camel.apache.org/schema/spring
       http://camel.apache.org/schema/spring/camel-spring.xsd
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-2.5.xsd
       http://activemq.apache.org/camel/schema/spring 
       http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
       http://www.springframework.org/schema/jee
       http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">


	<import resource="classpath:META-INF/cxf/cxf.xml" />
	<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
	<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />  
	
	<camel:camelContext id="camel"/>
	<camel:template id="camelTemplate"/>
	
	<bean id="imq" class="org.apache.camel.component.jms.JmsComponent">
  		<property name="connectionFactory" ref="imqConnectionFactory"/>
	</bean>
	
	<bean id="voiceGenerator" class="com.ess.tts.ws.VoiceGeneratorService">
		<property name="camelTemplate" ref="camelTemplate"/>
	</bean>

 	<bean id="imqConnectionFactory"
class="com.ess.tts.engine.util.IMQConnectionFactory">
		<property name="hostname" value="localhost" />
 		<property name="port" value="7676" />
 		<property name="username" value="admin" />
 		<property name="password" value="admin" />
 	</bean>

	
	<jaxws:endpoint
		id="voiceGeneratorWS"
		implementor="com.ess.tts.ws.VoiceGeneratorService"
		address="/voiceGeneratorService"
	/>

</beans>


@WebService(endpointInterface="com.ess.tts.ws.VoiceGenerator",
		serviceName="VoiceGeneratorService",
		portName="VoiceGeneratorPort")
public class VoiceGeneratorService implements VoiceGenerator {
	
	private static Logger log =
LoggerFactory.getLogger(VoiceGeneratorService.class);
	
	private ProducerTemplate camelTemplate;
	
	public void generateVoice(TTSAudioConfig audioConfig) {
		camelTemplate.sendBody("imq:queue:voiceRequestQueue",
ExchangePattern.InOut, audioConfig);
	}

	public ProducerTemplate getCamelTemplate() {
		return camelTemplate;
	}

	public void setCamelTemplate(ProducerTemplate camelTemplate) {
		this.camelTemplate = camelTemplate;
	}
	
}


-Steve Maring

-- 
View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23840855.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: using ProducerTemplate for JMS with Spring

Posted by James Strachan <ja...@gmail.com>.
2009/6/4 James Strachan <ja...@gmail.com>:
> 2009/6/4 stevenmaring <st...@gmail.com>:
>>
>> yeah ... I fought with my local Archiva repo for quite some time yesterday
>> because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
>> snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
>> Archiva repo.
>>
>> well ... with regard to this issue I'm having I'm not sure whether to put my
>> fist through the screen or curl up in the corner and cry like a baby ...
>> I've been fighting this for 3 days (on little sleep) and I'm supposed to
>> demo something with a code review in 7 hours!!!!  I thought it would be cool
>> if I could show how I could make this company's life easier with Camel ...
>> it won't look good for Camel (in the eyes of my company) or ME (in this
>> economy as a contractor) if I can't get something working very soon.
>>
>> I've given up on trying to inject a handle to the ProducerTemplate into my
>> class since, given the CamelContext, I can easily create one
>> programmatically.  So now, my only concern is how to get a handle to the
>> CamelContext into my POJO.
>>
>> I can see the context start in the logs, but it seems no matter what I try I
>> cannot get my CamelContext property set.  It is always null.
>>
>> <camel:camelContext id="camel"/>
>
> the camel: namespace is properly defined - and you've camel-spring on
> your classpath right?

The 2.0 namespace for camel is different BTW - I noticed you were
using the old http://activemq.apache... namespace in the first mail in
this thread.

For 2.x your XML should look like this...

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
    ">

    <camelContext xmlns="http://camel.apache.org/schema/spring">
        <template id="template"/>
    </camelContext>


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

Open Source Integration
http://fusesource.com/

Re: using ProducerTemplate for JMS with Spring

Posted by James Strachan <ja...@gmail.com>.
2009/6/4 James Strachan <ja...@gmail.com>:
> 2009/6/4 stevenmaring <st...@gmail.com>:
>>
>> yeah ... I fought with my local Archiva repo for quite some time yesterday
>> because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
>> snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
>> Archiva repo.
>>
>> well ... with regard to this issue I'm having I'm not sure whether to put my
>> fist through the screen or curl up in the corner and cry like a baby ...
>> I've been fighting this for 3 days (on little sleep) and I'm supposed to
>> demo something with a code review in 7 hours!!!!  I thought it would be cool
>> if I could show how I could make this company's life easier with Camel ...
>> it won't look good for Camel (in the eyes of my company) or ME (in this
>> economy as a contractor) if I can't get something working very soon.
>>
>> I've given up on trying to inject a handle to the ProducerTemplate into my
>> class since, given the CamelContext, I can easily create one
>> programmatically.  So now, my only concern is how to get a handle to the
>> CamelContext into my POJO.
>>
>> I can see the context start in the logs, but it seems no matter what I try I
>> cannot get my CamelContext property set.  It is always null.
>>
>> <camel:camelContext id="camel"/>
>
> the camel: namespace is properly defined - and you've camel-spring on
> your classpath right?
>
>
>> <bean id="myBean" class="sample.MyBean">
>>   <property name="context" ref="camel"/>
>> </bean>
>
> That should work fine!
>
> BTW if your bean implements CamelContextAware it should get the
> CamelContext injected automatically - so long as the CamelContext is
> correctly.
>
> I wonder if its worth you submitting simple maven project with your
> POJO (remove all your company stuff) and we can get it working for you
> (then we can include it as an example)?

Or another option is - starting with an example from Camel itself that
works - e.g. the POJO messaging example?
http://camel.apache.org/pojo-messaging-example.html

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

Open Source Integration
http://fusesource.com/

Re: using ProducerTemplate for JMS with Spring

Posted by James Strachan <ja...@gmail.com>.
2009/6/4 stevenmaring <st...@gmail.com>:
>
> yeah ... I fought with my local Archiva repo for quite some time yesterday
> because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
> snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
> Archiva repo.
>
> well ... with regard to this issue I'm having I'm not sure whether to put my
> fist through the screen or curl up in the corner and cry like a baby ...
> I've been fighting this for 3 days (on little sleep) and I'm supposed to
> demo something with a code review in 7 hours!!!!  I thought it would be cool
> if I could show how I could make this company's life easier with Camel ...
> it won't look good for Camel (in the eyes of my company) or ME (in this
> economy as a contractor) if I can't get something working very soon.
>
> I've given up on trying to inject a handle to the ProducerTemplate into my
> class since, given the CamelContext, I can easily create one
> programmatically.  So now, my only concern is how to get a handle to the
> CamelContext into my POJO.
>
> I can see the context start in the logs, but it seems no matter what I try I
> cannot get my CamelContext property set.  It is always null.
>
> <camel:camelContext id="camel"/>

the camel: namespace is properly defined - and you've camel-spring on
your classpath right?


> <bean id="myBean" class="sample.MyBean">
>   <property name="context" ref="camel"/>
> </bean>

That should work fine!

BTW if your bean implements CamelContextAware it should get the
CamelContext injected automatically - so long as the CamelContext is
correctly.

I wonder if its worth you submitting simple maven project with your
POJO (remove all your company stuff) and we can get it working for you
(then we can include it as an example)?

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

Open Source Integration
http://fusesource.com/

Re: using ProducerTemplate for JMS with Spring

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

You should see in your logs that Spring says something about bean XXX
is not eligble for post processors. When it says this then you know
you are in trouble. It should not say this for your POJO.



On Thu, Jun 4, 2009 at 11:58 AM, Claus Ibsen <cl...@gmail.com> wrote:
> On Thu, Jun 4, 2009 at 11:35 AM, stevenmaring <st...@gmail.com> wrote:
>>
>> yeah ... I fought with my local Archiva repo for quite some time yesterday
>> because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
>> snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
>> Archiva repo.
>>
>> well ... with regard to this issue I'm having I'm not sure whether to put my
>> fist through the screen or curl up in the corner and cry like a baby ...
>> I've been fighting this for 3 days (on little sleep) and I'm supposed to
>> demo something with a code review in 7 hours!!!!  I thought it would be cool
>> if I could show how I could make this company's life easier with Camel ...
>> it won't look good for Camel (in the eyes of my company) or ME (in this
>> economy as a contractor) if I can't get something working very soon.
>>
>> I've given up on trying to inject a handle to the ProducerTemplate into my
>> class since, given the CamelContext, I can easily create one
>> programmatically.  So now, my only concern is how to get a handle to the
>> CamelContext into my POJO.
>>
>> I can see the context start in the logs, but it seems no matter what I try I
>> cannot get my CamelContext property set.  It is always null.
>>
>> <camel:camelContext id="camel"/>
>>
>> <bean id="myBean" class="sample.MyBean">
>>   <property name="context" ref="camel"/>
>> </bean>
>>
>> where MyBean is also a jaxws webservice.  I've tried to instrument helper
>> classes instead of this pojo directly.  I've tried various versions of Camel
>> and every possible combination of namespaces I can think of.  I suppose next
>> I will try creating a CamelManager class that starts the context manually
>> and builds the routes, remove all refs to camel from my spring config, and
>> inject my pojo with that. ... oh, and pray like hell!   I know the powers
>> that be are not going to be too thrilled with a hack though.
>
> Yeah you can always do a CamelContext context = new DefaultCamelContext();
> For instance you can avoid using the Spring Camel DSL and just use Java DSL.
>
> For instance this tutorial stedily adds Camel to an existing solution.
> http://camel.apache.org/tutorial-example-reportincident-part2.html
>
>
>
> Ahhhh I guess Spring IoC is all bean post processors. So if you POJO
> contains some 3rd part annotations such as @WebService or the likes
> then Spring will not do all the other IoC stuff regardless what you
> do.
>
> Try for starters to remove any annotation in your POJO and see if you
> get the context set.
> Then add one annotation and see that is *not* set. Then you know the problem.
>
> If you have the time and want to you could create a small project (a
> zip file) that I can take a look at.
>
>
>>
>> I'm sooooo frustrated right now = (
>>
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> On Thu, Jun 4, 2009 at 5:26 AM, stevenmaring <st...@gmail.com>
>>> wrote:
>>>>
>>>> Clause,
>>>>
>>>> I just tried the 2.0-SNAPSHOT released earlier today and got the same
>>>> thing.
>>> There is something wrong with the Apache snapshot maven repo. Its
>>> maven metadata is wrong.
>>> It wrongly says the last version is a version from 9th april.
>>>
>>> You can get a fresh version by downloading the .jar yourself and
>>> install to your local .m2 repo.
>>> Or build the source and install locally.
>>>
>>>
>>>>
>>>> May I ask for a specific example of what you mean by "use regular setter
>>>> IoC
>>>> using spring bean property to set the camel producer template"?
>>>
>>> Yes its using the spring bean XML wiring
>>>
>>> <bean id="foo" class=...>
>>>    <property name="myprop" ref="bar"/>
>>> </bean>
>>>
>>> <bean id="bar" class=.../>
>>>
>>> In the camel context you give the <camelTemplate> and id so its
>>> <camelTemplate id="template"/>
>>>
>>> And then ref to this id from your POJO class.
>>>
>>>
>>>
>>>>
>>>> Thanks,
>>>> Steve Maring
>>>>
>>>>
>>>> Claus Ibsen-2 wrote:
>>>>>
>>>>> Hi
>>>>>
>>>>> I think you are stuck by the bug CAMEL-1663 that causes dependency
>>>>> injection with annotations to not work if you mix annotations from
>>>>> Camel with others.
>>>>> So use regular setter IoC using spring bean property to set the camel
>>>>> producer template.
>>>>>
>>>>> You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
>>>>> version when its build by this time tomorrow.
>>>>>
>>>>> Details at the download page if using maven to get the SNAPSHOT
>>>>> http://camel.apache.org/download.html
>>>>>
>>>>>
>>>>> On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com>
>>>>> wrote:
>>>>>>
>>>>>> I tried putting the template inside the camelContext but it didn't seem
>>>>>> to
>>>>>> help.  I've now read thru a good chunk of the manual, which certainly
>>>>>> did
>>>>>> wonders for my understanding of what is going on, but I'm still
>>>>>> scratching
>>>>>> my head over this NullpointerException.  The logs don't seem to be
>>>>>> yelling
>>>>>> at me about anything ...
>>>>>>
>>>>>> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
>>>>>> initialization started
>>>>>> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
>>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>>>> 06:49:01
>>>>>> EDT 2009]; root of context hierarchy
>>>>>> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>>> definitions from ServletContext resource
>>>>>> [/WEB-INF/applicationContext.xml]
>>>>>> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>>> definitions from class path resource [META-INF/cxf/cxf.xml]
>>>>>> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>>> definitions from class path resource
>>>>>> [META-INF/cxf/cxf-extension-soap.xml]
>>>>>> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>>> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
>>>>>> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
>>>>>> application context
>>>>>> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>>>> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
>>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>>> not
>>>>>> eligible for auto-proxying)
>>>>>> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
>>>>>> InstrumentationLifecycleStrategy.
>>>>>> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created
>>>>>> routes:
>>>>>> []
>>>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>>> not
>>>>>> eligible for auto-proxying)
>>>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>>> not
>>>>>> eligible for auto-proxying)
>>>>>> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>>>> singletons in
>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
>>>>>> defining beans
>>>>>> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
>>>>>> root of factory hierarchy
>>>>>> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>>>> 06:49:01
>>>>>> EDT 2009]; root of context hierarchy]
>>>>>> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>>>> now
>>>>>> that the ApplicationContext has started
>>>>>> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
>>>>>> (CamelContext:camel) is starting
>>>>>> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent
>>>>>> on
>>>>>> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
>>>>>> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>>>> with
>>>>>> objectname: org.apache.camel:context=smaring-dt/camel,name=context
>>>>>> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
>>>>>> (CamelContext:camel) started
>>>>>> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
>>>>>> uri=[spring-event:default], path=[default], parameters=[{}]
>>>>>> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default
>>>>>> converted
>>>>>> to endpoint: Endpoint[spring-event:default] by component:
>>>>>> org.apache.camel.component.event.EventComponent@1f4cf6f
>>>>>> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>>>> with
>>>>>> objectname:
>>>>>> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
>>>>>> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
>>>>>> initialization completed in 5938 ms
>>>>>> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
>>>>>> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
>>>>>> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date
>>>>>> [Wed
>>>>>> Jun 03 06:49:07 EDT 2009]; parent:
>>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
>>>>>> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for
>>>>>> application
>>>>>> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
>>>>>> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>>>> singletons in
>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
>>>>>> defining beans []; parent:
>>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>>>> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
>>>>>> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
>>>>>> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
>>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
>>>>>> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>>>> now
>>>>>> that the ApplicationContext has started
>>>>>>
>>>>>>
>>>>>> I'm going to try a simple HelloWorld sort of project getting a
>>>>>> reference
>>>>>> to
>>>>>> the ProducerTemplate ala ...
>>>>>>
>>>>>> mvn archetype:generate                   \
>>>>>>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>>>>>>  -DarchetypeArtifactId=camel-archetype-spring   \
>>>>>>  -DarchetypeVersion=2.0-M1             \
>>>>>>  -DgroupId=my.sample           \
>>>>>>  -DartifactId=HelloCamel
>>>>>>
>>>>>> hopefully I will either learn something or not get the
>>>>>> NullpointerException
>>>>>> on my reference.
>>>>>>
>>>>>> I'll let ya'll know how it goes ... thank you much for your thoughts so
>>>>>> far
>>>>>>
>>>>>> -Steve Maring
>>>>>>
>>>>>>
>>>>>> Martin Gilday wrote:
>>>>>>>
>>>>>>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>>>>>>
>>>>>>> Claus,
>>>>>>> Do you have to put the template inside the context?  Is this a 2.0
>>>>>>> change?  I've always placed it outside.  As you can't define a context
>>>>>>> ref it seemed effectively singleton and so didn't matter where you
>>>>>>> created it.  This is also how I wrote it in the Camel Spring tutorial
>>>>>>> on
>>>>>>> the wiki.  If it is considereed incorrect then I can update it.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Martin
>>>>>>>
>>>>>>>
>>>>>>> ----- Original message -----
>>>>>>> From: "Claus Ibsen" <cl...@gmail.com>
>>>>>>> To: users@camel.apache.org
>>>>>>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>>>>>>> Subject: Re: using ProducerTemplate for JMS with Spring
>>>>>>>
>>>>>>>
>>>>>>> Hi welcome on board the Camel ride.
>>>>>>>
>>>>>>> You almost got it. The camel:template XML tag should be inside the
>>>>>>> camel:context XML tag. So it should be:
>>>>>>>
>>>>>>>         <camel:camelContext id="camel">
>>>>>>>             <camel:template id="camelTemplate"/>
>>>>>>>         </camel:camelContext>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> View this message in context:
>>>>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23863267.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
>>>
>>>
>>
>> --
>> View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23866699.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: using ProducerTemplate for JMS with Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 4, 2009 at 11:35 AM, stevenmaring <st...@gmail.com> wrote:
>
> yeah ... I fought with my local Archiva repo for quite some time yesterday
> because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
> snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
> Archiva repo.
>
> well ... with regard to this issue I'm having I'm not sure whether to put my
> fist through the screen or curl up in the corner and cry like a baby ...
> I've been fighting this for 3 days (on little sleep) and I'm supposed to
> demo something with a code review in 7 hours!!!!  I thought it would be cool
> if I could show how I could make this company's life easier with Camel ...
> it won't look good for Camel (in the eyes of my company) or ME (in this
> economy as a contractor) if I can't get something working very soon.
>
> I've given up on trying to inject a handle to the ProducerTemplate into my
> class since, given the CamelContext, I can easily create one
> programmatically.  So now, my only concern is how to get a handle to the
> CamelContext into my POJO.
>
> I can see the context start in the logs, but it seems no matter what I try I
> cannot get my CamelContext property set.  It is always null.
>
> <camel:camelContext id="camel"/>
>
> <bean id="myBean" class="sample.MyBean">
>   <property name="context" ref="camel"/>
> </bean>
>
> where MyBean is also a jaxws webservice.  I've tried to instrument helper
> classes instead of this pojo directly.  I've tried various versions of Camel
> and every possible combination of namespaces I can think of.  I suppose next
> I will try creating a CamelManager class that starts the context manually
> and builds the routes, remove all refs to camel from my spring config, and
> inject my pojo with that. ... oh, and pray like hell!   I know the powers
> that be are not going to be too thrilled with a hack though.

Yeah you can always do a CamelContext context = new DefaultCamelContext();
For instance you can avoid using the Spring Camel DSL and just use Java DSL.

For instance this tutorial stedily adds Camel to an existing solution.
http://camel.apache.org/tutorial-example-reportincident-part2.html



Ahhhh I guess Spring IoC is all bean post processors. So if you POJO
contains some 3rd part annotations such as @WebService or the likes
then Spring will not do all the other IoC stuff regardless what you
do.

Try for starters to remove any annotation in your POJO and see if you
get the context set.
Then add one annotation and see that is *not* set. Then you know the problem.

If you have the time and want to you could create a small project (a
zip file) that I can take a look at.


>
> I'm sooooo frustrated right now = (
>
>
>
> Claus Ibsen-2 wrote:
>>
>> On Thu, Jun 4, 2009 at 5:26 AM, stevenmaring <st...@gmail.com>
>> wrote:
>>>
>>> Clause,
>>>
>>> I just tried the 2.0-SNAPSHOT released earlier today and got the same
>>> thing.
>> There is something wrong with the Apache snapshot maven repo. Its
>> maven metadata is wrong.
>> It wrongly says the last version is a version from 9th april.
>>
>> You can get a fresh version by downloading the .jar yourself and
>> install to your local .m2 repo.
>> Or build the source and install locally.
>>
>>
>>>
>>> May I ask for a specific example of what you mean by "use regular setter
>>> IoC
>>> using spring bean property to set the camel producer template"?
>>
>> Yes its using the spring bean XML wiring
>>
>> <bean id="foo" class=...>
>>    <property name="myprop" ref="bar"/>
>> </bean>
>>
>> <bean id="bar" class=.../>
>>
>> In the camel context you give the <camelTemplate> and id so its
>> <camelTemplate id="template"/>
>>
>> And then ref to this id from your POJO class.
>>
>>
>>
>>>
>>> Thanks,
>>> Steve Maring
>>>
>>>
>>> Claus Ibsen-2 wrote:
>>>>
>>>> Hi
>>>>
>>>> I think you are stuck by the bug CAMEL-1663 that causes dependency
>>>> injection with annotations to not work if you mix annotations from
>>>> Camel with others.
>>>> So use regular setter IoC using spring bean property to set the camel
>>>> producer template.
>>>>
>>>> You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
>>>> version when its build by this time tomorrow.
>>>>
>>>> Details at the download page if using maven to get the SNAPSHOT
>>>> http://camel.apache.org/download.html
>>>>
>>>>
>>>> On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com>
>>>> wrote:
>>>>>
>>>>> I tried putting the template inside the camelContext but it didn't seem
>>>>> to
>>>>> help.  I've now read thru a good chunk of the manual, which certainly
>>>>> did
>>>>> wonders for my understanding of what is going on, but I'm still
>>>>> scratching
>>>>> my head over this NullpointerException.  The logs don't seem to be
>>>>> yelling
>>>>> at me about anything ...
>>>>>
>>>>> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
>>>>> initialization started
>>>>> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>>> 06:49:01
>>>>> EDT 2009]; root of context hierarchy
>>>>> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>> definitions from ServletContext resource
>>>>> [/WEB-INF/applicationContext.xml]
>>>>> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>> definitions from class path resource [META-INF/cxf/cxf.xml]
>>>>> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>> definitions from class path resource
>>>>> [META-INF/cxf/cxf-extension-soap.xml]
>>>>> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>>> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
>>>>> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
>>>>> application context
>>>>> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>>> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>> not
>>>>> eligible for auto-proxying)
>>>>> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
>>>>> InstrumentationLifecycleStrategy.
>>>>> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created
>>>>> routes:
>>>>> []
>>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>> not
>>>>> eligible for auto-proxying)
>>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>>> not
>>>>> eligible for auto-proxying)
>>>>> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>>> singletons in
>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
>>>>> defining beans
>>>>> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
>>>>> root of factory hierarchy
>>>>> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>>> 06:49:01
>>>>> EDT 2009]; root of context hierarchy]
>>>>> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>>> now
>>>>> that the ApplicationContext has started
>>>>> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
>>>>> (CamelContext:camel) is starting
>>>>> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent
>>>>> on
>>>>> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
>>>>> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>>> with
>>>>> objectname: org.apache.camel:context=smaring-dt/camel,name=context
>>>>> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
>>>>> (CamelContext:camel) started
>>>>> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
>>>>> uri=[spring-event:default], path=[default], parameters=[{}]
>>>>> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default
>>>>> converted
>>>>> to endpoint: Endpoint[spring-event:default] by component:
>>>>> org.apache.camel.component.event.EventComponent@1f4cf6f
>>>>> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>>> with
>>>>> objectname:
>>>>> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
>>>>> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
>>>>> initialization completed in 5938 ms
>>>>> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
>>>>> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
>>>>> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date
>>>>> [Wed
>>>>> Jun 03 06:49:07 EDT 2009]; parent:
>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
>>>>> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for
>>>>> application
>>>>> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
>>>>> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>>> singletons in
>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
>>>>> defining beans []; parent:
>>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>>> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
>>>>> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
>>>>> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
>>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
>>>>> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>>> now
>>>>> that the ApplicationContext has started
>>>>>
>>>>>
>>>>> I'm going to try a simple HelloWorld sort of project getting a
>>>>> reference
>>>>> to
>>>>> the ProducerTemplate ala ...
>>>>>
>>>>> mvn archetype:generate                   \
>>>>>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>>>>>  -DarchetypeArtifactId=camel-archetype-spring   \
>>>>>  -DarchetypeVersion=2.0-M1             \
>>>>>  -DgroupId=my.sample           \
>>>>>  -DartifactId=HelloCamel
>>>>>
>>>>> hopefully I will either learn something or not get the
>>>>> NullpointerException
>>>>> on my reference.
>>>>>
>>>>> I'll let ya'll know how it goes ... thank you much for your thoughts so
>>>>> far
>>>>>
>>>>> -Steve Maring
>>>>>
>>>>>
>>>>> Martin Gilday wrote:
>>>>>>
>>>>>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>>>>>
>>>>>> Claus,
>>>>>> Do you have to put the template inside the context?  Is this a 2.0
>>>>>> change?  I've always placed it outside.  As you can't define a context
>>>>>> ref it seemed effectively singleton and so didn't matter where you
>>>>>> created it.  This is also how I wrote it in the Camel Spring tutorial
>>>>>> on
>>>>>> the wiki.  If it is considereed incorrect then I can update it.
>>>>>>
>>>>>> Thanks,
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>> ----- Original message -----
>>>>>> From: "Claus Ibsen" <cl...@gmail.com>
>>>>>> To: users@camel.apache.org
>>>>>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>>>>>> Subject: Re: using ProducerTemplate for JMS with Spring
>>>>>>
>>>>>>
>>>>>> Hi welcome on board the Camel ride.
>>>>>>
>>>>>> You almost got it. The camel:template XML tag should be inside the
>>>>>> camel:context XML tag. So it should be:
>>>>>>
>>>>>>         <camel:camelContext id="camel">
>>>>>>             <camel:template id="camelTemplate"/>
>>>>>>         </camel:camelContext>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23863267.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
>>
>>
>
> --
> View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23866699.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: using ProducerTemplate for JMS with Spring

Posted by stevenmaring <st...@gmail.com>.
yeah ... I fought with my local Archiva repo for quite some time yesterday
because it didn't seem to be proxying the SNAPSHOT requests onto the Apache
snapshot repo, so I manually inserted the 2.0-SNAPSHOT releases into my
Archiva repo.

well ... with regard to this issue I'm having I'm not sure whether to put my
fist through the screen or curl up in the corner and cry like a baby ...
I've been fighting this for 3 days (on little sleep) and I'm supposed to
demo something with a code review in 7 hours!!!!  I thought it would be cool
if I could show how I could make this company's life easier with Camel ...
it won't look good for Camel (in the eyes of my company) or ME (in this
economy as a contractor) if I can't get something working very soon.

I've given up on trying to inject a handle to the ProducerTemplate into my
class since, given the CamelContext, I can easily create one
programmatically.  So now, my only concern is how to get a handle to the
CamelContext into my POJO.

I can see the context start in the logs, but it seems no matter what I try I
cannot get my CamelContext property set.  It is always null.

<camel:camelContext id="camel"/>

<bean id="myBean" class="sample.MyBean">
   <property name="context" ref="camel"/>
</bean>

where MyBean is also a jaxws webservice.  I've tried to instrument helper
classes instead of this pojo directly.  I've tried various versions of Camel
and every possible combination of namespaces I can think of.  I suppose next
I will try creating a CamelManager class that starts the context manually
and builds the routes, remove all refs to camel from my spring config, and
inject my pojo with that. ... oh, and pray like hell!   I know the powers
that be are not going to be too thrilled with a hack though.

I'm sooooo frustrated right now = (



Claus Ibsen-2 wrote:
> 
> On Thu, Jun 4, 2009 at 5:26 AM, stevenmaring <st...@gmail.com>
> wrote:
>>
>> Clause,
>>
>> I just tried the 2.0-SNAPSHOT released earlier today and got the same
>> thing.
> There is something wrong with the Apache snapshot maven repo. Its
> maven metadata is wrong.
> It wrongly says the last version is a version from 9th april.
> 
> You can get a fresh version by downloading the .jar yourself and
> install to your local .m2 repo.
> Or build the source and install locally.
> 
> 
>>
>> May I ask for a specific example of what you mean by "use regular setter
>> IoC
>> using spring bean property to set the camel producer template"?
> 
> Yes its using the spring bean XML wiring
> 
> <bean id="foo" class=...>
>    <property name="myprop" ref="bar"/>
> </bean>
> 
> <bean id="bar" class=.../>
> 
> In the camel context you give the <camelTemplate> and id so its
> <camelTemplate id="template"/>
> 
> And then ref to this id from your POJO class.
> 
> 
> 
>>
>> Thanks,
>> Steve Maring
>>
>>
>> Claus Ibsen-2 wrote:
>>>
>>> Hi
>>>
>>> I think you are stuck by the bug CAMEL-1663 that causes dependency
>>> injection with annotations to not work if you mix annotations from
>>> Camel with others.
>>> So use regular setter IoC using spring bean property to set the camel
>>> producer template.
>>>
>>> You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
>>> version when its build by this time tomorrow.
>>>
>>> Details at the download page if using maven to get the SNAPSHOT
>>> http://camel.apache.org/download.html
>>>
>>>
>>> On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com>
>>> wrote:
>>>>
>>>> I tried putting the template inside the camelContext but it didn't seem
>>>> to
>>>> help.  I've now read thru a good chunk of the manual, which certainly
>>>> did
>>>> wonders for my understanding of what is going on, but I'm still
>>>> scratching
>>>> my head over this NullpointerException.  The logs don't seem to be
>>>> yelling
>>>> at me about anything ...
>>>>
>>>> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
>>>> initialization started
>>>> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>> 06:49:01
>>>> EDT 2009]; root of context hierarchy
>>>> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>> definitions from ServletContext resource
>>>> [/WEB-INF/applicationContext.xml]
>>>> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>> definitions from class path resource [META-INF/cxf/cxf.xml]
>>>> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>> definitions from class path resource
>>>> [META-INF/cxf/cxf-extension-soap.xml]
>>>> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>>> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
>>>> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
>>>> application context
>>>> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>> not
>>>> eligible for auto-proxying)
>>>> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
>>>> InstrumentationLifecycleStrategy.
>>>> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created
>>>> routes:
>>>> []
>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>> not
>>>> eligible for auto-proxying)
>>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>>> eligible for getting processed by all BeanPostProcessors (for example:
>>>> not
>>>> eligible for auto-proxying)
>>>> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>> singletons in
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
>>>> defining beans
>>>> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
>>>> root of factory hierarchy
>>>> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>>> 06:49:01
>>>> EDT 2009]; root of context hierarchy]
>>>> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>> now
>>>> that the ApplicationContext has started
>>>> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
>>>> (CamelContext:camel) is starting
>>>> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent
>>>> on
>>>> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
>>>> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>> with
>>>> objectname: org.apache.camel:context=smaring-dt/camel,name=context
>>>> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
>>>> (CamelContext:camel) started
>>>> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
>>>> uri=[spring-event:default], path=[default], parameters=[{}]
>>>> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default
>>>> converted
>>>> to endpoint: Endpoint[spring-event:default] by component:
>>>> org.apache.camel.component.event.EventComponent@1f4cf6f
>>>> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>>> with
>>>> objectname:
>>>> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
>>>> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
>>>> initialization completed in 5938 ms
>>>> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
>>>> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
>>>> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date
>>>> [Wed
>>>> Jun 03 06:49:07 EDT 2009]; parent:
>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
>>>> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for
>>>> application
>>>> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
>>>> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>>> singletons in
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
>>>> defining beans []; parent:
>>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>>> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>>> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
>>>> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
>>>> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
>>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
>>>> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext
>>>> now
>>>> that the ApplicationContext has started
>>>>
>>>>
>>>> I'm going to try a simple HelloWorld sort of project getting a
>>>> reference
>>>> to
>>>> the ProducerTemplate ala ...
>>>>
>>>> mvn archetype:generate                   \
>>>>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>>>>  -DarchetypeArtifactId=camel-archetype-spring   \
>>>>  -DarchetypeVersion=2.0-M1             \
>>>>  -DgroupId=my.sample           \
>>>>  -DartifactId=HelloCamel
>>>>
>>>> hopefully I will either learn something or not get the
>>>> NullpointerException
>>>> on my reference.
>>>>
>>>> I'll let ya'll know how it goes ... thank you much for your thoughts so
>>>> far
>>>>
>>>> -Steve Maring
>>>>
>>>>
>>>> Martin Gilday wrote:
>>>>>
>>>>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>>>>
>>>>> Claus,
>>>>> Do you have to put the template inside the context?  Is this a 2.0
>>>>> change?  I've always placed it outside.  As you can't define a context
>>>>> ref it seemed effectively singleton and so didn't matter where you
>>>>> created it.  This is also how I wrote it in the Camel Spring tutorial
>>>>> on
>>>>> the wiki.  If it is considereed incorrect then I can update it.
>>>>>
>>>>> Thanks,
>>>>> Martin
>>>>>
>>>>>
>>>>> ----- Original message -----
>>>>> From: "Claus Ibsen" <cl...@gmail.com>
>>>>> To: users@camel.apache.org
>>>>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>>>>> Subject: Re: using ProducerTemplate for JMS with Spring
>>>>>
>>>>>
>>>>> Hi welcome on board the Camel ride.
>>>>>
>>>>> You almost got it. The camel:template XML tag should be inside the
>>>>> camel:context XML tag. So it should be:
>>>>>
>>>>>         <camel:camelContext id="camel">
>>>>>             <camel:template id="camelTemplate"/>
>>>>>         </camel:camelContext>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23863267.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
> 
> 

-- 
View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23866699.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: using ProducerTemplate for JMS with Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 4, 2009 at 5:26 AM, stevenmaring <st...@gmail.com> wrote:
>
> Clause,
>
> I just tried the 2.0-SNAPSHOT released earlier today and got the same thing.
There is something wrong with the Apache snapshot maven repo. Its
maven metadata is wrong.
It wrongly says the last version is a version from 9th april.

You can get a fresh version by downloading the .jar yourself and
install to your local .m2 repo.
Or build the source and install locally.


>
> May I ask for a specific example of what you mean by "use regular setter IoC
> using spring bean property to set the camel producer template"?

Yes its using the spring bean XML wiring

<bean id="foo" class=...>
   <property name="myprop" ref="bar"/>
</bean>

<bean id="bar" class=.../>

In the camel context you give the <camelTemplate> and id so its
<camelTemplate id="template"/>

And then ref to this id from your POJO class.



>
> Thanks,
> Steve Maring
>
>
> Claus Ibsen-2 wrote:
>>
>> Hi
>>
>> I think you are stuck by the bug CAMEL-1663 that causes dependency
>> injection with annotations to not work if you mix annotations from
>> Camel with others.
>> So use regular setter IoC using spring bean property to set the camel
>> producer template.
>>
>> You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
>> version when its build by this time tomorrow.
>>
>> Details at the download page if using maven to get the SNAPSHOT
>> http://camel.apache.org/download.html
>>
>>
>> On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com>
>> wrote:
>>>
>>> I tried putting the template inside the camelContext but it didn't seem
>>> to
>>> help.  I've now read thru a good chunk of the manual, which certainly did
>>> wonders for my understanding of what is going on, but I'm still
>>> scratching
>>> my head over this NullpointerException.  The logs don't seem to be
>>> yelling
>>> at me about anything ...
>>>
>>> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
>>> initialization started
>>> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>> 06:49:01
>>> EDT 2009]; root of context hierarchy
>>> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>> definitions from ServletContext resource
>>> [/WEB-INF/applicationContext.xml]
>>> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>> definitions from class path resource [META-INF/cxf/cxf.xml]
>>> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>> definitions from class path resource
>>> [META-INF/cxf/cxf-extension-soap.xml]
>>> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>>> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
>>> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
>>> application context
>>> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
>>> eligible for getting processed by all BeanPostProcessors (for example:
>>> not
>>> eligible for auto-proxying)
>>> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
>>> InstrumentationLifecycleStrategy.
>>> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created
>>> routes:
>>> []
>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>> eligible for getting processed by all BeanPostProcessors (for example:
>>> not
>>> eligible for auto-proxying)
>>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>>> eligible for getting processed by all BeanPostProcessors (for example:
>>> not
>>> eligible for auto-proxying)
>>> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>> singletons in
>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
>>> defining beans
>>> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
>>> root of factory hierarchy
>>> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>>> 06:49:01
>>> EDT 2009]; root of context hierarchy]
>>> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext now
>>> that the ApplicationContext has started
>>> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
>>> (CamelContext:camel) is starting
>>> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent
>>> on
>>> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
>>> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>> with
>>> objectname: org.apache.camel:context=smaring-dt/camel,name=context
>>> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
>>> (CamelContext:camel) started
>>> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
>>> uri=[spring-event:default], path=[default], parameters=[{}]
>>> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default
>>> converted
>>> to endpoint: Endpoint[spring-event:default] by component:
>>> org.apache.camel.component.event.EventComponent@1f4cf6f
>>> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>>> with
>>> objectname:
>>> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
>>> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
>>> initialization completed in 5938 ms
>>> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
>>> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
>>> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date
>>> [Wed
>>> Jun 03 06:49:07 EDT 2009]; parent:
>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
>>> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for
>>> application
>>> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
>>> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>>> singletons in
>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
>>> defining beans []; parent:
>>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>>> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
>>> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
>>> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
>>> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
>>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
>>> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext now
>>> that the ApplicationContext has started
>>>
>>>
>>> I'm going to try a simple HelloWorld sort of project getting a reference
>>> to
>>> the ProducerTemplate ala ...
>>>
>>> mvn archetype:generate                   \
>>>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>>>  -DarchetypeArtifactId=camel-archetype-spring   \
>>>  -DarchetypeVersion=2.0-M1             \
>>>  -DgroupId=my.sample           \
>>>  -DartifactId=HelloCamel
>>>
>>> hopefully I will either learn something or not get the
>>> NullpointerException
>>> on my reference.
>>>
>>> I'll let ya'll know how it goes ... thank you much for your thoughts so
>>> far
>>>
>>> -Steve Maring
>>>
>>>
>>> Martin Gilday wrote:
>>>>
>>>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>>>
>>>> Claus,
>>>> Do you have to put the template inside the context?  Is this a 2.0
>>>> change?  I've always placed it outside.  As you can't define a context
>>>> ref it seemed effectively singleton and so didn't matter where you
>>>> created it.  This is also how I wrote it in the Camel Spring tutorial on
>>>> the wiki.  If it is considereed incorrect then I can update it.
>>>>
>>>> Thanks,
>>>> Martin
>>>>
>>>>
>>>> ----- Original message -----
>>>> From: "Claus Ibsen" <cl...@gmail.com>
>>>> To: users@camel.apache.org
>>>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>>>> Subject: Re: using ProducerTemplate for JMS with Spring
>>>>
>>>>
>>>> Hi welcome on board the Camel ride.
>>>>
>>>> You almost got it. The camel:template XML tag should be inside the
>>>> camel:context XML tag. So it should be:
>>>>
>>>>         <camel:camelContext id="camel">
>>>>             <camel:template id="camelTemplate"/>
>>>>         </camel:camelContext>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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
>>
>>
>
> --
> View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23863267.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: using ProducerTemplate for JMS with Spring

Posted by stevenmaring <st...@gmail.com>.
Clause,

I just tried the 2.0-SNAPSHOT released earlier today and got the same thing.

May I ask for a specific example of what you mean by "use regular setter IoC
using spring bean property to set the camel producer template"?

Thanks,
Steve Maring


Claus Ibsen-2 wrote:
> 
> Hi
> 
> I think you are stuck by the bug CAMEL-1663 that causes dependency
> injection with annotations to not work if you mix annotations from
> Camel with others.
> So use regular setter IoC using spring bean property to set the camel
> producer template.
> 
> You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
> version when its build by this time tomorrow.
> 
> Details at the download page if using maven to get the SNAPSHOT
> http://camel.apache.org/download.html
> 
> 
> On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com>
> wrote:
>>
>> I tried putting the template inside the camelContext but it didn't seem
>> to
>> help.  I've now read thru a good chunk of the manual, which certainly did
>> wonders for my understanding of what is going on, but I'm still
>> scratching
>> my head over this NullpointerException.  The logs don't seem to be
>> yelling
>> at me about anything ...
>>
>> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
>> initialization started
>> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>> 06:49:01
>> EDT 2009]; root of context hierarchy
>> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>> definitions from ServletContext resource
>> [/WEB-INF/applicationContext.xml]
>> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>> definitions from class path resource [META-INF/cxf/cxf.xml]
>> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>> definitions from class path resource
>> [META-INF/cxf/cxf-extension-soap.xml]
>> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
>> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
>> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
>> application context
>> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
>> eligible for getting processed by all BeanPostProcessors (for example:
>> not
>> eligible for auto-proxying)
>> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
>> InstrumentationLifecycleStrategy.
>> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created
>> routes:
>> []
>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>> eligible for getting processed by all BeanPostProcessors (for example:
>> not
>> eligible for auto-proxying)
>> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
>> eligible for getting processed by all BeanPostProcessors (for example:
>> not
>> eligible for auto-proxying)
>> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>> singletons in
>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
>> defining beans
>> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
>> root of factory hierarchy
>> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
>> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
>> display name [Root WebApplicationContext]; startup date [Wed Jun 03
>> 06:49:01
>> EDT 2009]; root of context hierarchy]
>> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext now
>> that the ApplicationContext has started
>> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
>> (CamelContext:camel) is starting
>> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent
>> on
>> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
>> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>> with
>> objectname: org.apache.camel:context=smaring-dt/camel,name=context
>> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
>> (CamelContext:camel) started
>> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
>> uri=[spring-event:default], path=[default], parameters=[{}]
>> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default
>> converted
>> to endpoint: Endpoint[spring-event:default] by component:
>> org.apache.camel.component.event.EventComponent@1f4cf6f
>> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean
>> with
>> objectname:
>> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
>> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
>> initialization completed in 5938 ms
>> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
>> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
>> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date
>> [Wed
>> Jun 03 06:49:07 EDT 2009]; parent:
>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
>> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for
>> application
>> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
>> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
>> singletons in
>> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
>> defining beans []; parent:
>> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
>> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
>> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
>> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
>> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
>> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
>> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext now
>> that the ApplicationContext has started
>>
>>
>> I'm going to try a simple HelloWorld sort of project getting a reference
>> to
>> the ProducerTemplate ala ...
>>
>> mvn archetype:generate                   \
>>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>>  -DarchetypeArtifactId=camel-archetype-spring   \
>>  -DarchetypeVersion=2.0-M1             \
>>  -DgroupId=my.sample           \
>>  -DartifactId=HelloCamel
>>
>> hopefully I will either learn something or not get the
>> NullpointerException
>> on my reference.
>>
>> I'll let ya'll know how it goes ... thank you much for your thoughts so
>> far
>>
>> -Steve Maring
>>
>>
>> Martin Gilday wrote:
>>>
>>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>>
>>> Claus,
>>> Do you have to put the template inside the context?  Is this a 2.0
>>> change?  I've always placed it outside.  As you can't define a context
>>> ref it seemed effectively singleton and so didn't matter where you
>>> created it.  This is also how I wrote it in the Camel Spring tutorial on
>>> the wiki.  If it is considereed incorrect then I can update it.
>>>
>>> Thanks,
>>> Martin
>>>
>>>
>>> ----- Original message -----
>>> From: "Claus Ibsen" <cl...@gmail.com>
>>> To: users@camel.apache.org
>>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>>> Subject: Re: using ProducerTemplate for JMS with Spring
>>>
>>>
>>> Hi welcome on board the Camel ride.
>>>
>>> You almost got it. The camel:template XML tag should be inside the
>>> camel:context XML tag. So it should be:
>>>
>>>         <camel:camelContext id="camel">
>>>             <camel:template id="camelTemplate"/>
>>>         </camel:camelContext>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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
> 
> 

-- 
View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23863267.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: using ProducerTemplate for JMS with Spring

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

I think you are stuck by the bug CAMEL-1663 that causes dependency
injection with annotations to not work if you mix annotations from
Camel with others.
So use regular setter IoC using spring bean property to set the camel
producer template.

You can try the 2.0m2 when it comes out with the fix, or the -SNAPSHOT
version when its build by this time tomorrow.

Details at the download page if using maven to get the SNAPSHOT
http://camel.apache.org/download.html


On Wed, Jun 3, 2009 at 12:53 PM, stevenmaring <st...@gmail.com> wrote:
>
> I tried putting the template inside the camelContext but it didn't seem to
> help.  I've now read thru a good chunk of the manual, which certainly did
> wonders for my understanding of what is going on, but I'm still scratching
> my head over this NullpointerException.  The logs don't seem to be yelling
> at me about anything ...
>
> 06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
> initialization started
> 06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
> display name [Root WebApplicationContext]; startup date [Wed Jun 03 06:49:01
> EDT 2009]; root of context hierarchy
> 06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
> definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
> 06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
> definitions from class path resource [META-INF/cxf/cxf.xml]
> 06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
> definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
> 06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
> definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
> 06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
> application context
> [org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
> 06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
> eligible for getting processed by all BeanPostProcessors (for example: not
> eligible for auto-proxying)
> 06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
> InstrumentationLifecycleStrategy.
> 06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created routes:
> []
> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
> eligible for getting processed by all BeanPostProcessors (for example: not
> eligible for auto-proxying)
> 06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
> eligible for getting processed by all BeanPostProcessors (for example: not
> eligible for auto-proxying)
> 06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
> singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
> defining beans
> [cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
> root of factory hierarchy
> 06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
> org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
> display name [Root WebApplicationContext]; startup date [Wed Jun 03 06:49:01
> EDT 2009]; root of context hierarchy]
> 06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext now
> that the ApplicationContext has started
> 06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
> (CamelContext:camel) is starting
> 06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent on
> server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
> 06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean with
> objectname: org.apache.camel:context=smaring-dt/camel,name=context
> 06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
> (CamelContext:camel) started
> 06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
> uri=[spring-event:default], path=[default], parameters=[{}]
> 06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default converted
> to endpoint: Endpoint[spring-event:default] by component:
> org.apache.camel.component.event.EventComponent@1f4cf6f
> 06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean with
> objectname:
> org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
> 06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
> initialization completed in 5938 ms
> 06:49:07,737  INFO BusApplicationContext:411 - Refreshing
> org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
> [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date [Wed
> Jun 03 06:49:07 EDT 2009]; parent:
> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
> 06:49:07,815  INFO BusApplicationContext:426 - Bean factory for application
> context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
> 06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
> singletons in
> org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
> defining beans []; parent:
> org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
> 06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
> org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
> display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
> startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
> org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
> 06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext now
> that the ApplicationContext has started
>
>
> I'm going to try a simple HelloWorld sort of project getting a reference to
> the ProducerTemplate ala ...
>
> mvn archetype:generate                   \
>  -DarchetypeGroupId=org.apache.camel.archetypes  \
>  -DarchetypeArtifactId=camel-archetype-spring   \
>  -DarchetypeVersion=2.0-M1             \
>  -DgroupId=my.sample           \
>  -DartifactId=HelloCamel
>
> hopefully I will either learn something or not get the NullpointerException
> on my reference.
>
> I'll let ya'll know how it goes ... thank you much for your thoughts so far
>
> -Steve Maring
>
>
> Martin Gilday wrote:
>>
>> Sorry if this appears twice, my first attempt got rejected as spam :)
>>
>> Claus,
>> Do you have to put the template inside the context?  Is this a 2.0
>> change?  I've always placed it outside.  As you can't define a context
>> ref it seemed effectively singleton and so didn't matter where you
>> created it.  This is also how I wrote it in the Camel Spring tutorial on
>> the wiki.  If it is considereed incorrect then I can update it.
>>
>> Thanks,
>> Martin
>>
>>
>> ----- Original message -----
>> From: "Claus Ibsen" <cl...@gmail.com>
>> To: users@camel.apache.org
>> Date: Wed, 3 Jun 2009 06:22:30 +0200
>> Subject: Re: using ProducerTemplate for JMS with Spring
>>
>>
>> Hi welcome on board the Camel ride.
>>
>> You almost got it. The camel:template XML tag should be inside the
>> camel:context XML tag. So it should be:
>>
>>         <camel:camelContext id="camel">
>>             <camel:template id="camelTemplate"/>
>>         </camel:camelContext>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.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: using ProducerTemplate for JMS with Spring

Posted by stevenmaring <st...@gmail.com>.
I tried putting the template inside the camelContext but it didn't seem to
help.  I've now read thru a good chunk of the manual, which certainly did
wonders for my understanding of what is going on, but I'm still scratching
my head over this NullpointerException.  The logs don't seem to be yelling
at me about anything ...

06:49:01,752  INFO ContextLoader:189 - Root WebApplicationContext:
initialization started
06:49:01,862  INFO XmlWebApplicationContext:411 - Refreshing
org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
display name [Root WebApplicationContext]; startup date [Wed Jun 03 06:49:01
EDT 2009]; root of context hierarchy
06:49:02,018  INFO XmlBeanDefinitionReader:323 - Loading XML bean
definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
06:49:02,471  INFO XmlBeanDefinitionReader:323 - Loading XML bean
definitions from class path resource [META-INF/cxf/cxf.xml]
06:49:02,596  INFO XmlBeanDefinitionReader:323 - Loading XML bean
definitions from class path resource [META-INF/cxf/cxf-extension-soap.xml]
06:49:02,659  INFO XmlBeanDefinitionReader:323 - Loading XML bean
definitions from class path resource [META-INF/cxf/cxf-servlet.xml]
06:49:04,659  INFO XmlWebApplicationContext:426 - Bean factory for
application context
[org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
06:49:05,034  INFO XmlWebApplicationContext:1196 - Bean 'cxf' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
06:49:05,112  INFO DefaultCamelContext:120 - JMX enabled. Using
InstrumentationLifecycleStrategy.
06:49:05,143 DEBUG CamelContextFactoryBean:282 - Found JAXB created routes:
[]
06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
06:49:05,159  INFO XmlWebApplicationContext:1196 - Bean 'camel' is not
eligible for getting processed by all BeanPostProcessors (for example: not
eligible for auto-proxying)
06:49:05,206  INFO DefaultListableBeanFactory:414 - Pre-instantiating
singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589:
defining beans
[cxf,org.apache.cxf.bus.spring.BusApplicationListener,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.transport.servlet.ServletTransportFactory,camelTemplate,camel:beanPostProcessor,camel,imq,voiceGenerator,imqConnectionFactory,voiceGeneratorWS];
root of factory hierarchy
06:49:07,424 DEBUG SpringCamelContext:107 - Publishing spring-event:
org.springframework.context.event.ContextRefreshedEvent[source=org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2:
display name [Root WebApplicationContext]; startup date [Wed Jun 03 06:49:01
EDT 2009]; root of context hierarchy]
06:49:07,424 DEBUG SpringCamelContext:94 - Starting the CamelContext now
that the ApplicationContext has started
06:49:07,424  INFO DefaultCamelContext:729 - Apache Camel 2.0-M1
(CamelContext:camel) is starting
06:49:07,440 DEBUG DefaultInstrumentationAgent:183 - Starting JMX agent on
server: com.sun.jmx.mbeanserver.JmxMBeanServer@e7bb91
06:49:07,534 DEBUG DefaultInstrumentationAgent:247 - Registered MBean with
objectname: org.apache.camel:context=smaring-dt/camel,name=context
06:49:07,549  INFO DefaultCamelContext:771 - Apache Camel 2.0-M1
(CamelContext:camel) started
06:49:07,565 DEBUG DefaultComponent:77 - Creating endpoint
uri=[spring-event:default], path=[default], parameters=[{}]
06:49:07,565 DEBUG DefaultCamelContext:362 - spring-event:default converted
to endpoint: Endpoint[spring-event:default] by component:
org.apache.camel.component.event.EventComponent@1f4cf6f
06:49:07,581 DEBUG DefaultInstrumentationAgent:247 - Registered MBean with
objectname:
org.apache.camel:context=smaring-dt/camel,type=endpoints,name="spring-event:default\?id=0x20a20c46"
06:49:07,706  INFO ContextLoader:209 - Root WebApplicationContext:
initialization completed in 5938 ms
06:49:07,737  INFO BusApplicationContext:411 - Refreshing
org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f: display name
[org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]; startup date [Wed
Jun 03 06:49:07 EDT 2009]; parent:
org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2
06:49:07,815  INFO BusApplicationContext:426 - Bean factory for application
context [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f]:
org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652
06:49:07,893  INFO DefaultListableBeanFactory:414 - Pre-instantiating
singletons in
org.springframework.beans.factory.support.DefaultListableBeanFactory@6f4652:
defining beans []; parent:
org.springframework.beans.factory.support.DefaultListableBeanFactory@baf589
06:49:07,909 DEBUG SpringCamelContext:107 - Publishing spring-event:
org.springframework.context.event.ContextRefreshedEvent[source=org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f:
display name [org.apache.cxf.bus.spring.BusApplicationContext@1a1b2f];
startup date [Wed Jun 03 06:49:07 EDT 2009]; parent:
org.springframework.web.context.support.XmlWebApplicationContext@7eb6e2]
06:49:07,909 DEBUG SpringCamelContext:94 - Starting the CamelContext now
that the ApplicationContext has started


I'm going to try a simple HelloWorld sort of project getting a reference to
the ProducerTemplate ala ...

mvn archetype:generate                   \
  -DarchetypeGroupId=org.apache.camel.archetypes  \
  -DarchetypeArtifactId=camel-archetype-spring   \
  -DarchetypeVersion=2.0-M1             \
  -DgroupId=my.sample           \
  -DartifactId=HelloCamel

hopefully I will either learn something or not get the NullpointerException
on my reference.

I'll let ya'll know how it goes ... thank you much for your thoughts so far

-Steve Maring


Martin Gilday wrote:
> 
> Sorry if this appears twice, my first attempt got rejected as spam :)
> 
> Claus,
> Do you have to put the template inside the context?  Is this a 2.0
> change?  I've always placed it outside.  As you can't define a context
> ref it seemed effectively singleton and so didn't matter where you
> created it.  This is also how I wrote it in the Camel Spring tutorial on
> the wiki.  If it is considereed incorrect then I can update it.
> 
> Thanks,
> Martin
> 
> 
> ----- Original message -----
> From: "Claus Ibsen" <cl...@gmail.com>
> To: users@camel.apache.org
> Date: Wed, 3 Jun 2009 06:22:30 +0200
> Subject: Re: using ProducerTemplate for JMS with Spring
> 
> 
> Hi welcome on board the Camel ride.
> 
> You almost got it. The camel:template XML tag should be inside the
> camel:context XML tag. So it should be:
> 
>         <camel:camelContext id="camel">
>             <camel:template id="camelTemplate"/>
>         </camel:camelContext>
> 
> 

-- 
View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23849357.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: using ProducerTemplate for JMS with Spring

Posted by Martin Gilday <ma...@imap.cc>.
Sorry if this appears twice, my first attempt got rejected as spam :)

Claus,
Do you have to put the template inside the context?  Is this a 2.0
change?  I've always placed it outside.  As you can't define a context
ref it seemed effectively singleton and so didn't matter where you
created it.  This is also how I wrote it in the Camel Spring tutorial on
the wiki.  If it is considereed incorrect then I can update it.

Thanks,
Martin


----- Original message -----
From: "Claus Ibsen" <cl...@gmail.com>
To: users@camel.apache.org
Date: Wed, 3 Jun 2009 06:22:30 +0200
Subject: Re: using ProducerTemplate for JMS with Spring


Hi welcome on board the Camel ride.

You almost got it. The camel:template XML tag should be inside the
camel:context XML tag. So it should be:

        <camel:camelContext id="camel">
            <camel:template id="camelTemplate"/>
        </camel:camelContext>

Re: using ProducerTemplate for JMS with Spring

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jun 2, 2009 at 11:04 PM, stevenmaring <st...@gmail.com> wrote:
>
> I'm probably doing something stupidly wrong here but I can't seem to figure
> it out.  I keep getting a NullPointerException when I try to use my
> camelTemplate property in my class.  I think, perhaps, I'm not understanding
> how camel:template gets instrumented by JmsComponent, but I can't find the
> documentation on this.
>

Hi welcome on board the Camel ride.

You almost got it. The camel:template XML tag should be inside the
camel:context XML tag. So it should be:

        <camel:camelContext id="camel">
            <camel:template id="camelTemplate"/>
        </camel:camelContext>



>
>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xmlns:jaxws="http://cxf.apache.org/jaxws"
>       xmlns:camel="http://camel.apache.org/schema/spring"
>       xmlns:context="http://www.springframework.org/schema/context"
>       xmlns:jee="http://www.springframework.org/schema/jee"
>       xsi:schemaLocation="
>       http://www.springframework.org/schema/beans
>       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
>       http://cxf.apache.org/jaxws
>       http://cxf.apache.org/schemas/jaxws.xsd
>       http://camel.apache.org/schema/spring
>       http://camel.apache.org/schema/spring/camel-spring.xsd
>       http://www.springframework.org/schema/context
>       http://www.springframework.org/schema/context/spring-context-2.5.xsd
>       http://activemq.apache.org/camel/schema/spring
>       http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
>       http://www.springframework.org/schema/jee
>       http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
>
>
>        <import resource="classpath:META-INF/cxf/cxf.xml" />
>        <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
>        <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
>
>        <camel:camelContext id="camel"/>
>        <camel:template id="camelTemplate"/>
>
>        <bean id="imq" class="org.apache.camel.component.jms.JmsComponent">
>                <property name="connectionFactory" ref="imqConnectionFactory"/>
>        </bean>
>
>        <bean id="voiceGenerator" class="com.ess.tts.ws.VoiceGeneratorService">
>                <property name="camelTemplate" ref="camelTemplate"/>
>        </bean>
>
>        <bean id="imqConnectionFactory"
> class="com.ess.tts.engine.util.IMQConnectionFactory">
>                <property name="hostname" value="localhost" />
>                <property name="port" value="7676" />
>                <property name="username" value="admin" />
>                <property name="password" value="admin" />
>        </bean>
>
>
>        <jaxws:endpoint
>                id="voiceGeneratorWS"
>                implementor="com.ess.tts.ws.VoiceGeneratorService"
>                address="/voiceGeneratorService"
>        />
>
> </beans>
>
>
> @WebService(endpointInterface="com.ess.tts.ws.VoiceGenerator",
>                serviceName="VoiceGeneratorService",
>                portName="VoiceGeneratorPort")
> public class VoiceGeneratorService implements VoiceGenerator {
>
>        private static Logger log =
> LoggerFactory.getLogger(VoiceGeneratorService.class);
>
>        private ProducerTemplate camelTemplate;
>
>        public void generateVoice(TTSAudioConfig audioConfig) {
>                camelTemplate.sendBody("imq:queue:voiceRequestQueue",
> ExchangePattern.InOut, audioConfig);
>        }
>
>        public ProducerTemplate getCamelTemplate() {
>                return camelTemplate;
>        }
>
>        public void setCamelTemplate(ProducerTemplate camelTemplate) {
>                this.camelTemplate = camelTemplate;
>        }
>
> }
>
>
> -Steve Maring
>
> --
> View this message in context: http://www.nabble.com/using-ProducerTemplate-for-JMS-with-Spring-tp23840855p23840855.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