4 Replies Latest reply on Jul 24, 2002 6:47 PM by Geoffry Roberts

    jndi and bindings or What's wrong with this picture?

    Geoffry Roberts Newbie

      Hi all,

      I would appreciate any insight into this matter.

      I am trying to discover why I cannot successfully perform a jndi lookup on what appears to be a successfully deployed session bean.

      The server.log indicates a successful deployment and the Agent View shows the bean as deployed. However when I attempt a lookup it fails saying the bean is not bound.

      What follows is my junit setup method then its output.

      JUnit method:

      public void setUp()
      {
      try
      {
      Context context = TestUtilities.getInitialContext();
      assertNotNull(context);
      // This lookup works.
      Object ref0 = context.lookup("session");
      System.out.println(ref0);

      // We seem to have the correct bindings
      for(NamingEnumeration enm = context.listBindings
      ("session"); enm.hasMore();)
      {
      Object ref1 = enm.next();
      System.out.println(ref1);
      }
      // This fails.
      Object ref2 = context.lookup
      ("session/PRPASessionHome");
      }
      catch (Exception e)
      {
      fail(e.toString());
      }
      }

      Output:

      test:
      [echo] Test enabled
      [junit] .org.jnp.interfaces.NamingContext@b61fd1
      [junit] PRPASession: $Proxy49:session/PRPASessionHome
      [junit] F
      [junit] Time: 0.501
      [junit] There was 1 failure:
      [junit] 1) test_Insert(app.test.app.test_Insert)junit.framework.AssertionFai
      ledError: javax.naming.NameNotFoundException: PRPASessionHome not bound
      [junit] at app.test.app.test_Insert.setUp(Unknown Source)
      [junit]
      [junit] FAILURES!!!
      [junit] Tests run: 1, Failures: 1, Errors: 0
      [junit]

      BUILD FAILED

        • 1. Re: jndi and bindings or What's wrong with this picture?
          Greg Turner Apprentice

          <What's wrong with this picture?>

          You have not given nearly enough info to enable anyone to help you. Is the lookup done in same JVM as JVM that is hosting EJB? What properties are you passing to Initialcontext? Have you set a jndi name? Does your session bean have local or remote references?

          I hate playing 20 questions, so a word to the wise should be sufficient.

          • 2. Re: jndi and bindings or What's wrong with this picture?
            Geoffry Roberts Newbie

            My apologies. I was trying to be both brief an clear and thought some of what you ask would be self evident--my mistake. Your twenty questions complaint is legitimate.

            I seems that if I can list the bindings I should be able to have a successful lookup.

            My junit is running in a separate jvm. The bean in question has both local and remote interfaces. ( See note at then end of this message.)

            The jboss.xml entry is:

            &lt;session&gt;
            &lt;ejb-name&gt;PRPASession&lt;/ejb-name&gt;
            &lt;jndi-name&gt;session/PRPASession&lt;/jndi-name&gt;
            &lt;/session&gt;


            The properties used by the InitialContext are as follows:

            /*
            Because this method returns a seemingly valid context, shouldn't that be evidence that the properties are correct?
            */
            public static Context getInitialContext()
            throws javax.naming.NamingException
            {
            Properties p = new Properties();

            p.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
            p.put("java.naming.provider.url","localhost:1099");
            p.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");

            return new javax.naming.InitialContext(p);
            }


            All this is running on same physical machine.

            Note: When this PRPASessionBean had only remote interfaces, JBoss complained in the server.log that is could not be bound for lack of local interfaces. Is it not possible to have only remote interfaces? It thought it was.

            • 3. Re: jndi and bindings or What's wrong with this picture?
              Greg Turner Apprentice

              Since your jboss.xml binds the bean as session/PRPASession, I would try that in the lookup, not session/PRPASessionHome

              • 4. Re: jndi and bindings or What's wrong with this picture?
                Geoffry Roberts Newbie

                Thank you for clearing that up.
                My EJB book always shows lookup being done on the Home interface. Apparently, this jboss.xml changes that. I noticed the discrepancy but thought that the "Home" part of the name was being handled internally somehow by JBoss.