users@glassfish.java.net

Re: Servcies registered with OSGi bundle context NOT available via JNDI

From: Arun Gupta <arun.p.gupta_at_oracle.com>
Date: Tue, 18 May 2010 18:11:05 -0500

AIU BundleContext.registerService makes the service available using the
OSGi service repository. You need to use OSGi declarative services so
that they are accessible from a Java EE client. This is explained in
detail at:

http://blogs.sun.com/arungupta/entry/totd_124_osgi_declarative_services

Thanks
-Arun

On 5/15/10 9:49 PM, glassfish_at_javadesktop.org wrote:
> From everything I have read on the web, when I register a service using the BundleContext.registerService() in a BundleActivator.start() method, in an OSGi bundle deployed to a glassfish server (I'm using v3.0.1b18), the service is supposed to be registered in JNDI so that I can use resource injection in a servlet (via @Resource). In fact, it seems that the services are NOT being registered in JNDI (as the name lookup fails, and browsing the JNDI tree confirms). If I register the services manually, then the @Resource injection works as it should.
>
> Is this a bug or do I need some special OSGi module installed to realize this behavior? Does this ONLY happen when using declarative services or spring? Shouldn't it work with manual registrations too?
>
> See http://blogs.sun.com/dochez/entry/glassfish_v3_extensions_part_3 and http://blogs.sun.com/dochez/entry/glassfish_v3_extensions_part_4
>
> Thanks in advance.
> [Message sent by forum member 'npahucki']
>
> http://forums.java.net/jive/thread.jspa?messageID=469987
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

-- 
Blog: http://blogs.sun.com/arungupta
Twitter: http://twitter.com/arungupta