我正在尝试使用蓝图在OSGi中正常工作(通过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构建运行(非常)简单的测试时,我得到了这个错误:
[ERROR] 2015-03-26 17:58:54,284 [Blueprint Extender: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:从元素&#39;包&#39;开始发现无效内容。其中一个&#39; {&#34; http://camel.apache.org/schema/blueprint&#34;:模板,&#34; http://camel.apache.org/schema/blueprint&#34;:consumerTemplate,&#34; http://camel.apache.org/schema/blueprint&# 34;:代理,&#34; http://camel.apache.org/schema/blueprint&#34;:导出,&#34; http://camel.apache.org/schema/blueprint&#34;:errorHandler,&#34; http://camel.apache.org/schema/blueprint&#34; :routeBuilder,&#34; http://camel.apache.org/schema/blueprint&#34;:routeContextRef,&#34; http://camel.apache.org/schema/blueprint&#34;:restContextRef,&#34; http://camel.apache.org/schema/blueprint&#34;:threadPoolProfile ,&#34; http://camel.apache.org/schema/blueprint&#34;:threadPool,&#34; http://camel.apache.org/schema/blueprint&#34;:端点,&#34; http://camel.apache.org/schema/blueprint&#34;:dataFormats,& #34; http://camel.apache.org/schema/blueprint&#34;:redeliveryPolicyProfile,&#34; http://camel.apache.org/schema/blueprint&#34;:onException,&#34; http://camel.apache.org/schema/blueprint&#34;:onCompletion,&#34 ; http://camel.apache.org/schema/blueprint&#34;:拦截,&#34; http://camel.apache.org/schema/blueprint&#34;:interceptFrom,&#34; http://camel.apache.org/schema/blueprint&#34;:interceptSendToEndpoint,&#34; { {3}}&#34;} restConfiguration,&#34; http://camel.apache.org/schema/blueprint&#34;:rest,&#34; http://camel.apache.org/schema/blueprint&#34;:route}&#39;是预期的。
我对此非常困惑,因为它抱怨Camel Context中的标记。我在其他地方使用这个完全相同的语法(只是一个不同的包),没有问题。
最终的错误&#39;一切都终于崩溃了:
java.lang.RuntimeException:等待服务(objectClass = org.apache.camel.CamelContext)
这是有道理的,因为元素在元素内部。
但是,我不知道为什么会失败。如果我删除了包元素,一切都很好,测试运行并通过,所以它实际上只是这个发臭的元素(或者它与某人的交互方式)。
帮助我Obi-wan Kenobi,你是我唯一的希望(也许)。
次要问题:我是否正确定义了代理端点&amp;它必要的暴露服务?
答案 0 :(得分:2)
在<proxy>
内切换<package>
和<camelContext>
的顺序。这些元素需要按特定顺序排列。