6 Replies Latest reply on Apr 19, 2007 4:36 PM by Joe Schmoe

    JNDI in Jboss EJB3 Embeddable Container: Naming Problem

    Joe Schmoe Newbie

      Hopefully someone can help me out with this.

      I'm running the JBoss EJB3 embeddable server inside Tomcat 6. Everything seems happy enough when booting. I'm trying to access a simple stateless bean named TestBean from within a struts servlet.

      I'm getting the following exception:

      javax.naming.NameNotFoundException: scrumster not bound

      Here is the Bean and interface:

      import javax.ejb.Stateless;
      import javax.persistence.*;
      import java.util.List;
      public class TestBean implements TestInterface {
       EntityManager em;
       public void saveMessages() {
       public void showMessages() {
       List messages =
       em.createQuery("select m from Message m order by m.text asc")
       System.out.println(messages.size() + " message(s) found:");

      public interface TestInterface {
       public void saveMessages();
       public void showMessages();

      And here is the calling code:

      public String execute() throws Exception {
       Hashtable props = new Hashtable();
       props.put("java.naming.factory.initial", "org.jnp.interfaces.LocalOnlyContextFactory");
       props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       InitialContext initialContext = new InitialContext(props);
       TestInterface msgHandler = (TestInterface) initialContext
       return SUCCESS;

      How do I even know my bean has loaded into the JBoss container? Is there something I need to do to get it to be detected?

      Thanks again for any help. I'm having a terrible time getting this setup so I can actually write some code.