adam bien's blog

Simplest Possible EJB 3.1 📎

@Stateless
public class SimpleSample{
    public void doSomething() { /*business logic*/  }
}

How to compile:

You will need the the EJB 3.0 / 3.1 API in the classpath, or at least the @Stateless annotation.

How to deploy:

Just JAR the class and put the JAR into e.g: [glassfishv3-prelude-b23]\glassfish\domains\domain1\autodeploy

How to use:

e.g.:

import javax.ejb.EJB;
public class MyServlet extends HttpServlet{

@EJB
private SimpleSample sample;

}

And: there is no XML, strange configuration, libraries, additional frameworks or jars needed... 

See also: EJB 3 series and EJB 3.1 From Legacy To Secret Weapon.

[See also "Real World Java EE Patterns - Rethinking Best Practices", page 36]