2

My application structure is

MyEAR.ear
    |-- MyWAR.war
    |-- MyEjb.jar
    |-- lib
         |- data.jar
         |- vo.jar
         |- util.jar
         |- jpa.jar     

myWAR.war has a servlet class which calls DataHelp.class which has ejb invocation.

//  MyWAR.war
Class servlet{
     DataHelper helper = new DataHelper().
     helper.getData();
}

//  lib/data.jar
Class DataHelper{
   @EJB
   MyEjb ejbBean;

    public Object  getData(){
        ejbBean.getData();
    }
}

// MyEJB.jar
@Stateless
@LocalBean
public class MyEjb {
    @PersistenceContext(unitName = "db.jpa.jar")
    EntityManager em;

    public Object getData(){
           // JPA
     }
}

MyEjb ejbBean; in DataHelper is null. I tried moving the jar next to ejb.jar. Still getting the same error.

Can you please help me configure the packaging. I need data.jar to be used in another project also, So it has to be an independent jar.

Thanks.

user418836
  • 847
  • 3
  • 8
  • 19
  • Possible duplicate of [My ear is not able to find ejb module classes](http://stackoverflow.com/questions/41306341/my-ear-is-not-able-to-find-ejb-module-classes) – Steve C Feb 10 '17 at 03:53

1 Answers1

2

To correctly work the ejb inject inside DataHelper class, data.jar should be inside MyEAR.ear as an ejb jar module, not in lib. If you want to use it in other projects, do similar by putting it as a ejb jar inside ear. Then add the following to the application.xml

<module>
    <ejb>data.jar</ejb>
</module>
Monzurul Shimul
  • 8,132
  • 2
  • 28
  • 42
  • When `data.jar` is moved to inside `myEAR.ear` as an ejb jar module....where does it end up exactly? Alongside `MyEjb.jar`? – Thufir Aug 19 '17 at 11:37