[jboss-user] [EJB 3.0] - Re: Problem running Stateless bean with JBOSS 4.0.4 GA and E

delkant do-not-reply at jboss.com
Tue May 8 15:38:04 EDT 2007


this: 

context.lookup("TestStatelessBean/remote");

is the rigth way... but here you will recive a remote interface, that is what you are requesting with the "/remote" part...

so.. you have to cast it to ....

(TestStateless)context.lookup("TestStatelessBean/remote");

your servlet have tobe something like this:


  | public class TestStatelessEJBServlet extends HttpServlet {
  | 
  | /**
  | *
  | */
  | private static final long serialVersionUID = 1L;
  | private TestStateless testRemoteInterface;
  | 
  | public void init() {
  | try {
  | Context context = new InitialContext();
  | System.out.println("Before lookup");
  | testRemoteInterface = (TestStateless) context.lookup("TestStatelessBean/remote");
  | System.out.println("After lookup");
  | 
  | } catch (NamingException e) {
  | // TODO Auto-generated catch block
  | e.printStackTrace();
  | }
  | }
  | 
  | public void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
  | PrintWriter writer = resp.getWriter();
  | writer.write("The stateless bean returned this string: " +
  | TestStateless.testBean());
  | }
  | 
  | public void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {
  | this.doGet(req, resp);
  | }
  | } 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4044046#4044046

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4044046



More information about the jboss-user mailing list