Search code examples
javaapache-cameljbossfuseblueprint-osgi

Bundle is waiting for namespace handlers [http://camel.apache.org/schema/blueprint]


I have written a simple apache camel project which will eventually be deployed in a FUSE container. For now, I'm simply trying to get a basic unit test working. I'm using the example here as a starting point.

I have written unit tests which work, but when I include a blueprint file, I get the following entry in the test output:

Bundle TestMainRoute is waiting for namespace handlers [http://camel.apache.org/schema/blueprint]

And the test fails with the following stack trace:

java.lang.RuntimeException: Gave up waiting for service (objectClass=org.apache.camel.CamelContext)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:240)
at org.apache.camel.test.blueprint.CamelBlueprintHelper.getOsgiService(CamelBlueprintHelper.java:202)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.createCamelContext(CamelBlueprintTestSupport.java:352)
at org.apache.camel.test.junit4.CamelTestSupport.doSetUp(CamelTestSupport.java:247)
at org.apache.camel.test.junit4.CamelTestSupport.setUp(CamelTestSupport.java:217)
at org.apache.camel.test.blueprint.CamelBlueprintTestSupport.setUp(CamelBlueprintTestSupport.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:55)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

My xml is very simple:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
  <routeContext id="validationRoute"  xmlns="http://camel.apache.org/schema/blueprint" >

    <route id="validation">
        <from uri="direct:validation" />
        <log message="validating..." />
    </route>
</routeContext>

As is the code:

public class RouteTest extends CamelBlueprintTestSupport  {

  @Test
  public void testValidationRoute() throws Exception    {
    DefaultExchange r1 = new DefaultExchange(context);
    r1.getIn().setBody("");
    Exchange response1 = template.send("direct:validation", r1);
  }

  protected String getBlueprintDescriptor() {
    return "OSGI-INF/blueprint/blueprint.xml";
  1. List item

} }

NB the validation route is referenced by my main camel context:

public class IntegrationFramework extends RouteBuilder {

public void configure() {

    from("netty-http:http://localhost:8457/broker/router.jsp").convertBodyTo(String.class)
    .log("http router "+simple("${body}").getText())
    .to("direct:validation");
}

I have other unit tests and logging which indicate that this part is working.


Solution

  • Turns out that a routeContext only exists in the context of xml dsl, and cannot be referenced from the Java DSL. This in my opinion is a bug, since it restricts the flexibility of mixing xml and java configuration.

    By changing the routeContext to a camelContext, this fixed the problem.

    See also this question: Camel: importing routeContext into an external camelContext

    Also related: https://issues.apache.org/jira/browse/CAMEL-5717