camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sven Nold (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CAMEL-7488) PropertiesComponent gets initialized by util:constant
Date Wed, 11 Jun 2014 08:14:03 GMT

    [ https://issues.apache.org/jira/browse/CAMEL-7488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14027532#comment-14027532
] 

Sven Nold edited comment on CAMEL-7488 at 6/11/14 8:13 AM:
-----------------------------------------------------------

Hi Willem,

I already had that setting enabled, but even with 2.13-SNAPSHOT no luck.
If you enable tracing you can see lines like:


[pache.camel.spring.Main.main()] CamelContextFactoryBean        INFO  Bridging Camel and Spring
property placeholder configurer with id: bridgePropertyPlaceHolder
[pache.camel.spring.Main.main()] SpringCamelContext             DEBUG Using ComponentResolver:
org.apache.camel.impl.DefaultComponentResolver@70ff4bfb to resolve component with name: properties
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     TRACE No bean named 'properties'
found in org.springframework.beans.factory.support.DefaultListableBeanFactory@4b37f3f9: defining
beans [ag.isb.camel.Constants.CONSTANT_1,bridgePropertyPlaceHolder,template,consumerTemplate,camel-1:beanPostProcessor,camel-1];
root of factory hierarchy
[pache.camel.spring.Main.main()] DefaultComponentResolver       DEBUG Found component: properties
in registry: null
[pache.camel.spring.Main.main()] ObjectHelper                   TRACE Loading class: org.apache.camel.component.properties.PropertiesComponent
using classloader: java.net.URLClassLoader@154f6189
[pache.camel.spring.Main.main()] DefaultComponentResolver       DEBUG Found component: properties
via type: org.apache.camel.component.properties.PropertiesComponent via: META-INF/services/org/apache/camel/component/properties
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Creating instance of
bean 'org.apache.camel.component.properties.PropertiesComponent'
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance
of singleton bean 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
after initialization for bean: ag.isb.camel.Constants.CONSTANT_1
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Autowiring by type from
bean name 'org.apache.camel.component.properties.PropertiesComponent' via constructor to bean
named 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance
of singleton bean 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
after initialization for bean: ag.isb.camel.Constants.CONSTANT_1
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG *Autowiring by type
from bean name 'org.apache.camel.component.properties.PropertiesComponent' via constructor
to bean named 'ag.isb.camel.Constants.CONSTANT_1'*
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
before initialization for bean: org.apache.camel.component.properties.PropertiesComponent

Why is it doing that?


was (Author: svennold):
Hi Willem,

I already had that setting enabled, but even with 2.13-SNAPSHOT no luck.
If you enable tracing you can see lines like:


[pache.camel.spring.Main.main()] CamelContextFactoryBean        INFO  Bridging Camel and Spring
property placeholder configurer with id: bridgePropertyPlaceHolder
[pache.camel.spring.Main.main()] SpringCamelContext             DEBUG Using ComponentResolver:
org.apache.camel.impl.DefaultComponentResolver@70ff4bfb to resolve component with name: properties
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     TRACE No bean named 'properties'
found in org.springframework.beans.factory.support.DefaultListableBeanFactory@4b37f3f9: defining
beans [ag.isb.camel.Constants.CONSTANT_1,bridgePropertyPlaceHolder,template,consumerTemplate,camel-1:beanPostProcessor,camel-1];
root of factory hierarchy
[pache.camel.spring.Main.main()] DefaultComponentResolver       DEBUG Found component: properties
in registry: null
[pache.camel.spring.Main.main()] ObjectHelper                   TRACE Loading class: org.apache.camel.component.properties.PropertiesComponent
using classloader: java.net.URLClassLoader@154f6189
[pache.camel.spring.Main.main()] DefaultComponentResolver       DEBUG Found component: properties
via type: org.apache.camel.component.properties.PropertiesComponent via: META-INF/services/org/apache/camel/component/properties
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Creating instance of
bean 'org.apache.camel.component.properties.PropertiesComponent'
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance
of singleton bean 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
after initialization for bean: ag.isb.camel.Constants.CONSTANT_1
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Autowiring by type from
bean name 'org.apache.camel.component.properties.PropertiesComponent' via constructor to bean
named 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG Returning cached instance
of singleton bean 'ag.isb.camel.Constants.CONSTANT_1'
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
after initialization for bean: ag.isb.camel.Constants.CONSTANT_1
[pache.camel.spring.Main.main()] DefaultListableBeanFactory     DEBUG *Autowiring by type
from bean name 'org.apache.camel.component.properties.PropertiesComponent' via constructor
to bean named 'ag.isb.camel.Constants.CONSTANT_1'*
[pache.camel.spring.Main.main()] DefaultCamelBeanPostProcessor  TRACE Camel bean processing
before initialization for bean: org.apache.camel.component.properties.PropertiesComponent



> PropertiesComponent gets initialized by util:constant
> -----------------------------------------------------
>
>                 Key: CAMEL-7488
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7488
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-spring
>    Affects Versions: 2.13.0, 2.13.1
>            Reporter: Sven Nold
>            Assignee: Willem Jiang
>         Attachments: camel-test.zip
>
>
> Using BridgePropertyPlaceholderConfigurer & Spring util constant namespace  to reference
a static field, the Properties Component gets initialized with this constant.
> {code:xml|title=camelContext.xml }
> <util:constant static-field="anypackage.CONSTANT_1"/>
> <bean id="bridgePropertyPlaceHolder" class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
>     <property name="locations">
>       <list>
>         <value>classpath:test.properties</value>
>       </list>
>     </property>
> </bean>
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
>     <camel:route>
>       <camel:from uri="direct://ignore" />
>       <camel:setBody>
>         <camel:simple>{{testProperty}}</camel:simple>
>       </camel:setBody>
>       <camel:to uri="mock://ignore" />
>     </camel:route>
> </camel:camelContext>   
> {code}
> Will produce following Stacktrace (constant contained '>>This will be loaded as
location; but I am simply a constant<<'):
> {noformat}
> Caused by: java.io.FileNotFoundException: Properties file >>This will be loaded
as location; but I am simply a constant<< not found in classpath
> 	at org.apache.camel.component.properties.DefaultPropertiesResolver.loadPropertiesFromClasspath(DefaultPropertiesResolver.java:96)
> 	at org.apache.camel.component.properties.DefaultPropertiesResolver.resolveProperties(DefaultPropertiesResolver.java:55)
> 	at org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.resolveProperties(BridgePropertyPlaceholderConfigurer.java:118)
> 	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:131)
> 	at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:117)
> 	at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1223)
> 	at org.apache.camel.model.ProcessorDefinition.resolvePropertyPlaceholders(ProcessorDefinition.java:571)
> {noformat}
> My current workaround was to specify propertyPlaceholder with empty location in  camelContext
...
> {code:xml|title=camelContext.xml }
> <!-- same as above -->
> <camel:camelContext xmlns="http://camel.apache.org/schema/spring">
>     <!-- location and id are mandatory -->
>     <camel:propertyPlaceholder id="stupidMandatoryId" location=""/>
>     <camel:route>
>       <camel:from uri="direct://ignore" />
>       <camel:setBody>
>         <camel:simple>{{testProperty}}</camel:simple>
>       </camel:setBody>
>       <camel:to uri="mock://ignore" />
>     </camel:route>
> </camel:camelContext>   
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message