3

Do I package a stateless session bean in a war file or a ear file for deployment?

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
user422930
  • 259
  • 1
  • 5
  • 15

3 Answers3

1

Neither nor. EJBs belong in standard JAR files (with a META-INF/ejb-jar.xml). In order to use EJBs from a WAR you pack these two archives in an EAR.

Since this is not really convenient it's possible since EJB 3.1 to package EJBs in the WAR.

musiKk
  • 14,751
  • 4
  • 55
  • 82
0

Stateless Session Beans (SLSB) are packaged in an EJB-JAR (which is a regular JAR file) including or not an optional deployment descriptor. EJB-JARs and WARs are assembled in an EAR for deployment.

See this article by Debu Panda and Rezza Rahmann (which is actually an extract from the excellent EJB 3 in Action):

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
0

With EJB 3.1/Java EE 6 you don't need EAR files any more, you can also put your session beans directly in a WAR file (as a separate .class file in WEB-INF/classes, or inside a JAR file within the WAR file's WEB-INF/lib directory). See e.g. http://java.sun.com/developer/technicalArticles/JavaEE/JavaEE6Overview_Part3.html#simpack

Stefan L
  • 1,529
  • 13
  • 20