I've read the threads about NoSuchObjectException and found out that JBoss throws this exception when an EJBException invalidates a stateful session bean.
Now, imagine I have a JSP page that creates this bean. The user takes some action that results in an EJBException.
Next, when the user tries to retry his action, the JSP page uses the same bean and a NoSuchObjectException is thrown.
The problem is that I only want to recreate the bean if it is neccessary, that is, when the bean is invalid. How can one figure out if a bean is valid or not in JBoss?
I can create a dummy method in every bean and call that method in the beginning of every JSP page, catch the NoSuchObjectException and in such case recreate the bean, but is that the only/recommended way?