aga5tya
aga5tya

Reputation: 55

Library dependencies outside WAR file

I have a requirement where i need to pack all the common classes of various web services and make them as dependencies(To avoid duplicates for multiple services). The structure of my EAR file is as follows:

    META-INF/MANIFEST.MF
    META-INF/application.xml
    commons-codec-1.2.jar
    MyWebService1.war
    MyWebService2.war
    MyWebService1.jar
    MyWebService2.jar
    EJB_Bean.jar

Now i have included the dependency jar's under WAR file's Manifest as follows(Not sure if appropriate), `

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.7.0_51-b13 (Oracle Corporation)
Class-Path: MyWebService1.jar

In the stated structure when i try to deploy the EAR file onto web-logic server, i get java.lang.NoClassDefFoundError, But whereas if i move the dependency jars under WEB-INF/lib folder of my WAR and repack my EAR file, Deployment goes fine as expected.

Is there any way i can include my WAR file dependency libraries outside WAR file or even outside my EAR file is my question. Any help or suggestion would be appreciated.

Upvotes: 1

Views: 2368

Answers (3)

trikelef
trikelef

Reputation: 2204

A simple way to set the libraries of an EAR package is to create a lib folder right under the the EAR root and put your libraries inside.

In this case you will have something like this in your EAR:

META-INF/MANIFEST.MF
META-INF/application.xml
MyWebService1.war
MyWebService2.war
lib/commons-codec-1.2.jar
lib/MyWebService1.jar
lib/MyWebService2.jar
EJB_Bean.jar

Upvotes: 2

Martin
Martin

Reputation: 7714

My first advice would be to use some kind of dependency management such as Maven, Gradle or Ivy - doing that by yourself is very difficult and error prone.

A simpler solution in your case would be to take your "common jars" (especially if they are shared between multiple applications), and add them to the shared library of your webserver. As an example, Tomcat will load all librairies that are placed under tomcat-dir/common/lib directory.

Upvotes: 0

Pranav Maniar
Pranav Maniar

Reputation: 1565

In tomcat jar files can be placed inside the lib directory and these jar files gets available to all the applications deployed on that server. In web-logic there must be the similar way to do it. A lib folder from where the web-logic server loads all the jar files.

Upvotes: 0

Related Questions