spring - Using OSGi service in the camel route -
i reading book 'camel in action' , unable work out example (section 4.3.4 osgiserviceregistry) using osgi service in camel route. bean (exposed osgi service
public class hellobean { public string hello(string name){ system.out.println(" invoking hello method "); return "hello " + name; } } this spring xml file exposes above bean service
<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:osgi="http://www.springframework.org/schema/osgi" xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd"> <bean id="hellobean" class="camelinaction.testbeans.hellobean" /> <osgi:service id="helloservice" interface="camelinaction.testbeans.hellobean" ref="hellobean" /> <camelcontext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="direct:start" /> <bean ref="helloservice" method="hello" /> </route> </camelcontext> </beans> when execute maven goal 'camel:run', following exception:
caused by: org.springframework.beans.factory.beancreationexception: error creating bean name 'helloservice': invocation of init method failed; nested exception java.lang.illegalargumentexception: required property 'bundlecontext' has not been set please let me know how set bundlecontext. using eclipse equinox osgi container.
camel:run runs thin non-osgi runtime using spring camel configs in project. message getting springdm (the thing instantiates <osgi:service id="helloservice"...>) not being able locate osgi environment. work need install code inside supporting container - such karaf of servicemix.
if you'd see osgi working camel, check out servicemix bootstraps project @ https://github.com/fusebyexample/smx-bootstraps - full documentation there around installing , tweaking code. bundles you'll interested in there smx-ponger , smx-ponger-service, demonstrate consumption , provision of osgi services respectively.
Comments
Post a Comment