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

Ronny Aerts commented on CAMEL-11523:
-------------------------------------

I attached a test case project.
It will give following output when it runs:
{code}
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.intris.TrisESB.route.test.TrisESBTest
2017-08-01 10:54:03.749 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
********************************************************************************
2017-08-01 10:54:03.750 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
Testing: TestJasypt(com.intris.TrisESB.route.test.TrisESBTest)
2017-08-01 10:54:03.750 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
********************************************************************************
2017-08-01 10:54:03.790 [INFO ] 
[org.springframework.context.support.ClassPathXmlApplicationContext] Refreshing 
org.springframework.context.support.ClassPathXmlApplicationContext@685cb137: 
startup date [Tue Aug 01 10:54:03 CEST 2017]; root of context hierarchy
2017-08-01 10:54:03.827 [INFO ] 
[org.springframework.beans.factory.xml.XmlBeanDefinitionReader] Loading XML 
bean definitions from class path resource [test-camel-context.xml]
2017-08-01 10:54:05.233 [INFO ] 
[org.apache.camel.spring.CamelContextFactoryBean] Bridging Camel and Spring 
property placeholder configurer with id: properties
2017-08-01 10:54:05.257 [INFO ] [org.apache.camel.spring.SpringCamelContext] 
Apache Camel 2.19.2 (CamelContext: tester) is starting
2017-08-01 10:54:05.258 [INFO ] 
[org.apache.camel.management.DefaultManagementStrategy] JMX is disabled
2017-08-01 10:54:05.298 [INFO ] 
[org.apache.camel.impl.converter.DefaultTypeConverter] Loaded 196 type 
converters
2017-08-01 10:54:05.356 [DEBUG] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Found property: 
rrts.pw.plain with value: this is the password to be used.
2017-08-01 10:54:05.356 [TRACE] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Parsing property 
'rrts.pw.plain=this is the password'
2017-08-01 10:54:05.364 [DEBUG] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Initialized 
encryptor using PBEWITHSHA1ANDRC4_128 algorithm and provided password
2017-08-01 10:54:05.368 [DEBUG] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Found property: 
rrts.pw.encrypted with value: ENC(vNEH1/wOEbwgZ28+1jLzpFlUHTqZm8Zwirq5Ww==) to 
be used.
2017-08-01 10:54:05.368 [TRACE] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Parsing property 
'rrts.pw.encrypted=ENC(vNEH1/wOEbwgZ28+1jLzpFlUHTqZm8Zwirq5Ww==)'
2017-08-01 10:54:05.368 [TRACE] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Decrypting part 
'ENC(vNEH1/wOEbwgZ28+1jLzpFlUHTqZm8Zwirq5Ww==)'
2017-08-01 10:54:05.768 [TRACE] 
[org.apache.camel.component.jasypt.JasyptPropertiesParser] Parsing property 
'dummy.property:this is the default value=null'
2017-08-01 10:54:05.769 [INFO ] [org.apache.camel.spring.SpringCamelContext] 
Apache Camel 2.19.2 (CamelContext: tester) is shutting down
2017-08-01 10:54:05.786 [INFO ] [org.apache.camel.spring.SpringCamelContext] 
Apache Camel 2.19.2 (CamelContext: tester) uptime 0.528 seconds
2017-08-01 10:54:05.786 [INFO ] [org.apache.camel.spring.SpringCamelContext] 
Apache Camel 2.19.2 (CamelContext: tester) is shutdown in 0.016 seconds
2017-08-01 10:54:05.788 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
********************************************************************************
2017-08-01 10:54:05.788 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
Testing done: TestJasypt(com.intris.TrisESB.route.test.TrisESBTest)
2017-08-01 10:54:05.788 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
Took: 2.042 seconds (2042 millis)
2017-08-01 10:54:05.788 [INFO ] [com.intris.TrisESB.route.test.TrisESBTest] 
********************************************************************************
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 2.168 sec <<< 
FAILURE!
TestJasypt(com.intris.TrisESB.route.test.TrisESBTest)  Time elapsed: 2.047 sec  
<<< ERROR!
org.apache.camel.RuntimeCamelException: 
org.apache.camel.FailedToCreateRouteException: Failed to create route 
test.jasypt.route at: >>> Log[dummy properties with default 
value={{dummy.property:this is the default value}}] <<< in route: 
Route(test.jasypt.route)[[From[direct://test.jasypt.entry]] ... because of 
PropertiesComponent with name properties must be defined in CamelContext to 
support property placeholders. Property with key [dummy.property:this is the 
default value] not found in properties from text: dummy properties with default 
value={{dummy.property:this is the default value}}
        at 
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1774)
        at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:138)
        at 
org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:361)
        at 
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
        at 
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
        at 
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)
        at 
org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)
        at 
org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)
        at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546)
        at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at 
org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
        at 
com.intris.TrisESB.route.test.TrisESBTest.createCamelContext(TrisESBTest.java:34)
        at 
org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:294)
        at 
org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:252)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
        at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at 
org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at 
org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at 
org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at 
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at 
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create 
route test.jasypt.route at: >>> Log[dummy properties with default 
value={{dummy.property:this is the default value}}] <<< in route: 
Route(test.jasypt.route)[[From[direct://test.jasypt.entry]] ... because of 
PropertiesComponent with name properties must be defined in CamelContext to 
support property placeholders. Property with key [dummy.property:this is the 
default value] not found in properties from text: dummy properties with default 
value={{dummy.property:this is the default value}}
        at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1298)
        at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204)
        at 
org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1087)
        at 
org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3540)
        at 
org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3271)
        at 
org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:202)
        at 
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3089)
        at 
org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3085)
        at 
org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3108)
        at 
org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3085)
        at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
        at 
org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3022)
        at 
org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:275)
        at 
org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:136)
        ... 46 more
Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name 
properties must be defined in CamelContext to support property placeholders. 
Property with key [dummy.property:this is the default value] not found in 
properties from text: dummy properties with default value={{dummy.property:this 
is the default value}}
        at 
org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:271)
        at 
org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:157)
        at 
org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:116)
        at 
org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:100)
        at 
org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:63)
        at 
org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:55)
        at 
org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer$BridgePropertiesParser.parseUri(BridgePropertyPlaceholderConfigurer.java:262)
        at 
org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer.parseUri(BridgePropertyPlaceholderConfigurer.java:167)
        at 
org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:230)
        at 
org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:173)
        at 
org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:2411)
        at 
org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:735)
        at 
org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:524)
        at 
org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:510)
        at 
org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:226)
        at 
org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1295)
        ... 59 more
{code}

> JasyptPropertiesParser fails on properties references with default value
> ------------------------------------------------------------------------
>
>                 Key: CAMEL-11523
>                 URL: https://issues.apache.org/jira/browse/CAMEL-11523
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jasypt
>    Affects Versions: 2.17.7, 2.19.1
>            Reporter: Ronny Aerts
>         Attachments: jasypt.rar
>
>
> I'm using the JasyptPropertiesParser in combination with the 
> BridgePropertyPlaceholderConfigurer to able to encrypt properties by adding 
> the parser property.
>              <beans:property name="parser">
>                     <!-- define the jasypt properties parser with the given 
> password to be used -->
>                     <beans:bean 
> class="org.apache.camel.component.jasypt.JasyptPropertiesParser" 
> depends-on="InitializeProperties">
>                            <beans:property name="password" 
> value="#{IP.getPassword()}"/>
>                            <beans:property name="algorithm" 
> value="PBEWITHSHA1ANDRC4_128"/>
>                     </beans:bean>
>              </beans:property>
> This works fine but when I have a 
> "tris.dlq.folder.process.history:c:/temp/TrisESB" property with a default 
> value in my xml route, the route creating fails with error:
> Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name 
> properties must be defined in CamelContext to support property placeholders. 
> Property with key [tris.dlq.folder.process.history:c:/temp/TrisESB] not found 
> in properties from text: 
> file://{{tris.dlq.folder.process.history:c:/temp/TrisESB}}?fileName=$simple{header.breadcrumbId}-prochist.htm
> My log also mentions the parsing of the property.
> [TRACE] [org.apache.camel.component.jasypt.JasyptPropertiesParser] Parsing 
> property 'tris.dlq.folder.process.history:c:/temp/TrisESB=null'
> It seems that the JasyptPropertiesParser can't handle default properties.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to