Stateful Session Bean, After remove is called how do I create a new SFSB?
The application when is deployed creates a new SFSB, after the remove method is called the SFSB does not exist anymore, also the same happens in a timeout. How do I create a new SFSB without restarting the server?
I am using EJB 3.0
I don't understand really how in a shopping cart examples through different uses the correct SFSB is called for each user, with EJB 3.0
Also how should I store the SFSB, I always called it through JNDI lookup.
Thanks,
Zoe
> The application when is deployed creates a new SFSB,
> after the remove method is called the SFSB does not
> exist anymore, also the same happens in a timeout.
> How do I create a new SFSB without restarting the
> server?
> I am using EJB 3.0
>
Just as you created the firwst one. Assuming that you have a handle to the home object stored somehwere from your first call, you use home.create(var1, var2) or else look up the home using jndi and then call create on the home object.
> I don't understand really how in a shopping cart
> examples through different uses the correct SFSB is
> called for each user, with EJB 3.0
>
Through your remote object. Each user has got his own remote object and for SFSB, one and only one bean is tied to a remote object. It's the container's responsibility to relate the remote object and the bean.
> Also how should I store the SFSB, I always called it
> through JNDI lookup.
Store? Use a handle and if the handle is lost or an attempt to retrieve the remote object using the handle fails, look at #1 above (lookup home, create on home etc)
>
> Thanks,
> Zoe
The examples I have seen so far don't call create methods in EJB 3.0, which confuses me. The first SFSB is created automatically from the server and I assumed that the server will create every subsequent SFSB. I realized that the remote class should be stored in the web session bean for further reference.
So, I only do the following to retrieve the SFSB:
MyService is the remote class
MyServiceBean is the stateful bean
InitialContext ctx = new InitialContext();
MyService myService= (MyService) ctx.lookup("MyServiceBean");
after a call the remove method how do I create a new SFSB, I still don't understand since there is no code for ejbHome, to call a create method.