You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by gasius <na...@combalt.com> on 2012/07/24 17:22:35 UTC

Unable to get OSGi service in JBI application

Hi,

I need to move some JBI applications to ServiceMix 4.4.2 and I'm having
trouble when trying to get shared OSGi services in xbean.xml. I added needed
namespaces, schemas and osgi library imports but OSGi reference 

*<osgi:reference id="connectionFactory"
interface="org.apache.activemq.pool.PooledConnectionFactory" />*

does not work. I'm getting such error message:

/Error creating bean with name 'connectionFactory': Invocation of init
method failed; nested exception is java.lang.IllegalArgumentException:
Required 'bundleContext' property was not set./

Also I got same error when tried to read properties from cfg file:

*<osgix:cm-properties id="props" persistent-id="my.props">*

Could you please assist me with this?



--
View this message in context: http://karaf.922171.n3.nabble.com/Unable-to-get-OSGi-service-in-JBI-application-tp4025300.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Unable to get OSGi service in JBI application

Posted by gasius <na...@combalt.com>.
After some testing I found that if JBI packaging is used then OSGi registry
services works only in servicemix-camel components. If they are needed in
other components I think it is possible to write some OSGi helper bundle
which could retrieve needed services and pass them as objects to the JBI
components.  



--
View this message in context: http://servicemix.396122.n5.nabble.com/Re-Unable-to-get-OSGi-service-in-JBI-application-tp5713984p5714040.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Unable to get OSGi service in JBI application

Posted by gasius <na...@combalt.com>.
Hi Freeman,

I'm using JBI service assembly:

/<jbi version="1.0" xmlns="http://java.sun.com/xml/ns/jbi">
    <service-assembly>
...
    </service-assembly>
</jbi>/

I'm trying to move SMX 3 applications with minimal changes - just replacing
JNDIs with Spring property-placeholders (read from a configuration file) and
OSGi services. So in my service unit's xbean.xml I add:

/    <classpath>
        <library>osgi:org.springframework.beans</library>
        <library>osgi:org.springframework.context</library>
        <library>osgi:org.springframework.osgi.core</library>
        <library>osgi:org.apache.activemq.activemq-pool</library>
    </classpath>/

and then for OSGi service reference:

/<osgi:reference id="connectionFactory"
interface="org.apache.activemq.pool.PooledConnectionFactory" />/

and for placeholders like described in 
http://www.consulting-notes.com/2010/08/spring-osgi-compendium-example.html
http://www.consulting-notes.com/2010/08/spring-osgi-compendium-example.html
:

/    <osgix:cm-properties id="props" persistent-id="my.props"/>
    <context:property-placeholder properties-ref="props"/>/

But like I said I get that "java.lang.IllegalArgumentException: Required
'bundleContext' property was not set" error. I did some workaround for the
placeholders reading them such way:

/<context:property-placeholder
location="file:${karaf.home}/etc/my.props.cfg" />/

But don't know how to fix OSGi service references.



--
View this message in context: http://servicemix.396122.n5.nabble.com/Re-Unable-to-get-OSGi-service-in-JBI-application-tp5713984p5713985.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Re: Unable to get OSGi service in JBI application

Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Redirect to servicemix mailing list as it's most suitable to discuss it there.

Anyway, you need post more complete configuration and tell us which kind of packaging your SA are using, it's JBI packaging or OSGi packaging?

Freeman
-------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-7-24, at 下午11:22, gasius wrote:

> Hi,
> 
> I need to move some JBI applications to ServiceMix 4.4.2 and I'm having
> trouble when trying to get shared OSGi services in xbean.xml. I added needed
> namespaces, schemas and osgi library imports but OSGi reference 
> 
> *<osgi:reference id="connectionFactory"
> interface="org.apache.activemq.pool.PooledConnectionFactory" />*
> 
> does not work. I'm getting such error message:
> 
> /Error creating bean with name 'connectionFactory': Invocation of init
> method failed; nested exception is java.lang.IllegalArgumentException:
> Required 'bundleContext' property was not set./
> 
> Also I got same error when tried to read properties from cfg file:
> 
> *<osgix:cm-properties id="props" persistent-id="my.props">*
> 
> Could you please assist me with this?
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Unable-to-get-OSGi-service-in-JBI-application-tp4025300.html
> Sent from the Karaf - User mailing list archive at Nabble.com.


Re: Unable to get OSGi service in JBI application

Posted by Freeman Fang <fr...@gmail.com>.
Hi,
Redirect to servicemix mailing list as it's most suitable to discuss it there.

Anyway, you need post more complete configuration and tell us which kind of packaging your SA are using, it's JBI packaging or OSGi packaging?

Freeman
-------------
Freeman Fang

FuseSource
Email:ffang@fusesource.com
Web: fusesource.com
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: http://weibo.com/u/1473905042

On 2012-7-24, at 下午11:22, gasius wrote:

> Hi,
> 
> I need to move some JBI applications to ServiceMix 4.4.2 and I'm having
> trouble when trying to get shared OSGi services in xbean.xml. I added needed
> namespaces, schemas and osgi library imports but OSGi reference 
> 
> *<osgi:reference id="connectionFactory"
> interface="org.apache.activemq.pool.PooledConnectionFactory" />*
> 
> does not work. I'm getting such error message:
> 
> /Error creating bean with name 'connectionFactory': Invocation of init
> method failed; nested exception is java.lang.IllegalArgumentException:
> Required 'bundleContext' property was not set./
> 
> Also I got same error when tried to read properties from cfg file:
> 
> *<osgix:cm-properties id="props" persistent-id="my.props">*
> 
> Could you please assist me with this?
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Unable-to-get-OSGi-service-in-JBI-application-tp4025300.html
> Sent from the Karaf - User mailing list archive at Nabble.com.