2 Replies Latest reply on Dec 8, 2005 8:01 PM by 843844

    How to access a jar file in EAR file?

      I have a EAR file which contains EJB.jar file and util.jar file. Outside of EAR, I mean in client side, I need to reference util.jar file. How can I access it?

      EAR structure is
      |--|---|--- deployment descriptors...
      |--|---|--- manifest.mf
      |--|--- EJB classes

      Util.jar must be executed in server side. If I just add Util.jar in client program's classpath, when client program is executed, serverside Util.jar is executed? Or what else I should do in the client program to reference server-side Util.jar?
        • 1. Re: How to access a jar file in EAR file?
          Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
          Write another EAR file with the following structure:
          client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.

          Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.

          If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
          Points to note are:
          you have to repackage util.jar again inside this ear file.
          For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.

          Hope this helps,
          • 2. Re: How to access a jar file in EAR file?
            Thanks Sahoo. Your reply helps me to do the job right.