【发布时间】:2015-05-31 03:13:36
【问题描述】:
我正在尝试让代理在 OSGi 中与 Blueprint 一起正常工作(通过 Karaf 完成),并通过 gradle 构建。
我的蓝图文件(名称已更改以保护无辜者):
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
<!-- Service proxy export for the Camel direct proxy route -->
<service id="postRoutableMessageService" interface="foo.bar.intf.RoutableMessagePoster" ref="postRoutableMessageProxy" ranking="1000">
<service-properties>
<entry key="protocol">
<value type="java.lang.String">Direct</value>
</entry>
</service-properties>
</service>
<camelContext xmlns="http://camel.apache.org/schema/blueprint">
<proxy id="postRoutableMessageProxy" serviceUrl="direct:postRoutableMessage" serviceInterface="foo.bar.intf.RoutableMessagePoster"/>
<!-- Load all routes from the specified package -->
<package>foo.bar.foo</package>
</camelContext>
</blueprint>
目前,这个蓝图文件是不可接受的。当我通过 gradle 构建以运行(非常)简单的测试时,出现此错误:
[错误] 2015-03-26 17:58:54,284 [蓝图扩展器:1] org.apache.aries.blueprint.container.BlueprintContainerImpl doRun - 无法启动捆绑包 OMDDProxyRouteTest 的蓝图容器 org.osgi.service.blueprint.container.ComponentDefinitionException: 无法验证 xml
。 . .
原因:org.xml.sax.SAXParseException; cvc-complex-type.2.4.a:发现以元素“包”开头的无效内容。 '{"http://camel.apache.org/schema/blueprint":template, "http://camel.apache.org/schema/blueprint":consumerTemplate, "http://camel.apache.org/schema/blueprint":proxy, "http://camel.apache.org/schema/blueprint":export, "http://camel.apache.org/schema/blueprint":errorHandler, "http://camel.apache.org/schema/blueprint" 之一: routeBuilder, "http://camel.apache.org/schema/blueprint":routeContextRef, "http://camel.apache.org/schema/blueprint":restContextRef, "http://camel.apache.org/schema/blueprint":threadPoolProfile, "http://camel.apache.org/schema/blueprint":threadPool, "http://camel.apache.org/schema/blueprint":endpoint, "http://camel.apache.org/schema/blueprint":dataFormats, "http://camel.apache.org/schema/blueprint":redeliveryPolicyProfile, "http://camel.apache.org/schema/blueprint":onException, "http://camel.apache.org/schema/blueprint":onCompletion, "http://camel.apache.org/schema/blueprint":intercept, "http://camel.apache.org/schema/blueprint":interceptFrom, "http://camel.apache.org/schema/blueprint":interceptSendToEndpoint, "@ 987654339@":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' 是预期的。
我对此感到非常困惑,因为它抱怨骆驼上下文中的标签。我在其他地方使用了完全相同的语法(只是不同的包),没有问题。
最终导致一切崩溃的最后一个“错误”是:
java.lang.RuntimeException: 放弃等待服务(objectClass=org.apache.camel.CamelContext)
这是有道理的,因为元素在元素内部。
不过,我不知道为什么会失败。如果我删除 package 元素,一切都很好,测试运行并通过,所以它真的只是这个臭元素(或它与某人交互的方式)。
帮助我欧比旺克诺比,你是我唯一的希望(也许)。
第二个问题:我是否正确定义了代理端点及其必要的公开服务?
【问题讨论】:
标签: java proxy apache-camel karaf blueprint-osgi