我试图让一个代理与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:发现无效的内容(从元素“ package”开始)。 “ {{http://camel.apache.org/schema/blueprint”:模板,“ http://camel.apache.org/schema/blueprint”:consumerTemplate,“ http://camel.apache.org/schema/blueprint”:代理,“ 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”:端点,“ 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”:拦截,“ http://camel.apache.org/schema/blueprint”:interceptFrom,“ http://camel.apache.org/schema/blueprint”:interceptSendToEndpoint,“ “:restConfiguration,” http://camel.apache.org/schema/blueprint“:rest,” http://camel.apache.org/schema/blueprint“:route}'是预期的。我对此感到非常困惑,因为它抱怨骆驼语境中的标签。我在其他地方(只是一个不同的包)使用了完全相同的语法,这没有问题。一切最终崩溃的最后一个“错误”是:java.lang.RuntimeException:放弃等待服务(objectClass = org.apache.camel.CamelContext)这是有道理的,因为该元素位于该元素内部。不过,我不知道为什么会失败。如果我删除了package元素,那么一切都很好,并且测试可以运行并通过,因此它实际上只是这个令人讨厌的元素(或它与某人交互的方式)。帮我Obi-wan Kenobi,您是我唯一的希望(也许)。第二个问题:我是否正确定义了代理端点及其必需的公开服务? (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 在<proxy>中交换<package>和<camelContext>的顺序。这些元素需要按特定顺序排列。 (adsbygoogle = window.adsbygoogle || []).push({});
07-28 14:11