0 Replies Latest reply on Mar 5, 2008 12:24 PM by Ben Walker

    Inject EJB 2.1 Entity Home into EJB 3.0 session beans using

    Ben Walker Newbie


      Has anyone been able to inject a 2.1 entity bean home into 3.0 session bean using the @EJB annotation in jboss-5.0.0.Beta4?

      I have tried the following (fairly sure it should work according to EJB3 spec)

      Session Fragment: -

      public class ExampleServiceBean implements ExampleService,ExampleServiceRemote,Serializable {
       private static final long serialVersionUID = -7533521006618484580L;
       private Example21EntityHome example21EntityHome;
       private static Logger logger = Logger.getLogger(ExampleServiceBean.class);
       * Does what ever you tell it too
       * @param whatToDo request text
       * @return string response text
       public String doSomething(String whatToDo) {
       String doing = "doing " + whatToDo;
       try {
       } catch (CreateException e) {
       logger.error("Unable to create 2.1 entity bean",e);
       return doing;

      Entity Fragment : -
      public abstract class Example21EntityBean extends EntityAdapter implements Serializable {
       public abstract Integer getPk();
       public abstract void setPk(Integer pk);
       public abstract String getData();
       public abstract void setData(String data);
       public Integer ejbCreate(String data) throws CreateException {
       // dummy, pk set by auto-generated-pk
       return null;
       public void ejbPostCreate(String data) {
       // empty implementation

      2.1 Entity Bean Deployment Descriptor
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
       <display-name>Example 21 Legacy</display-name>
       <description>This is the PK</description>

      However, on deployment I get the following stack trace: -
      17:13:58,517 ERROR [ProfileServiceBootstrap] Failed to load profile: Summary of incomplete deployments (SEE PREVIOUS ERRORS FOR DETAILS):
      *** CONTEXTS MISSING DEPENDENCIES: Name -> Dependency{Required State:Actual State}
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'Class:com.entitybean21.Example21EntityHome **}
       -> <UNKNOWN>{Described:** UNRESOLVED Demands 'jboss.ejb:service=EJBTimerService **}
      *** CONTEXTS IN ERROR: Name -> Error
      <UNKNOWN> -> ** UNRESOLVED Demands 'jboss.ejb:service=EJBTimerService **

      NB Packaged as two ejb jar files in the same ear to get around issue posted @ http://www.jboss.org/?module=bb&op=viewtopic&t=103268

      Has anyone tried to do something similar? Is this supported functionality?