You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by HockeyDave <da...@yahoo.com> on 2008/11/11 23:14:48 UTC

config.properties substitution into applicationcontext.xml

I'd like to extract out some Camel URI settings from Spring
applicationContext.xml into a config.properties to make it easier to manage
and more obvious to the IT deployment person what has to be customized in
the production environment.  However, if I try using property values, I get
an exception in that it tries to interpret the ${property} as a string.

config.properties
fromEmailServerUri=imap://user@server.company.corp:143?password=abcde&amp;consumer.delay=3600000&amp;processOnlyUnseenMessages=true&amp;deleteProcessedMessages=false


applicationContext.xml
	<context:property-placeholder location="classpath:config.properties" />
	
	<camel:camelContext id="camel">
		<camel:route>
			<!--
				Poll every hour
				&amp;deleteProcessedMessages=true&amp;debugMode=true&amp;
			-->
			<camel:from uri="${fromEmailServerUri}" />
			<camel:to uri="bean:mailReader" />
		</camel:route>
	</camel:camelContext>

Exception in thread "main" org.apache.camel.NoSuchEndpointException: No
endpoint could be found for: ${fromEmailServerUri}
	at
org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
	at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:100)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:102)
	at
org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
	at org.apache.camel.model.FromType.resolveEndpoint(FromType.java:73)
	at
org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:77)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:214)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:90)
	at
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:537)
	at
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:529)
	at
org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:149)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
	at
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
	at
org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
	at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
	at
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:275)
	at
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:737)
	at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384)
	at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
	at
org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
	at com.contextweb.file.FolderWatcher.main(FolderWatcher.java:237)

-- 
View this message in context: http://www.nabble.com/config.properties-substitution-into-applicationcontext.xml-tp20449629s22882p20449629.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: config.properties substitution into applicationcontext.xml

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

No I don't think its a bug.

I think you have to use an endpoint and use the ref in the route
<endpoint id="mailServer" uri="${fromEmailServerUri}"/>

And then in the route you use:
<camel:from ref="mailServer" />


On Wed, Nov 12, 2008 at 2:02 PM, Hadrian Zbarcea <hz...@gmail.com> wrote:
> This sounds like a bug.  Could you please log an issue for this?
>
> Thanks
> Hadrian
>
> On Nov 11, 2008, at 5:14 PM, HockeyDave wrote:
>
>>
>> I'd like to extract out some Camel URI settings from Spring
>> applicationContext.xml into a config.properties to make it easier to
>> manage
>> and more obvious to the IT deployment person what has to be customized in
>> the production environment.  However, if I try using property values, I
>> get
>> an exception in that it tries to interpret the ${property} as a string.
>>
>> config.properties
>>
>> fromEmailServerUri=imap://user@server.company.corp:143?password=abcde&amp;consumer.delay=3600000&amp;processOnlyUnseenMessages=true&amp;deleteProcessedMessages=false
>>
>>
>> applicationContext.xml
>>        <context:property-placeholder
>> location="classpath:config.properties" />
>>
>>        <camel:camelContext id="camel">
>>                <camel:route>
>>                        <!--
>>                                Poll every hour
>>
>>  &amp;deleteProcessedMessages=true&amp;debugMode=true&amp;
>>                        -->
>>                        <camel:from uri="${fromEmailServerUri}" />
>>                        <camel:to uri="bean:mailReader" />
>>                </camel:route>
>>        </camel:camelContext>
>>
>> Exception in thread "main" org.apache.camel.NoSuchEndpointException: No
>> endpoint could be found for: ${fromEmailServerUri}
>>        at
>>
>> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
>>        at
>> org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:100)
>>        at
>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:102)
>>        at
>>
>> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
>>        at
>> org.apache.camel.model.FromType.resolveEndpoint(FromType.java:73)
>>        at
>>
>> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:77)
>>        at org.apache.camel.model.RouteType.addRoutes(RouteType.java:214)
>>        at org.apache.camel.model.RouteType.addRoutes(RouteType.java:90)
>>        at
>>
>> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:537)
>>        at
>>
>> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:529)
>>        at
>>
>> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:149)
>>        at
>> org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
>>        at
>>
>> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
>>        at
>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>>        at
>>
>> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>>        at
>>
>> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>>        at
>>
>> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:275)
>>        at
>>
>> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:737)
>>        at
>>
>> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384)
>>        at
>>
>> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
>>        at
>>
>> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
>>        at com.contextweb.file.FolderWatcher.main(FolderWatcher.java:237)
>>
>> --
>> View this message in context:
>> http://www.nabble.com/config.properties-substitution-into-applicationcontext.xml-tp20449629s22882p20449629.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/

Re: config.properties substitution into applicationcontext.xml

Posted by Hadrian Zbarcea <hz...@gmail.com>.
This sounds like a bug.  Could you please log an issue for this?

Thanks
Hadrian

On Nov 11, 2008, at 5:14 PM, HockeyDave wrote:

>
> I'd like to extract out some Camel URI settings from Spring
> applicationContext.xml into a config.properties to make it easier to  
> manage
> and more obvious to the IT deployment person what has to be  
> customized in
> the production environment.  However, if I try using property  
> values, I get
> an exception in that it tries to interpret the ${property} as a  
> string.
>
> config.properties
> fromEmailServerUri=imap://user@server.company.corp:143? 
> password 
> = 
> abcde 
> &amp 
> ;consumer 
> .delay 
> = 
> 3600000 
> &amp;processOnlyUnseenMessages=true&amp;deleteProcessedMessages=false
>
>
> applicationContext.xml
> 	<context:property-placeholder  
> location="classpath:config.properties" />
> 	
> 	<camel:camelContext id="camel">
> 		<camel:route>
> 			<!--
> 				Poll every hour
> 				&amp;deleteProcessedMessages=true&amp;debugMode=true&amp;
> 			-->
> 			<camel:from uri="${fromEmailServerUri}" />
> 			<camel:to uri="bean:mailReader" />
> 		</camel:route>
> 	</camel:camelContext>
>
> Exception in thread "main" org.apache.camel.NoSuchEndpointException:  
> No
> endpoint could be found for: ${fromEmailServerUri}
> 	at
> org 
> .apache 
> .camel 
> .util 
> .CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
> 	at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java: 
> 100)
> 	at
> org 
> .apache 
> .camel 
> .impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java: 
> 102)
> 	at
> org 
> .apache 
> .camel 
> .impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java: 
> 108)
> 	at org.apache.camel.model.FromType.resolveEndpoint(FromType.java:73)
> 	at
> org 
> .apache 
> .camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java: 
> 77)
> 	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:214)
> 	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:90)
> 	at
> org 
> .apache 
> .camel 
> .impl 
> .DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java: 
> 537)
> 	at
> org 
> .apache 
> .camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:529)
> 	at
> org 
> .apache 
> .camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:149)
> 	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
> 	at
> org 
> .apache 
> .camel 
> .spring 
> .SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
> 	at
> org.springframework.context.event.SimpleApplicationEventMulticaster 
> $1.run(SimpleApplicationEventMulticaster.java:78)
> 	at
> org 
> .springframework 
> .core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
> 	at
> org 
> .springframework 
> .context 
> .event 
> .SimpleApplicationEventMulticaster 
> .multicastEvent(SimpleApplicationEventMulticaster.java:76)
> 	at
> org 
> .springframework 
> .context 
> .support 
> .AbstractApplicationContext 
> .publishEvent(AbstractApplicationContext.java:275)
> 	at
> org 
> .springframework 
> .context 
> .support 
> .AbstractApplicationContext 
> .finishRefresh(AbstractApplicationContext.java:737)
> 	at
> org 
> .springframework 
> .context 
> .support 
> .AbstractApplicationContext.refresh(AbstractApplicationContext.java: 
> 384)
> 	at
> org 
> .springframework 
> .context 
> .support 
> .FileSystemXmlApplicationContext 
> .<init>(FileSystemXmlApplicationContext.java:140)
> 	at
> org 
> .springframework 
> .context 
> .support 
> .FileSystemXmlApplicationContext 
> .<init>(FileSystemXmlApplicationContext.java:84)
> 	at com.contextweb.file.FolderWatcher.main(FolderWatcher.java:237)
>
> -- 
> View this message in context: http://www.nabble.com/config.properties-substitution-into-applicationcontext.xml-tp20449629s22882p20449629.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


Re: config.properties substitution into applicationcontext.xml

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

See the FAQ:
http://activemq.apache.org/camel/how-do-i-use-spring-property-placeholder-with-camel-xml.html
you can do it somehow.

There issue to fully support spring property placeholders is tracked
in a ticket:
http://issues.apache.org/activemq/browse/CAMEL-1066

Basically it requires Spring 3.0 to be possible from Spring let custom
namespace handlers support this also.

/Claus


On Tue, Nov 11, 2008 at 11:14 PM, HockeyDave
<da...@yahoo.com> wrote:
>
> I'd like to extract out some Camel URI settings from Spring
> applicationContext.xml into a config.properties to make it easier to manage
> and more obvious to the IT deployment person what has to be customized in
> the production environment.  However, if I try using property values, I get
> an exception in that it tries to interpret the ${property} as a string.
>
> config.properties
> fromEmailServerUri=imap://user@server.company.corp:143?password=abcde&consumer.delay=3600000&processOnlyUnseenMessages=true&deleteProcessedMessages=false
>
>
> applicationContext.xml
>        <context:property-placeholder location="classpath:config.properties" />
>
>        <camel:camelContext id="camel">
>                <camel:route>
>                        <!--
>                                Poll every hour
>                                &deleteProcessedMessages=true&debugMode=true&
>                        -->
>                        <camel:from uri="${fromEmailServerUri}" />
>                        <camel:to uri="bean:mailReader" />
>                </camel:route>
>        </camel:camelContext>
>
> Exception in thread "main" org.apache.camel.NoSuchEndpointException: No
> endpoint could be found for: ${fromEmailServerUri}
>        at
> org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:54)
>        at org.apache.camel.model.RouteType.resolveEndpoint(RouteType.java:100)
>        at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:102)
>        at
> org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108)
>        at org.apache.camel.model.FromType.resolveEndpoint(FromType.java:73)
>        at
> org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:77)
>        at org.apache.camel.model.RouteType.addRoutes(RouteType.java:214)
>        at org.apache.camel.model.RouteType.addRoutes(RouteType.java:90)
>        at
> org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:537)
>        at
> org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:529)
>        at
> org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:149)
>        at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:47)
>        at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)
>        at
> org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
>        at
> org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
>        at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
>        at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:275)
>        at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:737)
>        at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:384)
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
>        at
> org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
>        at com.contextweb.file.FolderWatcher.main(FolderWatcher.java:237)
>
> --
> View this message in context: http://www.nabble.com/config.properties-substitution-into-applicationcontext.xml-tp20449629s22882p20449629.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 

/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/