Stateless EJB's ejbCreate(...) method that takes parameters is not invoked in JBoss EAP 6

Solution Verified - Updated -

Environment

Red Hat JBoss Enterprise Application Platform (EAP) 6.x

Issue

  • I am using ejb 2.1 in my current project and i am not able to pass java object in ejbCreate(...) method. The ejbCreate(Properties) is not executing by the JBoss EAP 6 server.

The Remote Home interface looks like:

public interface ExampleEJBHome extends javax.ejb.EJBHome {
   public ExampleEJB create(Properties properties) throws javax.ejb.CreateException, java.rmi.RemoteException;
}

Resolution

Passing objects into the ejbCreate method is not defined by the specification. Change the application's EJBs to have only an ejbCreate() method

Root Cause

EJB 3.1 Specification:

4.3.10.2 Stateless Session Beans
A stateless session bean that has an EJB 2.1 local or remote client view has a single create method on
its home interface. In this case, EJB 2.1 required the stateless session bean class to have a single ejb-
Create method have no arguments. Under EJB 3.1, it is not required that a stateless session bean have
an ejbCreate method, even when it has a home interface. An EJB 3.1 stateless session bean class
may have a PostConstruct method, as described in Section 4.3.4.
If the stateless session bean instance has an ejbCreate method, the container treats the ejbCreate
method as the instance’s PostConstruct method, and, in this case, the PostConstruct annota-
tion (or deployment descriptor metadata) can only be applied to the bean’s ejbCreate method.
Since stateless session bean instances are typically pooled, the time of the client’s invocation of
the create method need not have any direct relationship to the container’s invocation of the
PostConstruct/ejbCreate method on the stateless session bean instance.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.