Reputation: 2551
I want to handle a login scenario as follows:
I am currently doing the second step as:
return new StatefulBean(some params);
Is this the right way to do it? It does not seem to me as I get the exception:
Class org.eclipse.persistence.internal.jpa.EntityManagerImpl is not Serializable
when running my application, and I think it is related to the described method.
What would be the correct way to return a reference to the SFJB from the SLJB to the client?
Upvotes: 1
Views: 243
Reputation: 3769
As Tomasz mentions, you probably need to rethink your flow.
That said, you can get a hold of a new stateful instance by doing a JNDI lookup, using the portable JNDI name that us assigned to each bean at startup.
Upvotes: 1
Reputation: 340733
First of all, this is completely wrong:
new StatefulBean(some params)
EJB container is responsible for creating and destroying instances of beans, you should never create them manually.
In your scenario I would reverse the flow: the client connects to the stateful bean which might stateless session bean as a helper. No need to pass beans around, client always uses the same bean.
Upvotes: 3