[jboss-user] [EJB 3.0] - "Could not find Stateful bean" exception breaks session
mighty
do-not-reply at jboss.com
Fri Aug 4 07:50:43 EDT 2006
I am using JBoss 4.0.4 GA Patch1 with the EJB3 profile to deploy an application based on JSF and EJB3. There are several Stateful Session Beans in the application which are accessed from JSF managed beans with a session scope. Here are some code snippets...
The SFSB
| @Local
| public interface BudgetManager {
|
| public Budget getBudgetByPeriodAndUnit(ReportingPeriod period, Unit unit);
|
| //other methods
|
| }
|
|
| @Stateful
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public class BudgetManagerBean implements BudgetManager {
|
| @PersistenceContext(type=PersistenceContextType.EXTENDED)
| protected EntityManager em;
|
| public Budget getBudgetByPeriodAndUnit(ReportingPeriod period, Unit unit) {
| Budget budget = (Budget) em
| .createQuery("from Budget where isunit = :unit and reportingPeriod = :period")
| .setParameter("unit", unit).setParameter("period", period)
| .getSingleResult();
|
| return budget;
| }
| // other methods
| }
|
The JSF managed bean
| public class RaidStatusBean {
| private BudgetManager budgetManager;
|
| public RaidStatusBean() {
| try {
| InitialContext ctx = new InitialContext();
| budgetManager = (BudgetManager) ctx
| .lookup("appName/BudgetManagerBean/local");
| } catch (NamingException e) {
| // Log stuff
| }
|
| }
|
| public String display() {
|
| budget = budgetManager.getBudgetByPeriodAndUnit(this.period, this.unit);
| }
|
| // other methods
| }
|
The call to display works fine for the first time, but fails afterwards if the time between calls on the SFSB > timeout of the SimpleStatefulCache. The stack trace is:
| Caused by: javax.ejb.EJBNoSuchObjectException: Could not find Stateful bean: a15221p-a8v0ft-eqgdcg5b-1-eqgfc9wj-4j at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCac
| he.java:266)
| at org.jboss.ejb3.stateful.StatefulInstanceInterceptor.invoke(StatefulInstanceInterceptor.java:59)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
| at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:199)
| at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
| at $Proxy376.getUsersByUnitAndAppUser(Unknown Source)
| at com.xxx.yyy.action.RaidStatusBean.refresh(RaidStatusBean.java:269)
| at com.xxx.yyy.action.RaidStatusBean.display(RaidStatusBean.java:201)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
| ... 34 more
I have also added lifecycle callbacks, and only the @PostConstruct method is called, the @PrePassivate, @PostActivate, @PreDestroy and @Remove methods are never called.
Now if I add the @Cache(org.jboss.ejb3.cache.NoPassivationCache.class) annotation to the SFSB, then everything works fine, as expected.
This looks to me like a problem with the SimpleStatefulCache, since it should be transparent to the application. Is there a way to work around this issue, without using the NoPassivationCache ? Could this behaviour be triggered by the fact the PersistenceContext in the SFSB is EXTENDED ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963150#3963150
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963150
More information about the jboss-user
mailing list