Is there a way that a Stateful Session Bean can remove itself when a transaction commits? Without this, the remove must be performed by the client that starts the transaction, which can be difficult when there may be non-stateful beans in-between.

Robert Castaneda

You could leave this to the Container or do it yourself.

Container - A solution would be to set a timeout value for the stateful session bean so that it will be removed after a shorter idle duration.

Developer - If the above is not sufficient and you need to explicitly clean up the bean, you could try posting the Stateful Session Bean's handle in a JNDI context and have another object check the context, obtain the handle and then call remove on the home interface, passing in the handle as an argument. Remember that the Handle is Serializable, so there could be many variations on this strategy.