Several people seem to have the same problem(see this and this):
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?
Edit: Maybe the following annotation helps: @DependsOn("Dependency")