This question has been asked once here EJB 3 Session Bean Design for Simple CRUD, and I just want to ask more in depth questions about this design. I already tried to ask th
1.- Your stateless bean is exposing the interface GenericCrudService (the view is what the application server registers), for that reason you use
@EJB
private GenericCrudService myEJB;
If you have multiple implementations of this interface, you can add the ejb name to the annotation for disambiguation:
@EJB(name="GenericCrudServiceBean")
private GenericCrudService myEJB;
In EJB 3.1, Session Bean without interface are exposing something called a No-Interface View. These session beans can be used only locally.
javax.ejb.Remote is an EJB 3.0 annotation, while java.rmi.Remote is a plain interface from before EJBs existed. There is no javax.rmi.Remote. And you are right, if you do not use the Remote annotation, then by default the EJB will be considered to have only a local interface.From the API doc of TransactionAttributeType.MANDATORY:
If a client invokes the enterprise bean's method while the client is associated with a transaction context, the container invokes the enterprise bean's method in the client's transaction context.
If there is no existing transaction, an exception is thrown.
You probably want to use TransactionAttributeType.REQUIRED, which automatically starts a transaction if none is present and is also the default if you use the annotation without a parameter.