[jboss-user] [JNDI and Naming] - JNDI binding and NameNotFoundException

David Bailey do-not-reply at jboss.com
Mon Dec 12 17:38:06 EST 2011


David Bailey [http://community.jboss.org/people/edwardpig] created the discussion

"JNDI binding and NameNotFoundException"

To view the discussion, visit: http://community.jboss.org/message/641151#641151

--------------------------------------------------------------
I'm an EJB-newbie, so please bear with me.  I'm running JBoss 5.1.0, and I'm trying to define/deploy/access a stateless session bean.  It's my understanding that JBoss 5.1.0 conforms to EJB 3.0, and so I can do the whole thing with annotations, without the need for a ejb-jar.xml or jboss.xml file.

After much Googling, I have tried a number of different ways to do things, most recently the following.  In my bean class, I added a no-args constructor and the following annotation and interface:

{code}
@Stateless
public class ScoreComputer implements IScoreComputer
{code}

I defined an IScoreComputer class which declares the methods I want to have available, and put the following annotation on it:

{code}
@Local
public interface IScoreComputer
{code}

In my server code, I try to obtain a reference to my ScoreComputer as follows:

{code}
IScoreComputer computer;
InitialContext ejbContext = new InitialContext();
computer = (IScoreComputer)ejbContext.lookup("ScoreComputer/local");
{code}

When this code executes, a NameNotFoundException is thrown with the message 'IScoreComputer not bound'.  I know I'm not doing the JNDI binding correctly, because I've looked in the JMX console for JBoss, and no binding is listed containing the string 'Score'.  But try as I might, I am unable to find instructions telling me the correct way to do the binding.

I am using the Spring DispatcherServlet as my servlet, and for a while I thought that might be what is causing the problem, and it may well be.  But I replaced that in my web.xml with a simple class which extends HttpServlet, and got the same behavior.  I have also tried injecting my bean using the @EJB annotation, e.g.

{code}
@EJB
protected IScoreComputer computer;
{code}

but that fails when JBoss attempts to deploy the .ear file, with a message "Resolution should not happen via injection container".
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/641151#641151]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111212/0246922f/attachment.html 


More information about the jboss-user mailing list