8 Replies Latest reply on Jul 31, 2003 2:32 AM by Dmitri Zamyslov

    configure shared classloader for all modules in an ear

    101 Newbie


      my problem: i have an ear with my session bean, web archive, and a hibernate sar.

      all these modules use shared jars, and i would like to put all these jars in a /lib in the ear and have the modules use it for classloading.

      currently i can do that by adding Class-Path entries to each jar (war, sar) manifest file, and it works fine except for the .sar. (could be that the war only works due to the classloader hierarchy from the session bean jar)

      if i'm not wrong it is possible to configure jboss classloader architecture from jboss-app.xml, but how? i can't find anything on the net, only the sources...

      or any other solutions?

      thanx in advance,

      - 101




        • 1. Re: configure shared classloader for all modules in an ear
          Juha Lindfors Master

          Just keep the shared JARs at the SAR level, you should not need to use manifest files at all. The default behavior is to share all libraries.

          • 2. Re: configure shared classloader for all modules in an ear
            101 Newbie

            it doesn't seem to work, did i get it right? i added all the jars (that hibernate depends on, plus hibernate) into the root of the ear. i also added my own jars (common code, persistent classes), but if i don't add the Class-Path manifest entry then my ejb deployment fails too.

            so i add everything to the ear root, add manifest fo the ejb jar, everything works except the sar deploy fails with a (hibernate) calss not found exception.

            (i have no tag anywhere, just started to play with it)

            adding all these jars to the default/lib dir solves all problem, but i would like to have a standalone ear.

            and i also had some strange behaviour: adding only _SOME_ of the jars to the default/lib that hibernate depends on resulted in this:

            2003-07-11 15:18:11,730 WARN [org.jboss.system.ServiceController] Problem starting servi>
            java.lang.NoClassDefFoundError: net/sf/hibernate/collection/Set
            at net.sf.hibernate.type.TypeFactory.set(TypeFactory.java:184)
            at net.sf.hibernate.mapping.Set.getType(Set.java:29)
            at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:856)
            at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:288)
            at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1076)
            at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
            at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
            at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
            at net.sf.hibernate.jmx.HibernateService.buildSessionFactory(HibernateService.jav>

            note that the thread is deep in the hibernate classes, and sais that a hibernate class is not found?! problem is solved if i add *.jar from the hibernate lib home to the default/lib dir. (that is i added some jars hibernate was depending on)

            i searched the entire server for another copy of hibernate2.jar, there was only one. it's way too strange for me...


            • 3. Re: configure shared classloader for all modules in an ear
              Raja Master

              The order of deployment within the deploy dir is -"sar", "service.xml", "rar", "jar", "war", "wsr", "ear", "zip".
              So ur Hibernate files(sars) are loaded before the other dependent jar files and it throws that exception as it doesnt load the jar yet(at that point!!). If you put the files in the default/lib, those are deployed before the deploy dir is even scanned. So if ur sars have a dependency of the jar files, that should take care of the exception.
              Correct me if im wrong here!! I also started playing with these dependencies lately ;-)

              -Raj

              • 4. Re: configure shared classloader for all modules in an ear
                101 Newbie


                thanks for the order, it's new info for me.

                now i just have to look up how to make my sar dependent on a jar file. this j2ee seems to be done so that they can sell a zillion books... :)

                thanks!

                • 5. Re: configure shared classloader for all modules in an ear
                  Raja Master

                  You can use the jboss-service.xml for ur sar to create the "depends" clause. Once you deployed ur jar file, you should find the object name of it in the jndiview of the jmx-console. Give that as a depends clause argument in the jboss-service.xml for ur sar.

                  I have seen some thread here that talks about how to set up hibernate(not sure if its here or the hibernate web site). That should give you a good starting point.

                  -Raj

                  • 6. Re: configure shared classloader for all modules in an ear
                    Jeff Rodgers Newbie

                    I had the same problem (minus the sar issue) and was able to resolve it with entries in the application.xml file that look like:


                    bsf.jar


                    commons-beanutils.jar


                    The jars are in the root of the EAR file.

                    • 7. Re: configure shared classloader for all modules in an ear
                      101 Newbie

                      surprisingly adding


                      foo.jar


                      to application.xml solved my problem, and works even for my .sar. seems like .jars are deployed before .sar's...

                      thanks for all the help!

                      • 8. Re: configure shared classloader for all modules in an ear
                        Dmitri Zamyslov Newbie

                        Hi!

                        for which version did it worked?

                        It doesn't work for 2.4.3. I have the same problem, but I must solve it with v.2.4.3