[jboss-user] [JNDI and Naming] - lookup a session bean inside a servlet

stefano bertozzi do-not-reply at jboss.com
Mon May 2 12:07:30 EDT 2011


stefano bertozzi [http://community.jboss.org/people/bertoz84] created the discussion

"lookup a session bean inside a servlet"

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

--------------------------------------------------------------
Hi, 
i have a simple servlet that lookup up for a session bean in doPost:


+package webinterface.servlet;+

+import java.io.IOException;+
+import java.io.PrintWriter;+
+import javax.naming.Context;+
+import javax.naming.InitialContext;+
+import javax.naming.NamingException;+
+import javax.servlet.RequestDispatcher;+
+import javax.servlet.Servlet;+
+import javax.servlet.ServletException;+
+import javax.servlet.http.HttpServlet;+
+import javax.servlet.http.HttpServletRequest;+
+import javax.servlet.http.HttpServletResponse;+
*+import bookshop.library.entitybean.*;+*
*+import bookshop.library.sessionbean.*;+*

 +public class somethingServlet extends HttpServlet+ +implements Servlet {+
+           static final long serialVersionUID = 1L;+
+           static Context context;+
+           static          OperazioniUtenti opUser;+
+           static Utenti user;+

+          public somethingServlet() {+
+                         super();+
+          }  + 

+protected void doPost(HttpServletRequest request, HttpServletResponse response)+ +throws ServletException, IOException {+
+                    try+ 
+                    {+
+                                   context = new InitialContext();+
+*                                   System.out.println(OperazioniUtentiRemote.class.toString());* // print successfully INFO  [STDOUT] interface bookshop.library.sessionbean.OperazioniUtentiRemote+
*+                                   opUser = (OperazioniUtenti) context.lookup("/BookShop/OperazioniUtenti/remote");+*
+                    } catch (NamingException e) {+
+                                   e.printStackTrace();+
+                    }+



I get the following error :
 ERROR [STDERR] javax.naming.NameNotFoundException: BookShop not bound


I created a Web Project ( "Web" ) together with Struts in Eclipse Helios; then i added my BookShop.jar inside Web/WebContent/WEB-INF/lib
There's a problem with the JNDI lookup? Do i miss something?! I'm very new with those stuff!

thank you for helping me!!
--------------------------------------------------------------

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

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/20110502/1837d0a3/attachment-0001.html 


More information about the jboss-user mailing list