InitialContext Lookup returns the same Stateful Session Bean Ref


EJB programming & troubleshooting: InitialContext Lookup returns the same Stateful Session Bean Ref

  1. Hello, In my current project I am facing a strange problem: whenever I want to get my Stateful Session Bean remote object , I get always the same reference. So all clients get the same remote object on server side ... which is of course not the incentive by the Stateful Session Beans model... I have written a small test application which behaves exactly the same as my projects application ... here the code : the SFSB : testBean code: @Stateful(mappedName="testEJB") public class testBean implements testRemote { public int quantity = 0; public void buy (int quantity){ this.quantity += quantity; } public int getQuantity(){ return quantity; } the Remote Interface: testRemote code: @Remote public interface testRemote { public void buy(int quantity); public int getQuantity(); } the test JSP code: <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="test.*,javax.naming.*"%> Insert title here <% InitialContext ic = new InitialContext(); testRemote tr = (testRemote) ic.lookup(testRemote.class.getName());
    <%= tr.toString() > Also I am using Eclipse Europe Winter IDE & Glassfish v2 Everytime it returns the same reference for the SFSB Object , ... I don't know why this happens ... is it a fault by me or is it a Bug on Server Side ?? I just don't know ... ... I also tried it with Servlet Injection but the result is the same , I guess it's my fault but I have no clue how to solve it ... thanks in advance ... LHD

    Threaded Messages (1)

  2. Scope[ Go to top ]

    How are you accessing this JSP? If you are using an automation tool, you can often specify the scope for each access - make sure that each access is not using the same HTTP Session, which might be responsible for what you are seeing. If you are manually hitting the page from a browser, be sure to open a separate physical copy of the browser for your sequential page accesses. Using a new tab will not automatically force a new HTTP session.