DistributeOrderXML.java
public static void main(String[] args) throws Exception{
ApplicationContext appContext = new ClassPathXmlApplicationContext("SpringRouteContext.xml");
CamelContext camelContext = SpringCamelContext.springCamelContext(appContext, false);
try {
camelContext.start();
ProducerTemplate orderProducerTemplate = camelContext.createProducerTemplate();
InputStream orderInputStream = new FileInputStream(ClassLoader.getSystemClassLoader().getResource("order.xml").getFile());
orderProducerTemplate.sendBody("direct:DistributeOrderXML", orderInputStream);
} finally {
camelContext.stop();
}
}
SpringRouteContext.xml
<camelContext
xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="direct:DistributeOrderXML" />
<log message="Split by Distribute Order" />
<split>
<xpath>//order[@product = 'Oil']/items</xpath>
<to uri="file:src/main/resources/order/" />
<to uri="stream:out" />
</split>
</route>
</camelContext>
ERROR CONSOLE
Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[From[direct:DistributeOrderXML] -> [To[stream:... because of No endpoint could be found for: direct://DistributeOrderXML, please check your classpath contains the needed Camel component jar. at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:123) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:353) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:327) at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2598) at org.apache.camel.support.service.BaseService.init(BaseService.java:83) at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2431) at org.apache.camel.support.service.BaseService.start(BaseService.java:111) at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2448) at org.apache.camel.spring.SpringCamelContext.start(SpringCamelContext.java:121) at org.apache.camel.spring.CamelContextFactoryBean.start(CamelContextFactoryBean.java:373) at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:420) at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:94) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:403) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:360) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:897) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:144) at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:85) at DistributeOrderXML.main(DistributeOrderXML.java:16)
Caused by: org.apache.camel.NoSuchEndpointException: No endpoint could be found for: direct://DistributeOrderXML, please check your classpath contains the needed Camel component jar. at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:880) at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:764) at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:57) at org.apache.camel.reifier.AbstractReifier.resolveEndpoint(AbstractReifier.java:166) at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:259) at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:117) ... 21 more