3 Replies Latest reply on Aug 9, 2002 4:36 PM by crozierm

    EAR's and classloaders

    crozierm

      Hello,

      There are dozens of posts regarding this issue, but I still don't understand how the classloader behaves for a deployed EAR. What I really want to know is how I can share jar files between web and ejb modules. If possible, can I have my EJB interfaces/stubs and common utilities contained in a jar at the EAR level without duplicating them in the war/ejb jars? Not only would it be a more simple file layout, but it would be easier to distribute the "common jar" to clients outside the EAR.

      I've tried adding "Class-Path: lib/common.jar"-like entries to MANIFEST.MF in the ear, web and ejb modules without any luck.

      If this is not possible, fine, but various posts in the forums indicate that it SHOULD be possible and I'm frustrated that I cannot get it to work. If somebody could shed some light on this or point me to a clear and concise description, I would appreciate it very much.

      -Michael

        • 1. Re: EAR's and classloaders
          sgturner

          Your questions are not specific to JBoss, but are specific to the J2EE spec. I suggest you find yourself a good reference. I reccommend "Java Server Programming J2EE 1.3 Edition" Wrox Press

          • 2. Re: EAR's and classloaders
            tbfmicke


            >
            > I've tried adding "Class-Path: lib/common.jar"-like
            > entries to MANIFEST.MF in the ear, web and ejb
            > modules without any luck.
            >

            The Class-Path: has worked for me (one utility jar with a bean that is used both from the webapp and an EJB.
            You should not need to have it in the .ear MANIFEST.MF, only in the webapps and ejb.

            I think there needs to be a newline after the Class-Path: line (or two :-) ). Have you checked that the manifest file is put correctly in the jar? (Inside the META-INF directory). You must give it separately to the jar command when creating the webapp/ejb (flag -m maybe?).

            Regards

            • 3. Re: EAR's and classloaders
              crozierm

              My goodness, the -m option in jar. Being pretty new to the J2EE game, I didn't realize that whatever MANIFEST.MF I included in the files list for jar wouldn't neccessarily be kept if I didn't specify it with -m.

              Why is the most frustration always causes by the dumbest problem?

              Thanks!