Simplest Possible, Annotation-Less EJB 3.1 📎
The Bean is just a POJO - without any dependencies to libraries etc:
public class MessageFacade {
public String hello(){
return "Working without annotations";
}
}
You will need to specify everything in XML:
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
         version = "3.1"
         xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd">
   <enterprise-beans>
    <session>
        <ejb-name>MessageFacade</ejb-name>
        <local-bean/>
        <ejb-class>com.abien.patterns.business.annotationless.boundary.MessageFacade</ejb-class>
        <session-type>Stateless</session-type>
    </session>
   </enterprise-beans>
</ejb-jar>
Now you can use already the no-interface view Bean and inject it into a servlet (JSF backing beans, interceptors, other beans):
public class FrontController extends HttpServlet {
@EJB
MessageFacade facade;
//...
With XML (ejb-jar.xml) you could develop the whole application without even having the EJB 3.X API in your classpath...
This sample was deployed as a WAR. The ejb-jar.xml has to be placed into WEB-INF.
The project (AnnotationLessEJB31) was pushed into: http://kenai.com/projects/javaee-patterns/. The code was tested with Netbeans 6.7 and Glassfish v3 Prelude. Netbeans 6.7, however, does not support EJB 3.1 directly. You will have to copy the ejb-jar.xml from src/java/conf into build/web/WEB-INF/ manually or change the ANT-script.
[Its one of the introductory samples (Chapter 1) from the "Real World Java EE Patterns" book]