8 Replies Latest reply on Apr 10, 2006 9:03 AM by Alexander Sack

    sharing library-jar globally in EAR

    mathias Newbie

      Hello,

      I have an EAR with a WAR and a jar with some EJB's in it. I also have a "library-jar" with utility classes that i want both the WAR and EJB classes to find.

      I have been looking around and weblogic has a thing called "APP-INF" where you can put common jars for an ear. The "classloading" wiki pages are not 100% clear on this topic but it seems it is not implemented in jboss.

      By reading docs and forums here at jboss.org i haven't been able to see anything else than that the only options i have is either to put the jar both in the war and ejb-jar, to put it in server/default/lib, or to create a "java" module-entry in the application.xml for the jar.

      None of these strike me as very good, so I am wondering if someone knows about a better option or if i have missed something? What i'd really like is a APP-INF/lib folder... :)

      thanks,

      /Mathias

        • 1. Re: sharing library-jar globally in EAR
          Frank Langelage Master

          I would advise against option one and two, but what's the problem with your third option (java module entry in aplication.xml)?

          • 2. Re: sharing library-jar globally in EAR
            mathias Newbie

            Well, the "having jar in both ejb and war" seems to be kind of the standard approach which is a bit weird to me, since you need to put the same code in multiple places which is not extremely good in the case where i want all in an EAR to use the same classes

            I of course don't want to put it in default/lib for the reloading and class scoping problems.


            But, the reason i don't like the application.xml-approach either is that if i suddenly realize i need another jar, to redeploy i need to manually edit that file and add one more entry, in contrast to a lib-folder where i put stuff and it's automagically added to the classpath when i redeploy. To me, this is a big minus...


            But, of the three options i also think that the last option it's the least bad. But i still think it IS bad... anyone has any other insights?

            • 3. Re: sharing library-jar globally in EAR
              eekboom Newbie

              Can't you just put the library-jar directly in the ear and reference it in the Class-Path in the bean jar's and war's manifest?
              Seems to work for me.

              • 4. Re: sharing library-jar globally in EAR
                Weston M. Price Master

                Bingo on the last reply, that is indeed the solution. However, this will work for JBoss 4.0 and not for JBoss 3.x. Remember, at the very least to include the version of JBoss that you are using so we can be of better help.

                • 5. Re: sharing library-jar globally in EAR
                  Alexander Sack Novice

                   

                  "weston.price@jboss.com" wrote:
                  Bingo on the last reply, that is indeed the solution. However, this will work for JBoss 4.0 and not for JBoss 3.x. Remember, at the very least to include the version of JBoss that you are using so we can be of better help.



                  Weston (or anyone), can you please tell me what Classloader repository these libraries get added to when you use the MANIFEST approach?

                  I'm doing this with iBatis within an EAR but what happens is then iBAtis can not find external XML files that are part of my JAR within the EAR. I've tried even jar'ing them up into an optional library, adding it to my JAR's MANIFEST file, and that doesn't work...thought I could get both coming from the same repository. The only way I seem to be able to get it to go is to call getObject().getClassLoader() and set the thread's CurrentContextClassLoader(). But that then causes iBAtis not to find some result objects that exist in the optional library I'm trying to share across EARs.

                  I'm using 403SP1 with EAR isolation on (I believe if I set it to false, it will work but that's not what I really want).

                  Am I doing something wrong?

                  • 6. Re: sharing library-jar globally in EAR
                    Scott Stark Master

                    The deployment class loader with the manifest. Still waiting for the jira issue.

                    • 7. Re: sharing library-jar globally in EAR
                      Alexander Sack Novice

                       

                      "scott.stark@jboss.org" wrote:
                      The deployment class loader with the manifest. Still waiting for the jira issue.[/quote

                      Alright Scott, I just thought this was pilot error on my part. I will file it today (promise).]


                      • 8. Re: sharing library-jar globally in EAR
                        Alexander Sack Novice

                        http://jira.jboss.com/jira/browse/JBAS-3086

                        Hope that makes sense Scott. Again this could be pilot error on my part but so far it seems very wrong right now the way MANIFEST Class-Path entries are handled by the EAR deployer.

                        I appologize in advance if I filed the bug incorrectly! :-)!