I've just been looking at this class after someone had a problem in the
user list and it throws a CreateException if it fails to load the bean
factory correctly. CreateException is supposed to be treated as an
application exception by an EJB container so is unlikely to be logged by
the container (it doesn't seem to be by JBoss at any rate).
Since ejbCreate is called on bean creation, rather than when the client
calls create() there's a danger the exception could be silently
swallowed when the session bean pool is being populated and the client
won't see it. Even if the server does log it, it might not obviously
correspond to the client error.
I think it might be better to just throw the BeansException directly. It
will be logged by the container and the bean will be destroyed. In fact,
it might be better to encourage this behaviour from onEJBCreate by
removing CreateException from the throws clause altogether. From a quick
look at the spec, it seems that only a runtime exception will cause the
bean to be destroyed, and I can't think of a situation with an SSB where
one would want to throw an exception on creation yet have the bean
remain in the pool to be invoked by a client later. At the very least
the BeansException should probably be logged.
What does everyone think?
I really wonder why I ever thought EJBs might be a good thing...
probably because they seemed simpler than CORBA :).
Luke.
--
Luke Taylor. Monkey Machine Ltd.
PGP Key ID: 0x57E9523C http://www.monkeymachine.ltd.uk
|