@EJB annotation - which error handling is appropriate?

The @EJB annotation can be used in "managed clients" to access the EJB.

You can put this annotation in a servlet class by declaring a member variable.

public class MyServlet extends HttpServlet {
     @EJB
     private MyWorkerInterface theWorker;
}

This @EJB annotation has been extended to JNDI requests that (I assume) are executed when servlet is initialized. These JNDI requests may fail: the EJB provider can modify its annotations to specify specific JNDI names, then a different JNDI name must be specified for the @EJB link, or the search will fail.

Also, I think, since EJB can be remote, there is the possibility of transients, network failures and server errors.

My thought: when using theWorker I have to check its authenticity.

  if ( theWorker == null ) {
      // ... etc.

My questions:

1.) ?

2.) , , , ? . , ? ?

3.) : , , JNDI- , @EJB. ?

+3
1

, JBoss.

1) , .
2) , - , . . -, . RemoteException, RemoteException, , - . , tx , , tx.
3) , JNDI, DI (, @EJBFromHost2). JNDI , JNDI ( , ).

+3

Source: https://habr.com/ru/post/1718113/


All Articles