No endpoint could be found for: direct://DistributeOrderXML, please check your classpath contains the needed Camel component jar

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=""> <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

2 Answers

Which version of Camel are you using? If it is later than Camel 3, you need to import camel-direct in your pom file as the direct component has been moved out of the camel-core module.

2

I had that error too. My problem was that I didn't include dependency for the specific Camel component used in my endpoint.

So in this case

Failed to create route route1: Route(route1)[From[direct:DistributeOrderXML] -> [To[stream:...

means that Camel cannot recognize "stream:..." as an endpoint. You have to add this dependency in pom.xml:

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-stream</artifactId>
<version>x.x.x</version>
</dependency>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like