Difference between JARs and EJB JARs from a usage perspective

2.3k views Asked by At

When I use Tomcat, the common utilities are packaged as JARs in tomcat/lib because every WAR has its own class loader, and classes and libs under the WEB-INF/lib directoy of the WAR is not visible to other ones.

When I use Jboss, the common utilities can packaged not only as JARs in jboss/lib but also as EJB JARs (invoked as services)

When I have some classes as common services, I can put them in JARs as well as EJB JARs.

I have no idea about the difference between JARs and EJB JARs from a usage perspective.

Can anyone guide me to the right path?

1

There are 1 answers

1
Praba On

The difference is clear when you see the difference between the contents of a JAR vs a EJB JAR. Apart from the source files (compiled) and the manifest that a JAR file has, you'd also need the following (back in the pre-annotation days):

  • The XML deployment descriptor
  • The beans
  • The remote and home interfaces
  • Dependencies

This tells the container which are the EJBs and their home/remote interfaces so when a request asks for a bean, the container will know which one to invoke. Without these files, there is no way of you telling the containers (except annotations wherever applicable), that this the bean implementing an interface.

More information can be found at this url