Default EJB transaction mode for asynchronous methods?

Similar to an MDB the transaction is started by the container just before your @Asynchronous, @Schedule or @Timeout method (and applicable interceptors) is actually invoked and committed just after the method (and interceptors) completes. As per usual, the transaction propagates to all beans called in said method and all beans those beans call, recursively. Of … Read more

What is the difference between @Inject and @EJB

@EJB injects EJBs only, but @Inject can be used to inject POJOs rather than EJBs. However, @Inject requires that your archive be a BDA (contain beans.xml for EE 6, or implicitly in EE 7). @Inject also has additional CDI-specific capabilities (scopes, interceptors, etc.), but those capabilities incur extra overhead. Application servers have support for specifying … Read more

Difference between @Stateless and @Singleton

You’re seeing the same output because there is only one client accessing the EJB at a time. The application server is able to recycle the same stateless EJB object for each call. If you try a concurrent access – multiple clients at the same time – you’ll see new stateless instances appearing. Note that, depending … Read more

Stateless and Stateful Enterprise Java Beans

Stateless Session Beans (SLSB) are not tied to one client and there is no guarantee for one client to get the same instance with each method invocation (some containers may create and destroy beans with each method invocation session, this is an implementation-specific decision, but instances are typically pooled – and I don’t mention clustered … Read more

What is an EJB, and what does it do?

Why really use them? (Why not just stick to POJO?) IF you need a component that accesses the database, or accesses other connectivity/ directory resources, or is accessed from multiple clients, or is intended as a SOA service, EJBs today are usually “bigger, stronger, faster (or at least more scalable) and simpler” than POJOs. They … Read more

tech