0

I am trying to get a proxy working correctly with Blueprint inside OSGi (being done via Karaf), and being built via gradle.

My blueprint file (names have been changed to protect the innocent):

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

Right now, this blueprint file is unacceptable. When I build via gradle to run a (very) simple test, I get this error:

[ERROR] 2015-03-26 17:58:54,284 [Blueprint Extender: 1] org.apache.aries.blueprint.container.BlueprintContainerImpl doRun - Unable to start blueprint container for bundle OMDDProxyRouteTest org.osgi.service.blueprint.container.ComponentDefinitionException: Unable to validate xml

. . .

Caused by: org.xml.sax.SAXParseException; cvc-complex-type.2.4.a: Invalid content was found starting with element 'package'. One of '{"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, "http://camel.apache.org/schema/blueprint":restConfiguration, "http://camel.apache.org/schema/blueprint":rest, "http://camel.apache.org/schema/blueprint":route}' is expected.

I am extremely confused by this, because it is complaining about the tag inside the Camel Context. I use this exact same syntax elsewhere (just a different package), and there is no problem.

The final 'error' that everything finally comes to a crashing end on is:

java.lang.RuntimeException: Gave up waiting for service (objectClass=org.apache.camel.CamelContext)

Which makes sense since the element is inside the element.

Still, I have no idea why this fails. If I remove the package element, all is fine and the test runs and passes, so it really is just this stinking element (or the way it interacts with somebody).

Help me Obi-wan Kenobi, you're my only hope (maybe).

Secondary question: Have I correctly defined the proxied endpoint & its necessary exposed service?

Aaron Marcus
  • 153
  • 2
  • 13

1 Answers1

2

Swap the order of <proxy> and <package> inside your <camelContext>. Those elements need to be in a specific order.

Claus Ibsen
  • 56,060
  • 7
  • 50
  • 65
  • Can you link the spec/doc where that sort of thing is specified? – Aaron Marcus Mar 27 '15 at 15:20
  • The XML file has a XSD schema that dictates the order. A modern java editor can validate that for you. The schema files is also online here: http://camel.apache.org/schema/blueprint/ – Claus Ibsen Mar 27 '15 at 15:57
  • I am trying to write a large-ish OSGi project using multiple blueprint files and am having difficulty, but cannot find a useful tutorial that spells out certain features well, any ideas? I'm trying to use a lot of proxies referencing beans spread across multiple blueprint files. – Aaron Marcus Apr 23 '15 at 21:05