tags:

views:

347

answers:

3

What happens, if an EJB3 stateless/stateful bean no args constructor throws an exception? For example, class A has a DI:

@EJB
B b;

and B throws an exception in the constructor? I didn't find any mention for this case in EJB3 specs. I'd guess that the isntance of class A gets discarded, because it really has no means for succeeding in its task.

A: 

IME if any of your EJBs fail to initialize when staring the application the appserver knows a problem occurred and does not flag your application as being available.

When this happens your EJB / Web URLs are not available...

Tom
I'm thinking of a case where instatiation of B fails for some reason when a new stateless bean A is instantiated. Deployment of the application has been successful.
tputkonen
A: 

Typically a null pointer exception when you try to use b.

Voytek Jarnot
A: 

javax.ejb.EJBTransactionRolledbackException

when you use a method of b.

davideconsonni