Stateful session bean returns null

Hi,
I call a stateful session bean which should return a Long object. Everything works fine while the bean executes and the Long object is returned by the bean.
But in the EJB-Client I get a null object.
The EJB-Client is a OC4J 10g standalone server and the EJB-Server is a OC4J 9.03 server, both running on the same machine.
Here are the JNDI properties:
java.naming.factory.initial=com.evermind.server.rmi.RMIInitialContextFactory
java.naming.provider.url=ormi://localhost:23791/ws
java.naming.security.principal=admin
java.naming.security.credentials=slash
dedicated.rmicontext=true
dedicated.connection=true
Thanks for your help,
A.

Hi,
Store HomeObject or EJB Object in the Session in the WebTier.
Anil

Similar Messages

  • Update object returned by a business method in stateful session bean

    I have a business method in stateful session Bean returning an Object "myObject getObject()". This object can be modified by the client.
    Is it necessary at the end to notify the bean about the changes with some kind of business method "setObject(Object myObject)"? or
    the client and the bean have the same reference to the object and it isn't necessary?
    Thanks

    When an EJB returns a value, it is serialised across the wire and is effectively lost to the EJB. Any changes to the returned object by the client, will have to be notified by a call on the EJB, as in your post.
    Dave

  • SAME EJB 3.0 Stateful Session bean for different JSP sessions returned

    Forum,
    I have a strange problem utilizing stateful session beans. Please note, that I am using jdeveloper for the following:
    1) Here is a basic stateful session bean:
    @Stateful(name = "DemoClass")
    public class DemoClassBean implements DemoClass,
               DemoClassLocal, SessionSynchronization {
          public static int id=0;
          public DemoClassBean() {
          id++;
          public int getId() {
             return id;
          //... other methods
    }2) This bean is accessed from a JSP for testing purpose, I am copying only the script used in JSP:
    <%
       DemoClass bean = null;
       try {
          bean = (DemoClass) ((new javax.naming.InitialContext()).
                       lookup("DemoClass "));
          System.out.println("ID=" + bean.getId() );
          } catch (javax.naming.NamingException e) {
             // TODO
    %>If this page is addressed by different clients, from different browsers, the same bean is returned.
    Here is what I see in the logs:
    ID=1
    ID=1
    ID=1
    The same problem is being observed when this session bean is accessed from a JSF Backing bean.
    What could be wrong? Is this a bug in oc4j / jdeveloper (version 10.1.3.3.0)?
    Edited by: smw000000001 on Nov 17, 2008 10:52 AM

    Hi,
    The code for stateful is perfectly fine and working in a normal way. The way you are trying to implement the stateful session bean in your application is wrong.
    think of binding the stateful session bean with HttpSession object.
    So that you will get a unique stateful session bean object.

  • Context.lookup in a Servlet always returns the same Stateful Session Bean

    Hi,
    I am working on an application in which a Servlet should obtain one StateFul Session Bean per client. I read in EJB 3.0 in Action that to do so I should use a jndi lookup and save the result of the lookup in an HttpSession. This works fine for me when I have a single client.
    My issue is that when I have several clients, context.lookup returns the same SFSB for each client. This means that I end up having a single SFSB for the whole application. I've been browsing the web for a while now trying to find a solution but haven't had any luck yet.
    The code I use to obtain and save the SFSB is the following:
    HttpSession session = request.getSession(true);
    DFMServiceRemote service = (DFMServiceRemote) session.getAttribute("DFMService");
    if (null == service)
         service = (DFMServiceRemote) new InitialContext().lookup("DFMService");
         session.setAttribute("DFMService", service);
    }Using different browser, I end up with different HttpSession but a single SFSB. The only workaround I found is to create the context with environment variables or properties. It then returns different SFSBs for different HttpSession. The workaround code is as below:
    Hashtable<String, String> env = new Hashtable<String, String>();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "com.evermind.server.rmi.RMIInitialContextFactory");
    env.put(Context.SECURITY_PRINCIPAL, "oc4jadmin");
    env.put(Context.SECURITY_CREDENTIALS, "welcome");
    env.put(Context.PROVIDER_URL, "ormi://localhost:23791/DriverFatigue");
    service = (DFMServiceRemote) new InitialContext(env).lookup("DFMService");My question is the following. How can I get a different instance of an SFSB every time I execute context.lookup without specifying properties.
    Thanks in advance for any help,
    Matthieu Siggen

    I just did something similar in another project using JBoss instead of oc4j and didn't have any problem. I expect I missed a configuration file in oc4j or there is a conflict somewhere.

  • EJB 3.0 Session bean transfers null Entity

    Hello all
    I am having trouble trying to transfer an Entity from a stateful session bean to a JSP. When I try an identical method with a java client within the OC4J container of JDeveloper, it works fine. However when I deploy the application to OracleAS 10.1.3, I get a null pointer on the entity.
    Please help. I have been stuck on this for about 3 weeks, and I've followed documentation to the letter as far as I can see.
    Here is the code for the JSP, the (simplified) bean and the Entity in question.
    Bean:
    import java.util.List;
    import javax.annotation.Resource;
    import javax.ejb.Stateful;
    import javax.persistence.EntityManager;
    import javax.persistence.Query;
    @Stateful(name="cart")
    public class CartBean implements CartRemote, CartLocal  {
        @Resource
        protected EntityManager manager;
        public CartBean() {
             public User getUser(String username){
                    User user = manager.find(User.class, username);
             return user;
        }The JSP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="com.evotec.ereq.CartLocal" %>
    <%@ page import="com.evotec.ereq.User" %>
    <%@ page import="javax.naming.InitialContext" %>
    <%@ page import="java.util.List" %>
    <%@ page import="java.util.ArrayList" %>
    <%!String m_username = "pbarrett";%>
    <%!String emailAddress = "";%>
    <%
    try {
        InitialContext ctx = new InitialContext();
        CartLocal cart = (CartLocal) ctx.lookup("java:comp/env/cart");
            User user = cart.getUser(m_username);
            emailAddress = user.getEmailAddress();
    %>
    <html>
    <body>
    you are: <%= m_username %><BR>
    your email address is: <%= emailAddress %><BR>
    </body>
    </html>
    <%
    catch (Exception e){
        e.printStackTrace();
    %>and the User entity:
    import java.io.Serializable;
    import java.sql.Timestamp;
    import static javax.persistence.AccessType.FIELD;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Table;
    import javax.persistence.Id;
    @Entity(access=FIELD)
    @Table(name="USERS")
    public class User implements Serializable {
        @Column(name="CREATION_DATE")
        protected Timestamp creationDate;
        @Column(name="DISPLAY_NAME")
        protected String displayName;
        @Column(name="EMAIL_ADDRESS")
        protected String emailAddress;
        @Id
        @Column(name="USERNAME")
        protected String username;
        @Column(name="USER_ID")
        protected Long userId;
        @Column(name="USER_STATUS")
        protected Long userStatus;
        public User() {
              //JDeveloper-generated getters and setters
    }I should point out that I have established that the null pointer is not coming from the CartLocal lookup.
    Any help welcome, thanks in advance.
    Paul

    Hi,
    Thanks for the quick response.
    I have tried this approach before but when I try and deploy to the server, I get this message:
    @PersistenceContext annotation can only be used when a javax.spi.PersistenceProvider is installed.
    Is this a missing jar file? If so, which one?
    Thanks
    Paul

  • Initialize a stateful session bean from another

    Hi,
    I am trying to create and initialize a stateful session bean from another stateful session bean. The code is as follows
    This method belongs to DefaultSessionBean where it creates the AdminSessionBean based on few checks and returns it to the client.
        public AdminSession getAdminSession() throws UnknownException, WarningException {
            checkSessionUser("getAdminSession");
            if (isAdmin()) {
                AdminSession adminSession;
                try {
                    final Context context = IToolsUtil.getInitialContext();
                    adminSession = (AdminSession)context.lookup("AdminSession");
                    System.out.println("Successfully created the adminsession bean");
                } catch (NamingException ne) {
                    ne.printStackTrace();
                    throw new UnknownException (new CatalogHelper("ITOOLS_100019", new Object[]{"Admin", ne.getMessage()}));
                System.out.println("adminsession will be returned");
                return adminSession;
            } else {
                throw new WarningException (new CatalogHelper("ITOOLS_000042", sessionUser.getUserhandle()));
        }Another method in DefaultSessionBean, creates its local interface and returns it.
        public DefaultSessionLocal getDefaultSessionLocal() {
            DefaultSessionLocal dsl = (DefaultSessionLocal)context.getBusinessObject(DefaultSessionLocal.class);
            System.out.println("local created.");
            return dsl;
        }Client call initialize method of the AdminSessionBean which is mentioned below:
        public void initialize(DefaultSession ds) throws WarningException, UnknownException {
            this.ds = ds.getDefaultSessionLocal();
            this.rfl = ReadFieldList.getInstance();
            this.fm = new FinderMethods();
        }The client code where it gets the adminSession and initializes is
       public static AdminSession getAdminSession(DefaultSession ds) throws ViewException {
            AdminSession as;
            try {
                as = ds.getAdminSession();
                System.out.println("got admin session");
            } catch (WarningException we) {
                 we.printStackTrace();
                throw new ViewException(we.getCatalogHelper());
            } catch (UnknownException ue) {
                ue.printStackTrace();
                throw new ViewException(ue.getCatalogHelper());
            } catch (OracleRemoteException ore) {
                ore.printStackTrace();
                throw new ViewException(new CatalogHelper("ITOOLS_050003", ore.getMessage()));
            // Initialize Admin Session
            try {
                System.out.println("before getting it.");
                as.initialize(ds);
                System.out.println("adminsession is initialized");
            } catch (WarningException we) {
                as.remove();
                as = null;
                throw new ViewException(we.getCatalogHelper());
            } catch (UnknownException ue) {
                as.remove();
                as = null;
                throw new ViewException(ue.getCatalogHelper());
            } catch (OracleRemoteException ore) {
                as.remove();
                as = null;
                throw new ViewException(new CatalogHelper("ITOOLS_050003", ore.getMessage()));
            System.out.println("got admin session");
            return as;
        }Apart from this I am using OC4J 10.1.3.1 tool test my application.
    When I am calling initialize method of the AdminSession I am getting the following error.
    06/10/24 12:26:08 Entered
    06/10/24 12:26:08 got default session
    06/10/24 12:26:08 Successfully created the adminsession bean
    06/10/24 12:26:08 adminsession will be returned
    06/10/24 12:26:08 got admin session
    06/10/24 12:26:08 before getting it.
    2006-10-24 12:26:08.156 WARNING J2EE RMI-00009 Exception returned by remote server: {0}
    06/10/24 12:26:08 com.itools.vs.view.exception.ViewException
    06/10/24 12:26:08      at com.itools.vs.view.util.ViewUtil.getAdminSession(ViewUtil.java:71)
    06/10/24 12:26:08      at com.itools.vs.view.backing.Admin.CreateUser.submit_action(CreateUser.java:182)
    06/10/24 12:26:08      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    06/10/24 12:26:08      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    06/10/24 12:26:08      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    06/10/24 12:26:08      at java.lang.reflect.Method.invoke(Method.java:585)
    06/10/24 12:26:08      at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:146)
    06/10/24 12:26:08      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:92)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.AjaxActionComponent.broadcast(AjaxActionComponent.java:88)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:274)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:250)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:405)
    06/10/24 12:26:08      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:95)
    06/10/24 12:26:08      at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:245)
    06/10/24 12:26:08      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:110)
    06/10/24 12:26:08      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:213)
    06/10/24 12:26:08      at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:67)
    06/10/24 12:26:08      at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:223)
    06/10/24 12:26:08      at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
    06/10/24 12:26:08      at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
    06/10/24 12:26:08      at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
    06/10/24 12:26:08      at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
    06/10/24 12:26:08      at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
    06/10/24 12:26:08      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
    06/10/24 12:26:08      at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
    06/10/24 12:26:08      at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    06/10/24 12:26:08      at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
    06/10/24 12:26:08      at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
    06/10/24 12:26:08      at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
    06/10/24 12:26:08      at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
    06/10/24 12:26:08      at java.lang.Thread.run(Thread.java:595)
    06/10/24 12:26:08 ITOOLS_050003: Failed to get Admin Session.
    Exception is "Error marshalling objects, Not Serializable: java.io.NotSerializableException: DefaultSession_RemoteProxy_6nein01; nested exception is:
         java.io.NotSerializableException: DefaultSession_RemoteProxy_6nein01".
    [b/                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Your remote client passes a DefaultSession to AdminSession.initialize(..). This DefaultSession has to be a remote type. In your client, how does it get DefaultSession?
    Did your client look up DefaultSession, and have it return a (sessionContext.getBusinessObject(DefaultSession.class))? If so, it should work.

  • Stateful session bean destroying instance variables?

    I'm trying to use a stateful session bean as some kind of login controller and to maintain the login id and access level across JSPs and HTMLs so that once logged in, all the JSPs can obtain the login name of the current user (String) and his access level (int).
    I use the login.jsp to login and it successfully reports logging in with the correct access level retrieved from database. However, if I go to another JSP (testlogin.jsp), these 2 EJB instance variables are always destroyed and set to null and 0 when I access them again.
    What am I missing that my stateful session bean is not saving these instance variables? Do I need to put them in some serializable value objects (create a help VO class?)
    I suspected that on different JSP, I call the MemberControllerHome.create() method, it creates a new instance or something but if I don't use the create method how do I get a handle to MemberController at all?
    MemberControllerBean.java
    public class MemberControllerBean implements SessionBean {
         //initialize in ejbCreate.
         private MemberHome memberHome;
         SessionContext context;
         //Member currentLogin;
         //Current Login
         private String loginID;
         private int accessLevel;
         // Constructor
         public MemberControllerBean() {}
    ...some code in between...
    public void login(String id, String password){
              try{
                   Member member = null;
                   member = memberHome.findByPrimaryKey(id);
                   if(member.getMPassword().equals(password)){
                        this.loginID = member.getMID();
                        this.accessLevel = member.getMAccessLevel();
                   else{
                        throw new EJBException("Login failed. Invalid member ID and/or password.");
              } catch (FinderException ex) {
                   throw new EJBException("Login failed. Invalid member ID and/or password.");
         public void logout(){
              this.loginID = null;
              this.accessLevel = 4;
         public String getLoginID(){
              return this.loginID;
         public int getLoginAccessLevel(){
              return this.accessLevel;
    login.jsp
    String mID = request.getParameter("mID");
    String mPassword = request.getParameter("mPassword");
    out.println("20:" + mID + ":" + mPassword);
    if(mID != null && mPassword != null){
         out.println("22:" + mID + ":" + mPassword);
         try{
              InitialContext ic = new InitialContext();
              MemberControllerHome home = (MemberControllerHome) ic.lookup("java:comp/env/ejb/MemberController");
              MemberController mc = home.create();
              out.println("26:Logging in as " + mID + " with " + mPassword);
              mc.login(mID, mPassword);
              out.println("28:" + mc.getLoginID() + "logged in successfully at level " +
                   mc.getLoginAccessLevel() + ".");
         } catch (NamingException ex) {
              out.println("java:comp/env/ejb/MemberController not found.");
         } catch (EJBException ex) {
              out.println(ex.getMessage());
         } catch (Exception ex) {
              out.println(ex.getMessage());
    testlogin.jsp
    <%
    try{
         InitialContext ic = new InitialContext();
         MemberControllerHome home = (MemberControllerHome) ic.lookup("java:comp/env/ejb/MemberController");
         MemberController mc = home.create();
         out.println("You are logged in as <b>" + mc.getLoginID() +
              "</b> at level <b>" + mc.getLoginAccessLevel() + "</b>.");
    } catch (NamingException ex) {
         out.println("java:comp/env/ejb/MemberController not found.");
    } catch (EJBException ex) {
         out.println(ex.getMessage());
    } catch (Exception ex) {
         out.println(ex.getMessage());
    %>

    The key to the problem is that in testlogin.jsp a new stateful session bean is created. The new bean instance of course doesn't know the log-in information you stored in the old session bean. That is why the method returns null and 0 when called.
    There are couple of ways to solve the issue. The easiest solution is to store the bean instance created in Login.jsp in the jsp's implicit HttpSession object. Because login.jsp and testlogin.jsp share the same session, the bean instance can be easily stored and retrieved.
    Here is the code you need to have:
    1. in login.jsp
    session.setAttribute("MemberControllerBeanInstance", mc);
    2. in testlogin.jsp
    MemberController mc =
    (MemberController) session.getAttribute("MemberControllerBeanInstance");
    Hope it helps.

  • Problem using application client for local stateful session bean

    Hi,
    I have deployed a local stateful session bean in Sun J2EE 1.4 application server.
    On running the applclient for the stateful session bean application client i get the following error:
    Warning: ACC006: No application client descriptor defined for: [null]
    cant we use application client for local stateful session beans. becoz the application runs smoothly when i changed the stateful sesion bean to remote.

    Hi,
    No, an ejb that exposes a local view can only be accessed by an ejb or web component packaged within the same application. Parameters and return values for invocations through the ejb local view are passed by reference instead of by value. That can't work for an application client since it's running in a separate JVM.
    --ken                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • My weblogic 7 can not run stateful session bean??

    Hi,all
    I create a stateful session bean in jbuilder 7 and deploy it to weblogic 7,it
    successed.The Home interface have a method like this:
    public TestRemote create(int var) throws RemoteException, CreateException;
    But the client test bean call the create(int var) method throwing
    a exception :
    java.lang.IllegalArgumentException: wrong number of arguments
    Start server side stack trace:
    java.lang.IllegalArgumentException: wrong number of arguments
         at java.lang.reflect.Constructor.newInstance(Native Method)
         at weblogic.rmi.internal.OIDManager.makeActivatableServerReference(OIDManager.java:203)
         at weblogic.rmi.internal.OIDManager.getReplacement(OIDManager.java:129)
         at weblogic.common.internal.RemoteObjectReplacer.getReplacement(RemoteObjectReplacer.java:265)
         at weblogic.common.internal.RemoteObjectReplacer.replaceObject(RemoteObjectReplacer.java:107)
         at weblogic.common.internal.ChunkedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:53)
         at weblogic.common.internal.ChunkedObjectOutputStream$NestedObjectOutputStream.replaceObject(ChunkedObjectOutputStream.java:239)
         at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:323)
         at weblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObjectOutputStream.java:107)
         at weblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:82)
         at com.berserk.ejb.Test_a6z4o8_HomeImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
         at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:762)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:295)
         at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
    End server side stack trace
    -- Failed: create(0)
         at weblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:109)
         at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:127)
         at com.berserk.ejb.Test_a6z4o8_HomeImpl_WLStub.create(Unknown Source)
         at com.berserk.ejb.TestClient1.create(TestClient1.java:102)
         at com.berserk.ejb.TestClient1.main(TestClient1.java:199)
    -- Return value from create(0): null.
    Then I deploy it to the borland application server 4.5,it did work!!
    Somebody can help me ?thx

    Try throwing a CreateException in ejbCreate (int var).
    Jackie wrote:
    hi,Sabha:
    My source codes is like this.
    the home interface:
    import java.rmi.*;
    import javax.ejb.*;
    public interface TestHome extends EJBHome
    public TestRemote create(int var) throws RemoteException, CreateException;
    the remote interface :
    import java.rmi.*;
    import javax.ejb.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public interface TestRemote extends EJBObject
    public void saycool() throws java.rmi.RemoteException;
    the stateful bean:
    import java.rmi.*;
    import javax.ejb.*;
    public class Test implements SessionBean
    private SessionContext sessionContext;
    private int m_var;
    public void ejbCreate(int var)
    this.m_var=var;
    public void ejbRemove()
    public void ejbActivate()
    public void ejbPassivate()
    public void setSessionContext(SessionContext sessionContext)
    this.sessionContext = sessionContext;
    public void saycool() throws java.rmi.RemoteException
    System.out.println("so cool");
    the client test class:
    import javax.naming.*;
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2002</p>
    * <p>Company: </p>
    * @author unascribed
    * @version 1.0
    public class TestClient1
    static final private String ERROR_NULL_REMOTE = "Remote interface reference
    is null. It must be created by calling one of the Home interface methods first.";
    static final private int MAX_OUTPUT_LINE_LENGTH = 100;
    private boolean logging = true;
    private TestHome testHome = null;
    private TestRemote testRemote = null;
    //Construct the EJB test client
    public TestClient1()
    long startTime = 0;
    if (logging)
    log("Initializing bean access.");
    startTime = System.currentTimeMillis();
    try
    //get naming context
    Context ctx = getInitialContext();
    //look up jndi name
    Object ref = ctx.lookup("TestRemote");
    //cast to Home interface
    testHome = (TestHome) PortableRemoteObject.narrow(ref, TestHome.class);
    if (logging)
    long endTime = System.currentTimeMillis();
    log("Succeeded initializing bean access.");
    log("Execution time: " + (endTime - startTime) + " ms.");
    catch(Exception e)
    if (logging)
    log("Failed initializing bean access.");
    e.printStackTrace();
    private Context getInitialContext() throws Exception
    String url = "t3://lettam:7001";
    String user = null;
    String password = null;
    Properties properties = null;
    try
    properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    properties.put(Context.PROVIDER_URL, url);
    if (user != null)
    properties.put(Context.SECURITY_PRINCIPAL, user);
    properties.put(Context.SECURITY_CREDENTIALS, password == null
    ? "" : password);
    return new InitialContext(properties);
    catch(Exception e)
    log("Unable to connect to WebLogic server at " + url);
    log("Please make sure that the server is running.");
    throw e;
    // Methods that use Home interface methods to generate a Remote interface
    reference
    public TestRemote create(int var)
    long startTime = 0;
    if (logging)
    log("Calling create(" + var + ")");
    startTime = System.currentTimeMillis();
    try
    testRemote = testHome.create(var);
    if (logging)
    long endTime = System.currentTimeMillis();
    log("Succeeded: create(" + var + ")");
    log("Execution time: " + (endTime - startTime) + " ms.");
    catch(Exception e)
    if (logging)
    log("Failed: create(" + var + ")");
    e.printStackTrace();
    if (logging)
    log("Return value from create(" + var + "): " + testRemote + ".");
    return testRemote;
    // Methods that use Remote interface methods to access data through the bean
    public void saycool()
    if (testRemote == null)
    System.out.println("Error in saycool(): " + ERROR_NULL_REMOTE);
    return ;
    long startTime = 0;
    if (logging)
    log("Calling saycool()");
    startTime = System.currentTimeMillis();
    try
    testRemote.saycool();
    if (logging)
    long endTime = System.currentTimeMillis();
    log("Succeeded: saycool()");
    log("Execution time: " + (endTime - startTime) + " ms.");
    catch(Exception e)
    if (logging)
    log("Failed: saycool()");
    e.printStackTrace();
    public void testRemoteCallsWithDefaultArguments()
    if (testRemote == null)
    System.out.println("Error in testRemoteCallsWithDefaultArguments():
    " + ERROR_NULL_REMOTE);
    return ;
    saycool();
    // Utility Methods
    private void log(String message)
    if (message == null)
    System.out.println("-- null");
    return ;
    if (message.length() > MAX_OUTPUT_LINE_LENGTH)
    System.out.println("-- " + message.substring(0, MAX_OUTPUT_LINE_LENGTH)
    + " ...");
    else
    System.out.println("-- " + message);
    //Main method
    public static void main(String[] args)
    TestClient1 client = new TestClient1();
    client.create(0);
    // Use the client object to call one of the Home interface wrappers
    // above, to create a Remote interface reference to the bean.
    // If the return value is of the Remote interface type, you can use it
    // to access the remote interface methods. You can also just use the
    // client object to call the Remote interface wrappers.
    Thank you for your help!!
    "Sabha" <[email protected]> wrote:
    Can you attach the sources of your ejb. Thanks.
    -Sabha
    "Jackie Lee" <[email protected]> wrote in message
    news:[email protected]...
    Hi,all
    I create a stateful session bean in jbuilder 7 and deploy it to weblogic7,it
    successed.The Home interface have a method like this:
    public TestRemote create(int var) throws RemoteException,CreateException;
    But the client test bean call the create(int var) method throwing
    a exception :
    java.lang.IllegalArgumentException: wrong number of arguments
    Start server side stack trace:
    java.lang.IllegalArgumentException: wrong number of arguments
    at java.lang.reflect.Constructor.newInstance(Native Method)
    atweblogic.rmi.internal.OIDManager.makeActivatableServerReference(OIDManager.j
    ava:203)
    at weblogic.rmi.internal.OIDManager.getReplacement(OIDManager.java:129)
    atweblogic.common.internal.RemoteObjectReplacer.getReplacement(RemoteObjectRep
    lacer.java:265)
    atweblogic.common.internal.RemoteObjectReplacer.replaceObject(RemoteObjectRepl
    acer.java:107)
    atweblogic.common.internal.ChunkedObjectOutputStream.replaceObject(ChunkedObje
    ctOutputStream.java:53)
    atweblogic.common.internal.ChunkedObjectOutputStream$NestedObjectOutputStream.
    replaceObject(ChunkedObjectOutputStream.java:239)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:323)
    atweblogic.common.internal.ChunkedObjectOutputStream.writeObject(ChunkedObject
    OutputStream.java:107)
    atweblogic.rjvm.MsgAbbrevOutputStream.writeObject(MsgAbbrevOutputStream.java:8
    2)
    at com.berserk.ejb.Test_a6z4o8_HomeImpl_WLSkel.invoke(Unknown Source)
    at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:346)
    at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:300)
    atweblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:762)
    atweblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:295)
    atweblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:3
    0)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:152)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:133)
    End server side stack trace
    -- Failed: create(0)
    atweblogic.rmi.internal.BasicOutboundRequest.sendReceive(BasicOutboundRequest.
    java:109)
    at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:127)
    at com.berserk.ejb.Test_a6z4o8_HomeImpl_WLStub.create(Unknown Source)
    at com.berserk.ejb.TestClient1.create(TestClient1.java:102)
    at com.berserk.ejb.TestClient1.main(TestClient1.java:199)
    -- Return value from create(0): null.
    Then I deploy it to the borland application server 4.5,it did work!!
    Somebody can help me ?thx
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

  • How to track the stateful Session Bean?

    Hi all,
    Am in a serious trouble. I have a message driven bean which will get initiated when some message gets dumped into the queue. I have got session bean which i use to process message which my message driven bean takes from the queue.
    My problem is, lets say there are 3 msgs in the queue. lets say the messages be "aaaa", "aaaa" and "bbbb".
    In this case, when i read the first message, i will create an instance of the session bean to process the message "aaaa". When i receive the second message still i create an instance to process the message "aaaa". When i get the 3rd message, i create an instance to process the message "bbbb".
    My problem in this is, i want to create only one instance of session bean for the message "aaaa".
    So once i create the instance for session bean for particular message, i need to store the object or something of the instance which i created along with the message. Please help me with what i can store with which i can reffer to the session bean again.
    Please see the sample code too.
    Thanks in advance,
    Ashly
    if(msg.equals("aaaa"))
    First n;
    Object obj = ctx.lookup("ejb/First");
    FirstHome home = (FirstHome) PortableRemoteObject.narrow(obj, FirstHome.class);
    n = home.create(msg);
    }

    Hi,
    thanks for information. But i have one question. In a stateful session bean why do we have to store the Remote Interface on the client side.
    I expected in the second jsp page when i do a lookup or create, the container/server should find out whether there is a session bean already created for this session if yes, then return that particular instance of the session bean else create a new one.
    If this is not a possible case then a stateful session bean is nuthing but an instance of an object in the EJB container which does not get destroyed unless there is a time out or the remove method is called. It has nuthing to do with session because throughout the session I have to store the remote interface in the session context of the client( the client here means the jsp).
    thanks in advance
    Anurag

  • Stateful session Bean in Model not working

    I made a sample application very very simple, and the weblogic server cant find the @stateful annotation on the class. is it there another possibility? here i post the error i get:
    [Running application MyTest1 on Server Instance IntegratedWebLogicServer...]
    [09:48:51 PM] ---- Deployment started. ----
    [09:48:51 PM] Target platform is (Weblogic 10.3).
    [09:48:52 PM] Retrieving existing application information
    [09:48:52 PM] Running dependency analysis...
    [09:48:52 PM] Deploying 3 profiles...
    [09:48:53 PM] Wrote Web Application Module to /home/issanllo/.jdeveloper/system11.1.1.2.36.55.36/o.j2ee/drs/MyTest1/ViewWebApp.war
    [09:48:53 PM] Wrote EJB Module to /home/issanllo/.jdeveloper/system11.1.1.2.36.55.36/o.j2ee/drs/MyTest1/ModelEJB.jar
    [09:48:53 PM] Wrote Enterprise Application Module to /home/issanllo/.jdeveloper/system11.1.1.2.36.55.36/o.j2ee/drs/MyTest1
    [09:48:53 PM] Deploying Application...
    <03-jun-2010 21H48' CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1275594533727' for task '2'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(ModelEJB.jar)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    No EJBs found in the ejb-jar file {0}. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation..'
    weblogic.application.ModuleException: Exception preparing module: EJBModule(ModelEJB.jar)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    No EJBs found in the ejb-jar file {0}. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation..
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:454)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:391)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:59)
         Truncated. see log file for complete stacktrace
    Caused By: java.io.IOException: No EJBs found in the ejb-jar file {0}. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation.
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:219)
         at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
         at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1210)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:382)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
         Truncated. see log file for complete stacktrace
    >
    <03-jun-2010 21H48' CEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'MyTest1'.>
    <03-jun-2010 21H48' CEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    weblogic.application.ModuleException: Exception preparing module: EJBModule(ModelEJB.jar)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    No EJBs found in the ejb-jar file {0}. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation..
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:454)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:391)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:59)
         Truncated. see log file for complete stacktrace
    Caused By: java.io.IOException: No EJBs found in the ejb-jar file {0}. Please ensure the ejb-jar contains EJB declarations via an ejb-jar.xml deployment descriptor or at least one class annotated with the @Stateless, @Stateful or @MessageDriven EJB annotation.
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:219)
         at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
         at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1210)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:382)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199)
         Truncated. see log file for complete stacktrace
    >
    #### Cannot run application MyTest1 due to error deploying to IntegratedWebLogicServer.
    [09:48:54 PM] #### Deployment incomplete. ####
    [09:48:54 PM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)
    [Application MyTest1 stopped and undeployed from Server Instance IntegratedWebLogicServer]
    and the very simple class with a Local and Remote interfaces at Model project in jDeveloper 11g (11.1.1.3)
    package test.core;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Local;
    import javax.ejb.Remote;
    import javax.ejb.Stateful;
    @Stateful(name = "ControlSessionBean", mappedName = "MyTest1-Model-ControlSessionBean")
    public class ControlSessionBean implements ControlSessionRemote,
    ControlSessionLocal
    private String username;
    private String password;
    public ControlSessionBean()
    public List simple()
    List <String> s = new ArrayList();
    s.add(username);
    s.add(password);
    return s;
    any suggestions why it is not working??
    sincerely
    Israel S Llorens

    not working... i tried to make the stateful session bean Control.. and is still not working the error i get now is this one:
    <04-jun-2010 16H29' CEST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1275661769594' for task '9'. Error is: 'weblogic.application.ModuleException: Could not setup environment'
    weblogic.application.ModuleException: Could not setup environment
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1499)
         at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:442)
         at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:375)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
         at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:95)
         Truncated. see log file for complete stacktrace
    Caused By: weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'gecu.view.LoginBean/controlBean' from module 'GeCU_Web_view_root' of application 'GeCU_Web'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'gecu.model.ControlSession' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
         at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:427)
         at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:502)
         at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
         at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3117)
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1497)
         Truncated. see log file for complete stacktrace
    >
    <04-jun-2010 16H29' CEST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 9 task for the application 'GeCU_Web'.>
    <04-jun-2010 16H29' CEST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'GeCU_Web'.>
    <04-jun-2010 16H29' CEST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    weblogic.application.ModuleException: Could not setup environment
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1499)
         at weblogic.servlet.internal.WebAppModule.activate(WebAppModule.java:442)
         at weblogic.application.internal.flow.ModuleStateDriver$2.next(ModuleStateDriver.java:375)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:41)
         at weblogic.application.internal.flow.ModuleStateDriver.activate(ModuleStateDriver.java:95)
         Truncated. see log file for complete stacktrace
    Caused By: weblogic.deployment.EnvironmentException: [J2EE:160200]Error resolving ejb-ref 'gecu.view.LoginBean/controlBean' from module 'GeCU_Web_view_root' of application 'GeCU_Web'. The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because no EJBs in the application were found to implement the 'gecu.model.ControlSession' interface. Please link or map this ejb-ref to its target EJB and ensure the interfaces declared in the ejb-ref are correct.
         at weblogic.deployment.BaseEnvironmentBuilder.autowireEJBRef(BaseEnvironmentBuilder.java:427)
         at weblogic.deployment.EnvironmentBuilder.addEJBReferences(EnvironmentBuilder.java:502)
         at weblogic.servlet.internal.CompEnv.activate(CompEnv.java:157)
         at weblogic.servlet.internal.WebAppServletContext.activate(WebAppServletContext.java:3117)
         at weblogic.servlet.internal.WebAppModule.activateContexts(WebAppModule.java:1497)
         Truncated. see log file for complete stacktrace
    >
    [04:29:35 PM] #### Deployment incomplete. ####
    [04:29:35 PM] Remote deployment failed

  • Share stateful session bean in JSF managed beans with different scope

    Hi,
    I have a JSF application and I want to try to use of stateful session beans.
    So I created a new stateful session bean and its local interface.
    @Stateful
    public class StatefulSessionBean implements StatefulSessionBeanLocalInterface{
    private String name;
    @Local
    public interface StatefulSessionBeanLocalInterface {
    ...In my JSF application I have a mananed bean with session context which registers the new interface by
    this annotation
    @EJB(name="sessionbeanref", beanInterface=StatefulSessionBeanLocalInterface.class) and set the name to something.
    Now I want to fetch this name in another managed bean with request scope. So I looked up the bean and tried to get the name.
    StatefulSessionBeanLocalInterface = (StatefulSessionBeanLocalInterface) new InitialContext().lookup("java:comp/env/sessionbeanref");
    System.out.println(currentmailingbean.getName());but the name is null.
    Why?

    The xsd was created via the netbeans J2EE enterprise application dialog and I think its the most recent.
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">All other annotations seem to work.
    Wouldnt the lookup completely fail if the deployment process thought that it is version 1.4 ?

  • Howto call the @Remove method of a stateful session bean after JSF page ...

    I use EJB3, JPA, JSF in my web application. There are 2 database tables: Teacher and Student. A teacher can have many (or none) students and a student can have at most 1 teacher.
    I have a JSF page to print the teacher info and all his students' info. I don't want to load the students' info eagerly because there's another JSF page I need to display the teacher info only. So I have a stateful session bean to retrieve the teacher info and all his students' info. The persistence context in that stateful session bean has the type of PersistenceContextType.EXTENDED. The reason I choose a stateful session bean and an extended persistence context is that I want to write something like this without facing the lazy initialization exception:
    <h:dataTable value="#{backingBean.teacher.students}" var="student">
        <h:outputText value="${student.name}"/>
    </h:dataTable>Because my session bean is stateful, I have a method with the @Remove annotation. This method is empty because I don't want to persist anything to the database.
    Now, my question is: How can I make the @Remove method of my stateful session bean be called automatically when my JSF page finishes being rendered?

    Philip Petersen wrote:
    I have a few questions concerning the EJB remove method.
    1) What is the purpose of calling the remove method on stateless session
    bean?There isn't one.
    >
    2) What action does the container take when this method is called?It checks that you were allowed to call remove (a security check) and then
    just returns.
    >
    3) What happens to the stateless session bean if you do not call the remove
    method?Nothing
    >
    4) Is it a good practice to call the remove method, or should the remove
    method be avoided in the case of stateless session beans?
    Personally, I never do it.
    -- Rob
    >
    >
    Thanks in advance for any insight that you may provide.
    Phil--
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com
    [att1.html]

  • How to get the Stateful Session bean instance in the second call

    Hi,
    I am new to EJBs. I have made a Stateful session bean on the first jsp page. In this page i am setting certain member variables of the EJB. Now in the second page i want to get these stored values in the EJB.
    In the second page do I...
    1. Store the instance of Remote Interface in the Session Context of the first JSP page and then in the second page get the Remote interface stored in its session context and call the business functions to get the values. If this is the case then what do u mean by Stateful Session beans??
    P.S.- This works fine.
    2. Try to get the Remote interface of that particular instance of the EJB(in which the values were stored) and call its business functions. IF this is possible. How do i do it??
    thanks in advance
    Anurag

    Hi,
    thanks for information. But i have one question. In a stateful session bean why do we have to store the Remote Interface on the client side.
    I expected in the second jsp page when i do a lookup or create, the container/server should find out whether there is a session bean already created for this session if yes, then return that particular instance of the session bean else create a new one.
    If this is not a possible case then a stateful session bean is nuthing but an instance of an object in the EJB container which does not get destroyed unless there is a time out or the remove method is called. It has nuthing to do with session because throughout the session I have to store the remote interface in the session context of the client( the client here means the jsp).
    thanks in advance
    Anurag

  • Stateful session bean

    I am creating a web application using JSPs and want to keep stateful information from one call to the next.  In the first jsp I run the code:
    InitialContext ic = new InitialContext();
    StatefulTestLocal testbean = ((StatefulTestLocalHome)ic.lookup("java:comp/env/ejb/StatefulTestBean")).create();
    testbean.setUsername(request.getParameter("uname"));
    In the second JSP I run the code:
    InitialContext ic = new InitialContext();
    StatefulTestLocal testbean = ((StatefulTestLocalHome)ic.lookup("java:comp/env/ejb/StatefulTestBean")).create();
    testbean.setUsername(request.getParameter("uname"));
    out.println("<hr>Username get<br>");
    out.println(testbean.getUsername());
    out.println("<hr>");
    The second JSP always prints null for the username.  I always thought when creating a stateful session bean, it looks for an instantiated class that is tied to the client and then if it isn't found, creates a new class.  It appears to always be creating a new object.
    Every example I see, shows then creating the stateful and then stuffing it into the session.  Is this really the way to do it?

    I am creating a web application using JSPs and want to keep stateful information from one call to the next. In the first jsp I run the code:
    InitialContext ic = new InitialContext();
    StatefulTestLocal testbean = ((StatefulTestLocalHome)ic.lookup("java:comp/env/ejb/StatefulTestBean")).create();
    testbean.setUsername(request.getParameter("uname"));
    In the second JSP I run the code:
    InitialContext ic = new InitialContext();
    StatefulTestLocal testbean = ((StatefulTestLocalHome)ic.lookup("java:comp/env/ejb/StatefulTestBean")).create();
    testbean.setUsername(request.getParameter("uname"));
    out.println("<hr>Username get");
    out.println(testbean.getUsername());
    out.println("<hr>");
    The second JSP always prints null for the username. I always thought when creating a stateful session bean, it looks for an instantiated class that is tied to the client and then if it isn't found, creates a new class. It appears to always be creating a new object.
    Every example I see, shows then creating the stateful and then stuffing it into the session. Is this really the way to do it?

Maybe you are looking for