Reputation: 21
eip-conext.xml:
<bean id="myProcessor" class="sup.splitter.provider.MyProcessor"/>
<camelContext id="integrationTestContext" xmlns="http://camel.apache.org/schema/spring" useMDCLogging="true"
autoStartup="true">
<camel:route id="FileToTranscodeDetector">
<camel:from uri="file:/mnt/iscsi/MIDDLEDATA/in/?include=.*.mp4&move=/mnt/iscsi/MIDDLEDATA/out/&moveFailed=/mnt/iscsi/MIDDLEDATA/error/"/>
<log message="Receiving \${header.CamelFileName} For TestIntegration" loggingLevel="INFO"
logName="sup.encoder.provider"/>
<camel:to uri="bean:myProcessor?method=process1"/>
<camel:to uri="file:{{exchangeProperty.filePath}}"/>
<!--?tempPrefix=/inProgress/ -->
</camel:route>
MyProcess.java :
public void process1(@Headers final Map<String, Object> headers, final Exchange exchange) throws Exception {
try {
logger.debug("New Process Core !");
final String str = (String) headers.get(Exchange.FILE_NAME);
final File inputFile = new File(str);
Orquestrator.DoJob(inputFile, exchange);
} catch (final Exception e) {
throw new Exception("error with process...", e);
}
}
DoJob.java :
public static void DoJob(final File file, final Exchange exchange)
{
logger.info("starting DoJob..");
logger.info("searching worker");
//WorkerID = FindWorker();
//Je met le le worker 1 pour tester -------
WorkerID = 1;
//-----------------------------------------
logger.info("Send job to available worker number " + WorkerID);
if (WorkerID == 1) {
logger.info("filepath = Worker1/");
exchange.setProperty("filePath", "Worker1/");
} else if (WorkerID == 2) {
logger.info("filepath = Worker2/");
exchange.setProperty("filePath", "Worker2/");
}
}
Solution? I just found nothing...
StackTrace :
06-09 16:27:42 INFO org.springframework.web.context.ContextLoader.initWebApplicationContext (ContextLoader.java:307) Root WebApplicationContext: initialization started
06-09 16:27:42 INFO org.springframework.context.support.AbstractApplicationContext.prepareRefresh (AbstractApplicationContext.java:574) Refreshing Root WebApplicationContext: startup date [Thu Jun 09 16:27:42 CEST 2016]; root of context hierarchy
06-09 16:27:42 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:317) Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/eip-context_Encoder.xml]
06-09 16:27:44 ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext (ContextLoader.java:353) Context initialization failed
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route FileToTranscodeDetector at: >>> To[file:{{exchangeProperty.filePath}}] <<< in route: Route(FileToTranscodeDetector)[[From[file:/mnt/iscsi/MIDDLED... because of PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:123)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:332)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:380)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:851)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route FileToTranscodeDetector at: >>> To[file:{{exchangeProperty.filePath}}] <<< in route: Route(FileToTranscodeDetector)[[From[file:/mnt/iscsi/MIDDLED... because of PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1028)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:185)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:841)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2895)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2618)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:255)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
... 23 more
Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:268)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:154)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:113)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:97)
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:62)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:129)
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1956)
at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:632)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:480)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:217)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1025)
... 36 more
06-09 16:27:55 INFO org.springframework.web.context.ContextLoader.initWebApplicationContext (ContextLoader.java:307) Root WebApplicationContext: initialization started
06-09 16:27:55 INFO org.springframework.context.support.AbstractApplicationContext.prepareRefresh (AbstractApplicationContext.java:574) Refreshing Root WebApplicationContext: startup date [Thu Jun 09 16:27:55 CEST 2016]; root of context hierarchy
06-09 16:27:55 INFO org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions (XmlBeanDefinitionReader.java:317) Loading XML bean definitions from ServletContext resource [/WEB-INF/classes/eip-context_Encoder.xml]
06-09 16:28:02 ERROR org.springframework.web.context.ContextLoader.initWebApplicationContext (ContextLoader.java:353) Context initialization failed
org.apache.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException: Failed to create route FileToTranscodeDetector at: >>> To[file:{{exchangeProperty.filePath}}] <<< in route: Route(FileToTranscodeDetector)[[From[file:/mnt/iscsi/MIDDLED... because of PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1619)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:123)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:332)
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:380)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:851)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:540)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1073)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1857)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route FileToTranscodeDetector at: >>> To[file:{{exchangeProperty.filePath}}] <<< in route: Route(FileToTranscodeDetector)[[From[file:/mnt/iscsi/MIDDLED... because of PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1028)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:185)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:841)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:2895)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:2618)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:167)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2467)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2463)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2486)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2463)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2432)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:255)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:121)
... 23 more
Caused by: java.lang.IllegalArgumentException: PropertiesComponent with name properties must be defined in CamelContext to support property placeholders. Property with key [exchangeProperty.filePath] not found in properties from text: file:{{exchangeProperty.filePath}}
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.getPropertyValue(DefaultPropertiesParser.java:268)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.readProperty(DefaultPropertiesParser.java:154)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.doParse(DefaultPropertiesParser.java:113)
at org.apache.camel.component.properties.DefaultPropertiesParser$ParsingContext.parse(DefaultPropertiesParser.java:97)
at org.apache.camel.component.properties.DefaultPropertiesParser.parseUri(DefaultPropertiesParser.java:62)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:178)
at org.apache.camel.component.properties.PropertiesComponent.parseUri(PropertiesComponent.java:129)
at org.apache.camel.impl.DefaultCamelContext.resolvePropertyPlaceholders(DefaultCamelContext.java:1956)
at org.apache.camel.model.ProcessorDefinitionHelper.resolvePropertyPlaceholders(ProcessorDefinitionHelper.java:632)
at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:480)
at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:217)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1025)
... 36 more
Upvotes: 2
Views: 10091
Reputation: 9537
You could use the dynamic to, to use those properties:
<camel:toD uri="file:${exchangeProperty.filePath}" />
Upvotes: 1
Reputation: 55710
See the Camel documentation how to use property placeholders: http://camel.apache.org/using-propertyplaceholder.html
As you are using XML, then see the section titled Configuring in Spring XML
eg you need to configure where the properties files is located, something a like:
<propertyPlaceholder id="properties" location="com/mycompany/myprop.properties"/>
Upvotes: 3