I am using Camel 2.19.1 and have a question on @PropertyInject with a default 
value. I have the following:

public class MyStuff {
    @PropertyInject(value="testVal", defaultValue="")
    private String testVal;
...
}

When this class is instantiated and injected, if there is no 'testVal" in 
properties, I get an exception (below) that the testVal key is not found.

But if I change the defaultValue to anything non-empty, it works fine - the 
default value is used without a property of the given name.

Is this the way you would expect it to work?

Thanks,
-Steve

...
Caused by: org.apache.camel.RuntimeCamelException: 
java.lang.IllegalArgumentException: Property with key [testVal] not found in 
properties from text: {{testVal}}
        at 
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1774)
        at 
org.apache.camel.impl.CamelPostProcessorHelper.getInjectionPropertyValue(CamelPostProcessorHelper.java:282)
        at 
org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFieldProperty(DefaultCamelBeanPostProcessor.java:211)
        at 
org.apache.camel.impl.DefaultCamelBeanPostProcessor$1.doWith(DefaultCamelBeanPostProcessor.java:171)
        at 
org.apache.camel.util.ReflectionHelper.doWithFields(ReflectionHelper.java:74)
        at 
org.apache.camel.impl.DefaultCamelBeanPostProcessor.injectFields(DefaultCamelBeanPostProcessor.java:167)
        at 
org.apache.camel.impl.DefaultCamelBeanPostProcessor.postProcessBeforeInitialization(DefaultCamelBeanPostProcessor.java:82)
        at 
org.apache.camel.impl.DefaultInjector.newInstance(DefaultInjector.java:48)
        ... 61 more
Caused by: java.lang.IllegalArgumentException: Property with key [ris.testOpk] 
not found in properties from text: {{ris.testOpk}}
        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.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.impl.CamelPostProcessorHelper.getInjectionPropertyValue(CamelPostProcessorHelper.java:268)
        ... 67 more

Reply via email to