JBoss Community

lookup a session bean inside a servlet

created by stefano bertozzi in JNDI and Naming - View the full discussion

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

Start a new discussion in JNDI and Naming at Community