gpt4 book ai didi

java - Bundle 正在等待命名空间处理程序 [http ://camel. apache.org/schema/blueprint]

转载 作者:搜寻专家 更新时间:2023-11-01 03:56:33 28 4
gpt4 key购买 nike

我写了一个简单的 apache camel 项目,最终将部署在 FUSE 容器中。现在,我只是想让一个基本的单元测试正常工作。我正在使用示例 here作为起点。

我已经编写了有效的单元测试,但是当我包含一个蓝图文件时,我在测试输出中得到以下条目:

Bundle TestMainRoute 正在等待命名空间处理程序 [http://camel.apache.org/schema/blueprint]

测试失败并显示以下堆栈跟踪:

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)

我的 xml 非常简单:

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

代码如下:

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. 列表项

}

注意验证路由被我的主 Camel 上下文引用:

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");
}

我有其他单元测试和日志记录表明这部分工作正常。

最佳答案

我有同样的错误,但另一个设置然后@mdarwin,所以我也想与你分享我的解决方案。

我用 camel-archetype-blueprint 开始了一个项目,所以我的命名空间如下所示:

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

一开始它是一个非常简单的蓝图,带有一个定时器和一个文件端点,所以这里的实现并不重要。我将我的包部署到 Karaf为此,我安装了 aries-blueprint 功能。

我错过了,我感到很惭愧,是安装camel , 也。为此,我必须添加 repo 并安装它,你可以阅读 here :

feature:repo-add camel
feature:install camel

现在命名空间处理程序就在那里。

我认为这是显而易见的,但还是花了几分钟才弄明白。

关于java - Bundle 正在等待命名空间处理程序 [http ://camel. apache.org/schema/blueprint],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36721820/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com