5 Replies Latest reply on Feb 14, 2011 10:55 AM by Divakar B

    Issue with properties component

    Divakar B Newbie

      Hi,

       

      I am reading the properties file using PropertyPlaceholderConfigurer and when trying to set those values in the properties present inside the camel context getting exception.

       

      Accessing the properties file in the following manner:

      <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

      <property name="location" value="classpath:com/resources/common.properties"/>

      </bean>

       

      I am trying to set the values inside the camel context properties as below:

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

      <route>

      <from uri="nmr:xxx"/>

      <setProperty propertyName="com.userWSName">

      <simple>$</simple> </setProperty> <to uri="direct:yyy"/> </route> </camel:camelContext> The exception occured is: org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route route60 at: >>> SetProperty[http://com.userWSName, simple{$}|http://com.userwsname,%20simple%7b$%7busername%7d%7d/] <<< in route: Route[[From[nmr:xxx]|http://fusesource.com/forums/] -> [To[... because of Illegal syntax: username

      at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:103)75:org.apache.camel.camel-spring:2.6.0.fuse-00-00

      at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:237)75:org.apache.camel.camel-spring:2.6.0.fuse-00-00

      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)61:org.springframework.context:3.0.5.RELEASE

      at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)61:org.springframework.context:3.0.5.RELEASE

      at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911)61:org.springframework.context:3.0.5.RELEASE

      at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.finishRefresh(AbstractOsgiBundleApplicationContext.java:235)71:org.springframework.osgi.core:1.2.0

      at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:358)71:org.springframework.osgi.core:1.2.0

      at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)71:org.springframework.osgi.core:1.2.0

      at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)71:org.springframework.osgi.core:1.2.0

      at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:136)72:org.springframework.osgi.extender:1.2.0

      at java.lang.Thread.run(Thread.java:619):1.6.0_18

      Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route60 at: >>> SetProperty[http://com.userWSName, simple{${username}}|http://com.userwsname,%20simple%7b$%7busername%7d%7d/] <<< in route: Route[[From[nmr:xxx]|http://fusesource.com/forums/] -> [To[... because of Illegal syntax: username

      at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:701)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1623)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)75:org.apache.camel.camel-spring:2.6.0.fuse-00-00

      at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)75:org.apache.camel.camel-spring:2.6.0.fuse-00-00

      at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)75:org.apache.camel.camel-spring:2.6.0.fuse-00-00

      ... 10 more

      Caused by: org.apache.camel.ExpressionIllegalSyntaxException: Illegal syntax: username

      at org.apache.camel.language.simple.SimpleLanguage.createSimpleExpression(SimpleLanguage.java:314)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.language.simple.SimpleLanguageSupport.createComplexConcatExpression(SimpleLanguageSupport.java:318)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.language.simple.SimpleLanguageSupport.createExpression(SimpleLanguageSupport.java:92)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.language.ExpressionDefinition.createExpression(ExpressionDefinition.java:171)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.language.ExpressionDefinition.createExpression(ExpressionDefinition.java:161)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.SetPropertyDefinition.createProcessor(SetPropertyDefinition.java:72)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)68:org.apache.camel.camel-core:2.6.0.fuse-00-00

      ... 21 more

       

      Regards,

      V. Arvind

       

       

        • 1. Re: Issue with properties component
          Claus Ibsen Master

          Spring Framework's property placeholder is very limited. See the FAQ at the Camel website when it's back online.

           

          Basically you cannot use spring placeholders inside the  outside the route which can have placeholders.

           

          If you use the Camel properties component, then it works everywhere in the routes.

          If you have the Camel book, then check chapter 6, section 6.1.6

          • 2. Re: Issue with properties component
            Divakar B Newbie

            We are using camel properties compenents and trying to read properties from another bundle which we have imported. When we are using org.springframework.beans.factory.config.PropertyPlaceholderConfigurer we are able to locate the properties file and retrieve its values. But when we are using org.apache.camel.component.properties.PropertiesComponent we are not able locate the properties file and set the values to the properties inside the route. During that time we are getting exception

             

            Properties Loader:

            $ [To[... because of org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XSL_MessagePartner': FactoryBean threw exception on object creation; nested exception is org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: xsl

            t:{{XslBaseUri}}partner/xxx/zzz/Message-Request.xsl?uriResolver=myResolver&transformerFactory=tFactory due to: Properties file com/common/resources/common.properties not found in classpath

                    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:759)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:160)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:701)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1623)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1412)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1321)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:164)[75:org.apache.camel.camel-spring:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1299)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)[75:org.apache.camel.camel-spring:2.6.0.fuse-00-00]

                    at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)[75:org.apache.camel.camel-spring:2.6.0.fuse-00-00]

                    ... 10 more

            Caused by: org.apache.camel.RuntimeCamelException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XSL_IncidentMessageCM

            IS': FactoryBean threw exception on object creation; nested exception is org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: xslt:{{Xsl

            BaseUri}}partner/xxx/zzz/Message-Request.xsl?uriResolver=myResolver&transformerFactory=tFactory due to: Properties file com/common/resources/common.properties not found in classpath

                    at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1139)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:56)[68:org.apache.camel.camel-core:2.6.0.fu

            se-00-00]

                    at org.apache.camel.impl.DefaultRouteContext.lookup(DefaultRouteContext.java:139)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:122)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:64)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:58)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:403)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:174)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:756)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    ... 21 more

            Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XSL_MessagePartner': FactoryBean threw exception on obje

            ct creation; nested exception is org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: xslt:{{XslBaseUri}}partner/xxx/zzz/Message-Request.xsl?uriResolver=myResolver&transformerFactory=tFactory due to: Properties file com/common/resources/common.propertie

            s not found in classpath

                    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)[59:org.springfra

            mework.beans:3.0.5.RELEASE]

                    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)[59:org.springframe

            work.beans:3.0.5.RELEASE]

                    at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1429)[59:org.springframework.beans:3.

            0.5.RELEASE]

                    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:245)[59:org.springframework.beans:3.0.5.RELEASE]

                    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)[59:org.springframework.beans:3.0.5.RELEASE]

                    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1079)[61:org.springframework.context:3.0.5.REL

            EASE]

                    at org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:41)[75:org.apache.camel.camel-spring:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.CompositeRegistry.lookup(CompositeRegistry.java:47)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:54)[68:org.apache.camel.camel-core:2.6.0.fu

            se-00-00]

                    ... 28 more

            Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: xslt:{{XslBaseUri}}partner/xxx/zzz/Message-Request.xsl?uriResolver=myResolver&transformerFactory=tFactory due to: Properties file com/common/resources/common.properties not found in classpa

            th

                    at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:406)[68:org.apache.camel.camel-core:2.6.0.fuse-00-00]

                    at org.apache.camel.core.xml.AbstractCamelEndpointFacto

             

            Edited by: divakar on Feb 15, 2011 8:47 AM

            • 3. Re: Issue with properties component
              Claus Ibsen Master

              You need to import those classpaths in your bundle, as they are loaded from the classpath, and thus you are under the mercy of OSGi

              • 4. Re: Issue with properties component
                Claus Ibsen Master

                And the bundle which has the files, must export those packages, so other bundles can import them.

                • 5. Re: Issue with properties component
                  Divakar B Newbie

                  Yes that particular bundle which we have imported has exported those packages in there pom file.

                   

                  We are currently using SMX 4.3.1

                   

                   

                  Regards