I am using the following JNDI configuration:
final String appName = "";
final String moduleName = "session-beans";
final String distinctName = "";
final String beanName = "ItemStatefulRemote";
final String viewClassName = ItemStatefulRemote.class.getName();
final String toLookup = String.format("ejb:%s/%s/%s/%s!%s", appName, moduleName, distinctName, beanName, viewClassName);
return (ItemStatefulRemote) context.lookup(toLookup);
While trying to connect with a stateful
bean I am getting the following error:
Session id hasn't been set for stateful component:
What can be the reason?
Since it is a stateful bean so will have to add the session id which can be done by using the annotation ?stateful
along with the viewClassName
.
So the code should be changed to:
final String viewClassName = ItemStatefulRemote.class.getName()+"?stateful";