users@glassfish.java.net

Strange EJB injection problem

From: <glassfish_at_javadesktop.org>
Date: Tue, 16 Sep 2008 12:17:40 PDT

GFv2r2, JDK 5

We have a generic, everyday Stateless Session Bean.

It had been, up to now, working just peachy.

Today, it's decided to revolt.

Within this session bean we have:

[code]
    @EJB(name = "ejb/MySessionBean", beanName = "MySessionBean")
    private MySessionLocal kb;
[/code]

Later, I have:

[code]
    kb.update(o);
[/code]

This fails with a Null Pointer Exception.

kb is null. I even check, print it out, debug it. It's null. Why is it null?

So, on a lark I changed the declaration up above.

from

[code]
    @EJB(name = "ejb/MySessionBean", beanName = "MySessionBean")
    private MySessionLocal kb;
[/code]

to

[code]
    @EJB(name = "ejb/MySessionBeanX", beanName = "MySessionBean")
    private MySessionLocal kb;
[/code]

And now, it works.

Why does it work now? Why didn't it work before? I can change the X to anything (1, Q, whatever), and it works. But if I leave it at "ejb/MySessionBean", it doesn't work. It fails. I get null.

And I get no error, no complaint. Nothing about the injection failing. The session bean is called directly from a Web WAR client bundled in the same ear, using the local interface.

Even more annoying, is I have a @AroundInvoke object as an interceptor. It runs, it has the EXACT SAME declaration, and IT works, but not here.

This also fails when I remove the @AroundInvoke (I thought maybe it had something to do with it -- no, I don't know why either, but it was a recent change so I backed it out just to see).

Any clues anyone?
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=299664