Using @Reference(lookup="jmsConnectionFactory") annotation in glassfish


Trond Arild Lode Tobiassen Heidelberg
 

Hi. tried to use this feature, However injection does not happen and nullpointer results.
The test succeeds using jndi lookup directly, implying all is correct on glassfish for sending messages to MDB.

I have tried the Resource annotation on the field and also on the class. The class is defined as a Stateless Session bean. I have tried with fields as instance as well as static. I have tried with class annotation only and field annotation only.This is the code:

@Stateless(name = "jmsRunnabeStatelessSessionCDIBean", mappedName = "jmsRunnableStatelessSessionBeanCDIMappedName")
@LocalBean
@Resource(name = "jmsMyConnectionFactoryName", type = javax.jms.TopicConnectionFactory.class, mappedName = "jmsMyConnectionFactoryMappedName", lookup = "jmsMyConnectionFactory")
public class EmitterCDI implements Runnable {
 
@Resource(name = "jmsMyConnectionFactoryName", lookup = "jmsMyConnectionFactory")
private static TopicConnectionFactory connectionFactory;
.......
}

Hope one of you guys can shed some light as to why the nullpointer.

Best regards Trond 


Yamini Kalyandurga <yamini.k.b@...>
 

Hi Trond,

Which version of GlassFish are you using? 

Can you please share the stack trace?

Thanks,
-Yamini


Trond Arild Lode Tobiassen Heidelberg
 

Hi and thanks for you swift reply.

The version is 4.1 and there is no stack trace except nullpointer when i access methods on the connection factory.

Best Regards Trond

On 15.08.2017 16:30, Yamini Kalyandurga wrote:
Hi Trond,

Which version of GlassFish are you using? 

Can you please share the stack trace?

Thanks,
-Yamini


Yamini Kalyandurga <yamini.k.b@...>
 

Hi Trond,

Can you please try on GlassFish 5.0?
http://download.oracle.com/glassfish/5.0/nightly/index.html

It would help if you can share a reproducer.

Thanks,
-Yamini


Sam
 

Same bug. What do you mean with reproducer?

 

 

 

 

Met vriendelijke groet,

 

 

Jeroen Bankert

Pesetastraat 40, 2991XT Barendrecht

 

j.bankert@...

 

www.yellowstar.com

 

 

 

 

 

 

Van: glassfish@javaee.groups.io [mailto:glassfish@javaee.groups.io] Namens Yamini Kalyandurga
Verzonden: donderdag 24 augustus 2017 14:40
Aan: glassfish@javaee.groups.io
Onderwerp: Re: [glassfish] Using @Reference(lookup="jmsConnectionFactory") annotation in glassfish

 

Hi Trond,

Can you please try on GlassFish 5.0?
http://download.oracle.com/glassfish/5.0/nightly/index.html

It would help if you can share a reproducer.

Thanks,
-Yamini


Trond Arild Lode Tobiassen Heidelberg
 

Turns out I needed to use InitialContext for my application. At least going from JUnit testst or from netty callback methods. Making them session beans and trying to inject (@Resource) does not work. I successfully used injection inside an MDB so everything is ok.


On 24.08.2017 14:40, Yamini Kalyandurga wrote:
Hi Trond,

Can you please try on GlassFish 5.0?
http://download.oracle.com/glassfish/5.0/nightly/index.html

It would help if you can share a reproducer.

Thanks,
-Yamini