numberfourteen
numberfourteen

Reputation: 175

Apache Camel "No component found with scheme: stream"

I'm just getting to know Camel (and Maven) and I have this very simple Java example:

 public static void main( String[] args ) throws Exception {    
    CamelContext context = new DefaultCamelContext();

    context.addRoutes(new RouteBuilder() {

          public void configure() { 
            from("direct:in").to("stream:out");     
          }

    });

    context.start();

    ProducerTemplate template = context.createProducerTemplate();
    template.sendBody("direct:in", "Hello Text World"); 
    template.sendBody("direct:in", "Hello Bytes World".getBytes());
}

My maven POM file includes:

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

Still I receive a org.apache.camel.FailedToCreateRouteException, because No component found with scheme: stream

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1 at: >>> To[stream:out] <<< in route: Route(ro to: No component found with scheme: stream at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1298) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:204) at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1087) at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3544) at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3275) at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:202) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3093) at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3089) at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3112) at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3089) at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61) at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3026) at mavenCamelRiding.binFileStreamToCamel.MainStreamRouter.main(MainStreamRouter.java:37) Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: stream://out due to: No component found with scheme: stream at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:729) at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80) at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:219) at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:112) at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:118) at org.apache.camel.model.SendDefinition.resolveEndpoint(SendDefinition.java:62) at org.apache.camel.model.SendDefinition.createProcessor(SendDefinition.java:56) at org.apache.camel.model.ProcessorDefinition.makeProcessorImpl(ProcessorDefinition.java:549) at org.apache.camel.model.ProcessorDefinition.makeProcessor(ProcessorDefinition.java:510) at org.apache.camel.model.ProcessorDefinition.addRoutes(ProcessorDefinition.java:226) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1295)

Any idea, where the problem could be? Google wasn't able to help me so far.

edit 1: here is the rest of my POM file

  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>mavenCamelRiding</groupId>
  <artifactId>binFileStreamToCamel</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>binFileStreamToCamel</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.19.2</version>
    </dependency>

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

  </dependencies>
</project>

edit 2:

It obviously has something to do with the way I build and start the program. This confuses me, because I didn't have any problems with any other route options I played around with so far (jms, activemq, file, bean).

I now tested the building and running within Eclipse instead of with the console. So I right-clikced the project folder and selected "Build Project". Then I selected "Run As" and "Java Application". The Eclipse console gives me the expected hello-world-output.

Why doesn't it work with the console?

edit 3:

now instead of first using "mvn compile", moving into the "target\classes" folder and then running "java package.classname", I executed this:

mvn compile exec:java -Dexec.mainClass=package.classname

and it gives me the hello-world-output I wanted.

Sounds like a class path problem? How can I start the example program without maven?

Upvotes: 2

Views: 8244

Answers (2)

numberfourteen
numberfourteen

Reputation: 175

Now I have 2 options to run my example program on the console:

First option:

mvn compile exec:java -Dexec.mainClass=package.classname (in folder with pom.xml)

Second option:

  1. mvn dependency:copy-dependencies compile (in folder with pom.xml)
  2. java -classpath ..\dependency*;. package.classname (in folder target\classes)

So it was a classpath problem. It just doesn't explain, why in earlier examples java was able to find camel-core and camel-jms without additional classpath information, but not camel-stream.

Upvotes: 2

RanjithKRaman
RanjithKRaman

Reputation: 46

I took your source and tested on my machine and was able to see the output, as below:

Hello Text World Hello Bytes World

It's possible that your local .m2 is missing the camel-stream jar. Or you can you delete the camel-stream folder under your .m2\repository\org\apache\camel\camel-stream\2.19.2, do a maven clean install and try to run this again.

Upvotes: 0

Related Questions