I created an OSGi bundle using the camel-archetype-blueprint maven archetype. I then tried to install this into Karaf, but the bundle is going into GracePeriod. After running diag, it's missing a dependency that is inside the jar file itself.
Ok, the long version:
The jar file generated from the archetype contains the Hello and HelloBean classes that are included from the archetype:
$ jar tvf myproject-1.0-SNAPSHOT.jar
455 Tue Jul 26 11:25:10 UTC 2016 META-INF/MANIFEST.MF
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/
0 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/myproject/
143 Tue Jul 26 11:25:10 UTC 2016 META-INF/maven/com.petewall/myproject/pom.properties
3418 Tue Jul 26 11:25:06 UTC 2016 META-INF/maven/com.petewall/myproject/pom.xml
0 Tue Jul 26 11:25:10 UTC 2016 OSGI-INF/
0 Tue Jul 26 11:25:10 UTC 2016 OSGI-INF/blueprint/
1376 Tue Jul 26 11:20:12 UTC 2016 OSGI-INF/blueprint/blueprint-bean.xml
961 Tue Jul 26 11:20:12 UTC 2016 OSGI-INF/blueprint/blueprint-service.xml
0 Tue Jul 26 11:25:10 UTC 2016 com/
0 Tue Jul 26 11:25:10 UTC 2016 com/petewall/
143 Tue Jul 26 11:24:56 UTC 2016 com/petewall/Hello.class
1022 Tue Jul 26 11:24:56 UTC 2016 com/petewall/HelloBean.class
676 Tue Jul 26 11:20:12 UTC 2016 log4j.properties
I dropped this jar file into the deploy directory of my karaf instance. The bundle is installed and listed in the bundle:list
command. However, when the bundle starts, it goes into GracePeriod. Diagnosing it shows that it's missing a dependency:
karaf@root()> bundle:diag 98
Camel Blueprint Route (98)
--------------------------
Status: GracePeriod
Blueprint
7/26/16 6:26 PM
Missing dependencies:
(objectClass=com.petewall.Hello)
However, those classes are even found using karaf's exports
command:
karaf@root()> exports
Package Name | Version | ID | Bundle Name
-----------------------------------------------------------------------------
...
com.petewall | 1.0.0.SNAPSHOT | 98 | myproject
...
And the classes
command:
karaf@root()> classes
...
com/petewall/Hello.class
com/petewall/HelloBean.class
I'm very new to all of these technologies (Karaf, Camel, OSGi, etc...), so I'm sure I'm missing something. Please, can someone point me in the right direction here?
UPDATE 1: The archetype generates two XML files which seem to define the blueprint service and bean.
blueprint-bean.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="..." xmlns:xsi="..." xmlns:cm="..." xsi:schemaLocation="...">
<cm:property-placeholder persistent-id="HelloBean" update-strategy="reload">
<cm:default-properties>
<cm:property name="greeting" value="Hi from Camel" />
</cm:default-properties>
</cm:property-placeholder>
<bean id="helloBean" class="com.petewall.HelloBean">
<property name="say" value="${greeting}"/>
</bean>
<camelContext id="blueprint-bean-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="timerToLog">
<from uri="timer:foo?period=5000"/>
<setBody>
<method ref="helloBean" method="hello"/>
</setBody>
<log message="The message contains ${body}"/>
<to uri="mock:result"/>
</route>
</camelContext>
</blueprint>
blueprint-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="..." xmlns:xsi="..." xmlns:cm="..." xsi:schemaLocation="...">
<reference id="helloService" interface="com.petewall.Hello" />
<camelContext id="blueprint-service-context" xmlns="http://camel.apache.org/schema/blueprint">
<route id="timerToLog">
<from uri="timer:foo?period=5000"/>
<setBody>
<method ref="helloService" method="hello"/>
</setBody>
<log message="The message contains ${body}"/>
<to uri="mock:result"/>
</route>
</camelContext>
</blueprint>
The archetype generates an interface, Hello
, that defines one method: String hello()
. The HelloBean
class implements that interface and uses a private String say
parameter to change what the hello()
method prints.