You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by fpapon <fp...@openrun.re> on 2017/07/28 11:54:18 UTC

Reference annotation null instance with javax.jms.ConnectionFactory

Hi,I'm using SCR to get instance of service like LogService,
ConfigurationAdmin and it work well.I tried to do the same with JMS Factory
with the activemq-cf feature and my service can't resolve the
ConnectionFactory...*  @Reference  private LogService logService;*  * 
@Reference  private ConfigurationAdmin configAdmin;*  * 
@Reference(target="(osgi.jndi.service.name=jms/activemq-moss)")  private
ConnectionFactory jmsConnectionFactory;*In console :*karaf@root()>
service:list ConnectionFactory                                                                                                                                                                               
15:48:40[javax.jms.ConnectionFactory]-----------------------------
osgi.jndi.service.name = jms/activemq-moss service.bundleid = 38 service.id
= 180 service.scope = singletonProvided by :  activemq-cf
(38)**karaf@root()> jndi:names            JNDI Name                      │
Class Nameosgi:service/jms/activemq-moss │
org.apache.activemq.jms.pool.PooledConnectionFactoryosgi:service/mossorder        
│ org.postgresql.jdbc2.optional.SimpleDataSourceosgi:service/jndi             
│ org.apache.karaf.jndi.internal.JndiServiceImpl*when installing the feature
:*resolution:=mandatory [caused by: Unable to resolve
myservice/1.0.0.SNAPSHOT: missing requirement [myservice/1.0.0.SNAPSHOT]
osgi.service; filter:="(objectClass=javax.jms.ConnectionFactory)";
effective:=active]]*However, if I do this in the activate method of my
service :*jmsConnectionFactory =         
bndContext.getService(bndContext.getServiceReferences(ConnectionFactory.class,             
"(osgi.jndi.service.name=jms/activemq-moss)").iterator().next());*It's work
!



--
View this message in context: http://karaf.922171.n3.nabble.com/Reference-annotation-null-instance-with-javax-jms-ConnectionFactory-tp4051118.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Reference annotation null instance with javax.jms.ConnectionFactory

Posted by fpapon <fp...@openrun.re>.
Yes I see before sending the post :(

I post a new message well formatted 



--
View this message in context: http://karaf.922171.n3.nabble.com/Re-Reference-annotation-null-instance-with-javax-jms-ConnectionFactory-tp4051120p4051122.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Re: Reference annotation null instance with javax.jms.ConnectionFactory

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Unfortunately your message is not well formatted and not easy to read.

You can use @Reference to get a javax.jms.ConnectionFactory service (using a 
filter if you want).

Is it your question ?

Regards
JB

On 07/28/2017 01:54 PM, fpapon wrote:
> Hi,I'm using SCR to get instance of service like LogService,
> ConfigurationAdmin and it work well.I tried to do the same with JMS Factory
> with the activemq-cf feature and my service can't resolve the
> ConnectionFactory...*  @Reference  private LogService logService;*  *
> @Reference  private ConfigurationAdmin configAdmin;*  *
> @Reference(target="(osgi.jndi.service.name=jms/activemq-moss)")  private
> ConnectionFactory jmsConnectionFactory;*In console :*karaf@root()>
> service:list ConnectionFactory
> 15:48:40[javax.jms.ConnectionFactory]-----------------------------
> osgi.jndi.service.name = jms/activemq-moss service.bundleid = 38 service.id
> = 180 service.scope = singletonProvided by :  activemq-cf
> (38)**karaf@root()> jndi:names            JNDI Name                      │
> Class Nameosgi:service/jms/activemq-moss │
> org.apache.activemq.jms.pool.PooledConnectionFactoryosgi:service/mossorder
> │ org.postgresql.jdbc2.optional.SimpleDataSourceosgi:service/jndi
> │ org.apache.karaf.jndi.internal.JndiServiceImpl*when installing the feature
> :*resolution:=mandatory [caused by: Unable to resolve
> myservice/1.0.0.SNAPSHOT: missing requirement [myservice/1.0.0.SNAPSHOT]
> osgi.service; filter:="(objectClass=javax.jms.ConnectionFactory)";
> effective:=active]]*However, if I do this in the activate method of my
> service :*jmsConnectionFactory =
> bndContext.getService(bndContext.getServiceReferences(ConnectionFactory.class,
> "(osgi.jndi.service.name=jms/activemq-moss)").iterator().next());*It's work
> !
> 
> 
> 
> --
> View this message in context: http://karaf.922171.n3.nabble.com/Reference-annotation-null-instance-with-javax-jms-ConnectionFactory-tp4051118.html
> Sent from the Karaf - User mailing list archive at Nabble.com.
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com