Thursday, December 17, 2009

Adding libs to ear

Many users have problems to use their libraries in their applications. But sometimes a working solution is too obvious to be noticed.
To include all the libraries you need for your project in an EAR file:
  1. Create a package project called common-libs and put all the libraries in a directory included in the Project Source Path. Don't use the src directory but lib at the same hierarchy level. Add this new directory to the Project Source Paths.
  2. Open the Application Properties
  3. Create a deployment profile for the EAR file.
  4. To include the libraries within the EAR file we have two options to include the libraries are available: either put into APP-INF/lib or a directory of your choice (eg. lib). In the Deployment Profile select Application Assembly, tick the check box of every JAR file you need and enter the directory name (APP-INF/lib or lib) in the Path in EAR text field at the bottom. This must be done for every JAR file!
  5. If you do not want to use APP_INF/lib you need to create an application.xml for the application. Open the Application Resources accordion and expand Descriptors and META-INF to see which Deployment Descriptors are available. On Descriptors, chose New JEE Deployment Descriptor... from the Context Menu and select application.xml. In the newly created application.xml insert the tag <library-directory>lib</library-directory>.
  6. From the Application Menu select Deploy to EAR File to check the contents before deploying it to the server.

No comments:

Post a Comment