Skip to main content

MDB(Message Driven Bean) failing on server startup

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2014-06-03


I've already posted this question on SO:

Several people seem to have the same problem(see links at the bottom):

If you startup a glassfish(v 4) server with an MDB(Message Driven Bean) and there are messages to be consumed, the MDB will start consuming the messages while the container is still initializing. If the message processing requires any other service from the container it will throw an exception:

Caused by: javax.ejb.EJBException: Attempt to invoke when container is in Initializing
Has anyone managed to solve this problem?

Ideally the MDB should only start consuming messages after the container is fully initialized.

Is there a way to let the MDB check for container initialization and only start accepting messages when the container is up and running?

Thanks for any feedback!