Hi Paul,

If your component expose a service (that you can see with bundle:services for 
instance), and you have also the jndi feature installed, nothing to do: you 
will have the JNDI name mapped to the OSGi service (it’s not related to 
blueprint or DS, it’s directly service). You can also add a service property 
osgi.jndi.name to simplify the lookup.

Regards
JB

> Le 9 sept. 2020 à 18:03, Paul Spencer <[email protected]> a écrit :
> 
> Karaf 4.2.9
> PAX-WEB 7.2.16
> 
> I have a running in a MyFaces web application and I am not getting an OSGi 
> Service defined via @Component via JNDI?
> 
> I am following the "OSGi Services Registry and JNDI" documentation in 
> https://karaf.apache.org/manual/latest/#_naming_jndi to access the service.  
> Services defined via Blueprint are available to the web application where as 
> services defined via @Component are not.  Specifically the 
> ctx.lookup(“osgi:service/...”) returns null for services define via 
> @Component.  
> 
> What is needed for services defined using @Component 
> (org.osgi.service.component.annotations.Component) to be available to a Web 
> Application using PAX-WEB via the JNDI schema 
> osgi:service/<interface>[/<filter>] ?
> 
> Note: I have defined  command in Karaf that is able to access the service via 
> @Reference (org.apache.karaf.shell.api.action.lifecycle.Reference) and the 
> JNDI schema osgi:service/<interface>[/<filter>] 
> 
> 
> ***
> * Environment information
> ***
> karaf@root()> feature:list --installed | grep -i pax                          
>                                                                               
>                                                                        
> pax-http-service             │ 7.2.16           │          │ Started │ 
> standard-4.2.9           │ Pax-Web OSGi HTTP Service
> pax-web-core                 │ 7.2.16           │          │ Started │ 
> org.ops4j.pax.web-7.2.16 │ Provide Core pax-web bundles
> pax-jetty                    │ 9.4.28.v20200408 │          │ Started │ 
> org.ops4j.pax.web-7.2.16 │ Provide Jetty engine support
> pax-http-jetty               │ 7.2.16           │          │ Started │ 
> org.ops4j.pax.web-7.2.16 │
> pax-http                     │ 7.2.16           │          │ Started │ 
> org.ops4j.pax.web-7.2.16 │ Implementation of the OSGI HTTP Service
> pax-http-whiteboard          │ 7.2.16           │          │ Started │ 
> org.ops4j.pax.web-7.2.16 │ Provide HTTP Whiteboard pattern support
> pax-war                      │ 7.2.16           │ x        │ Started │ 
> org.ops4j.pax.web-7.2.16 │ Provide support of a full WebContainer
> pax-transx-tm-api            │ 0.4.4            │          │ Started │ 
> pax-transx-0.4.4         │
> pax-transx-tm-geronimo       │ 0.4.4            │          │ Started │ 
> pax-transx-0.4.4         │
> pax-jdbc-spec                │ 1.4.4            │          │ Started │ 
> org.ops4j.pax.jdbc-1.4.4 │ Provides OSGi JDBC Service spec
> pax-jdbc                     │ 1.4.4            │          │ Started │ 
> org.ops4j.pax.jdbc-1.4.4 │ Provides JDBC Service support
> pax-jdbc-config              │ 1.4.4            │          │ Started │ 
> org.ops4j.pax.jdbc-1.4.4 │ Provides JDBC Config support
> pax-jdbc-postgresql          │ 1.4.4            │ x        │ Started │ 
> org.ops4j.pax.jdbc-1.4.4 │ Provides JDBC PostgreSQL DataSourceFactory
> pax-cdi                      │ 1.1.3            │ x        │ Started │ 
> org.ops4j.pax.cdi-1.1.3  │ Provide CDI support
> pax-cdi-weld                 │ 1.1.3            │          │ Started │ 
> org.ops4j.pax.cdi-1.1.3  │ Weld CDI 1.2 support
> karaf@root()> list | grep -i pax
> 133 │ Active   │  80 │ 1.4.4                │ OPS4J Pax JDBC Generic Driver 
> Extender
> 134 │ Active   │  80 │ 1.4.4                │ OPS4J Pax JDBC Config
> 135 │ Active   │  80 │ 1.4.4                │ OPS4J Pax JDBC Pooling Support 
> Base
> 143 │ Active   │  80 │ 0.4.4                │ pax-transx-tm-api
> 144 │ Active   │  80 │ 0.4.4                │ pax-transx-tm-geronimo
> 233 │ Active   │  80 │ 1.1.3                │ OPS4J Pax CDI Bean Bundle API
> 234 │ Active   │  80 │ 1.1.3                │ OPS4J Pax CDI Extender for Bean 
> Bundles
> 235 │ Active   │  80 │ 1.1.3                │ OPS4J Pax CDI Portable 
> Extension for OSGi
> 236 │ Active   │  80 │ 1.1.3                │ OPS4J Pax CDI Service Provider 
> Interface
> 237 │ Active   │  80 │ 1.1.3                │ OPS4J Pax CDI Weld Adapter
> karaf@root()>  
> karaf@root()> list | grep -i faces
> 230 │ Resolved │  80 │ 5.1.0                │ primefaces
> 240 │ Resolved │  80 │ 2.2.12               │ Apache MyFaces JSF-2.2 Core API
> 242 │ Resolved │  80 │ 2.2.12               │ Apache MyFaces JSF-2.2 Core Impl
> 
> Paul Spencer
> 
> 

Reply via email to