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

雨燕双飞 提交于 2019-12-01 05:34:28

问题


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.


回答1:


I had the same error but another setup then @mdarwin, so I want to share my solution with you, too.

I startet a project with the camel-archetype-blueprint, so my namespaces looked like the following:

blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
   xsi:schemaLocation="
     http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
     http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd
     http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd">

At the beginning it was a really simple blueprint with a timer and a file endpoint, so the implementation is not important here. I deployed my bundle to Karaf and for that I installed the aries-blueprint feature.

What I missed, and I feel really ashamed, was to install camel, too. For that I had to add the repo and than install it, as you can read here:

feature:repo-add camel
feature:install camel

Now the namespace handler is there.

I think that was obvious, but it still took some minutes to figure it out.




回答2:


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



来源:https://stackoverflow.com/questions/36721820/bundle-is-waiting-for-namespace-handlers-http-camel-apache-org-schema-bluepri

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!