[ 
https://issues.apache.org/jira/browse/CAMEL-7540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-7540:
-------------------------------

    Issue Type: Improvement  (was: Bug)

> Quartz Endpoint with a SimpleTrigger does not support referencing a bean in 
> URI
> -------------------------------------------------------------------------------
>
>                 Key: CAMEL-7540
>                 URL: https://issues.apache.org/jira/browse/CAMEL-7540
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-quartz
>    Affects Versions: 2.12.3
>            Reporter: Nathan Jensen
>            Assignee: Willem Jiang
>            Priority: Minor
>             Fix For: 2.14.0
>
>
> When configuring a Quartz endpoint with Spring, if you are using a 
> SimpleTrigger then it doesn't work to use a bean reference as a parameter on 
> the URI.  For example,
> {code:xml}
> <bean id="taskCount" class="java.lang.Integer">
>    <constructor-arg>5</constructor-arg>
> </bean>
> <endpoint id="taskLauncher" 
> uri="quartz://taskThread?trigger.repeatCount=#taskCount"/>
> {code}
> Since there is no cron specified, it will use a SimpleTrigger.  In 
> QuartzComponent.createEndpoint(String, String, Map) it will get the 
> repeatCount as the string "#taskCount" instead of the actual bean, and 
> therefore when it goes to convert it to an Integer, it will fail with an 
> exception like this:
> {noformat}
> Caused by: org.apache.camel.TypeConversionException: Error during type 
> conversion from type: java.lang.String to the required type: 
> java.lang.Integer with value #taskCount due java.lang.NumberFormatException: 
> For input string: "#taskCount"
>       at 
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:130)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:98)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:174)
>  ~[camel-quartz-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:56)
>  ~[camel-quartz-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:123)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:511)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       ... 43 common frames omitted
> Caused by: org.apache.camel.RuntimeCamelException: 
> java.lang.NumberFormatException: For input string: "#taskCount"
>       at 
> org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1363)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1005) 
> ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.converter.StaticMethodTypeConverter.convertTo(StaticMethodTypeConverter.java:59)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.doConvertTo(BaseTypeConverterRegistry.java:275)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at 
> org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:113)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       ... 48 common frames omitted
> Caused by: java.lang.NumberFormatException: For input string: "#taskCount"
>       at 
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) 
> ~[na:1.7.0_40]
>       at java.lang.Integer.parseInt(Integer.java:481) ~[na:1.7.0_40]
>       at java.lang.Integer.valueOf(Integer.java:582) ~[na:1.7.0_40]
>       at 
> org.apache.camel.converter.ObjectConverter.toInteger(ObjectConverter.java:250)
>  ~[camel-core-2.12.3.jar:2.12.3]
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
> ~[na:1.7.0_40]
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
> ~[na:1.7.0_40]
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>  ~[na:1.7.0_40]
>       at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40]
>       at 
> org.apache.camel.util.ObjectHelper.invokeMethod(ObjectHelper.java:1001) 
> ~[camel-core-2.12.3.jar:2.12.3]
>       ... 51 common frames omitted
> {noformat}
> A workaround is to explicitly set the value of repeatCount or use a system or 
> environment variable, but there are situations where we want to use a value 
> defined elsewhere in the application context.  Looking at the code, it 
> appears a similar problem will occur with repeatInterval.



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

Reply via email to