0

I am new to java and learning how to implement stateful ejb, I couldn't do that- (I wanted to maintain a list by adding and removing element in a arrayList) and unit testing is working fine, initializing the object throws the javax.naming.NamingException

Is there anything that i am missing.

 <%!
     private static ListElementRemoteForStateful itemIds;
     public void jspInit()
     {
          try
          {
            InitialContext ic = new InitialContext();
            // next line of code always throw
            // here EjbPrototype is the name of the project
            // StatefulEjb is the class name which resides in package ejb
            // I tested with java:global/EjbPrototype/StatefulEjb
            // I tested with java:global/EjbPrototype/ejb.StatefulEjb 
            // I tested with java:app/EjbPrototype/StatefulEjb 
            // I tested with java:module/EjbPrototype/StatefulEjb
            // I tested with java:comp/EjbPrototype/StatefulEjb but no luck
            itemIds = (ListElementRemoteForStateful)ic.lookup("java:global/EjbPrototype/StatefulEjb");

           }
           catch(Exception e)
           {
               System.out.println(e);
           }
    }
%>

I have following result produced by accepted answer of SOQ enter image description here

Community
  • 1
  • 1
Veshraj Joshi
  • 3,544
  • 3
  • 27
  • 45
  • I doubt it. More likely the `lookup()` throws a `NamingException` of some kind. – user207421 Mar 22 '17 at 05:21
  • Exactly @EJP, I saw it in neatbeans console but nullpointer exception in web browser .... what should be the path there – Veshraj Joshi Mar 22 '17 at 06:07
  • So it didn't return null, it threw a `NamingException`, as predicted, which you ignored, and subsequently got a `NullPointerException`, which is the real subject of your question. So fix your title and your question. Without knowing more of your configuration it is impossible for anybody to tell you the correct path. – user207421 Mar 22 '17 at 06:16
  • But without adding anything that would indicate to anybody what the correct path is. – user207421 Mar 22 '17 at 07:21
  • Could you help me what should I present here... like. Should i present the result of accepted answer of http://stackoverflow.com/questions/2324937/code-to-list-all-the-entries-in-jndi-on-remote-machine @EJP and thanks for your reply – Veshraj Joshi Mar 22 '17 at 07:26
  • sir could you help me please @EJP – Veshraj Joshi Mar 22 '17 at 07:49
  • What you should present here is whatever exactly it is that makes you think that looking up `"java:global/EjbPrototype/StatefulEjb"` should work. – user207421 Mar 22 '17 at 08:09
  • not working ... – Veshraj Joshi Mar 22 '17 at 08:11
  • **What do you mean 'not working'?** Don't talk nonsense here. Nobody has given you a solution to try and see if it works. What you've been *asked for* is configuration information, and so far you have completely failed to supply it. – user207421 Mar 22 '17 at 09:51

0 Answers0