Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing common jar files in EAR

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an EAR file. I would like to have a jar file which could be accessed by both EJB(JAR) and Web(WAR) modules with in the EAR. If i put this jar file in the top-level directory inside the .ear file is it accessible by both the EJB and Web modules? If not where should i put the common jar in EAR file to be accessed by both EJB and Web modules?

Thanks in Advance,
Srikanth.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you place the JAR file in the base directory of the EAR, and include it in the application.xml file, then it will be available to both EJBs and WAR.

In 5.0, you could also place it in the lib directory within the EAR. Then you do not need to add it to the application.xml file. I am not sure if this scheme would work on 4.2.x.
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Peter Johnson:
If you place the JAR file in the base directory of the EAR, and include it in the application.xml file, then it will be available to both EJBs and WAR.

In 5.0, you could also place it in the lib directory within the EAR. Then you do not need to add it to the application.xml file. I am not sure if this scheme would work on 4.2.x.


Peter, It worked! but, just curious to know: If we add the jar file to the class path thru manifest files(Class-Path: common.jar) in ejb-jar and war files. is common.jar accessible to both the modules?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Srikanth Reddy:
If we add the jar file to the class path thru manifest files(Class-Path: common.jar) in ejb-jar and war files. is common.jar accessible to both the modules?


I have never tried this (at least, not intentionally!) so do not know if it would work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic