5 Replies Latest reply on Jun 5, 2009 4:36 AM by Dean Hiller

    very very advanced seam internal code question classloading

    Dean Hiller Expert

      First context...I have a war file and a jar file full of ejbs.  I have seam components in both of those.  Seam at one point loads all the components but seems to drop the ones in the jar file and NOT install them. 


      Not sure this is classloading yet or not, but in


      ComponentDeploymentHandler.postProcess(CLassloader cl) {
            Set<ClassDescriptor> classes = new HashSet<ClassDescriptor>();
            for (ClassDescriptor classDescriptor : getClasses())
            {
               if (classDescriptor.getClazz().isAnnotationPresent(Install.class))
               {
            ....
            ....
      



      I see it load my classes from the EJB Jar AND from my war file.  Then, I also check the annotations on classDescriptor.clazz.annotations.  At this point so early I already see the seam annotations are missing from the hashtable(classDescriptor.clazz.annotations) BUT the very weird thing is the list of classes ONLY contains seam components that had the @Name annotation.  Later on in the process, it fails when it checks for isAnnotationPresent(Name.class) because it is truly not there for some reason.  Why would it be missing? 


      Anyone know anything on how the jdk works with annotations...shouldn't I get a classNotFoundException if the annotation is not in the classloader...of course, how did it know to load all of my EJB3 beans that had @Name annotation and NOT load any that did not have the @Name annotation?  This is so bizarre.
      Dean






        • 1. Re: very very advanced seam internal code question classloading
          Dean Hiller Expert

          yup, definitely a classloader issue.....I now have to stick jboss-seam.jar in jboss/server/default/lib directory to make this run and can now only run one monolithic application in jboss....our EJB jar is too big to have in each application.


          NOTE: I tried to take the annotations out of seam jar but they were tied to ScopeType which in turn was tied to Contexts :(...if only these annotations where a separate jar, I could just have the annotation jar in the lib directory and all apps could then share my EJB layer.


          Dean

          • 2. Re: very very advanced seam internal code question classloading
            Jean Luc Apprentice

            Which class loader was it? Perhaps it was the one added by Seam to support hot redeployment of classes?

            • 3. Re: very very advanced seam internal code question classloading
              Dean Hiller Expert

              nope, I don't use the hotdeploy stuff and it didn't step into hot deploy scanner really as I don't have a dev directory. 


              I believe it is basically the jboss classloader.  Since the seam annotations are in jboss-seam.jar(though I wish they were not), and jboss-seam.jar HAS to go in the war file as you cannot use the same seam in different war files due to all the static stuff, jboss-seam.jar and it's @Name annotation are in the war's classloader I believe and the xcore3.jar which is NOT inthe war file can't see those classes.  If only I could move the annotations to the jboss common lib directory, this would all work, but when I tried to do that, @Scope was dependendent on enum ScopeType which was dependent on Contexts which depended on everything :(....


              currently we now run one monolithic war file since we are forced to.  We have our war file and other jboss services using the ejb jar file in the deploy directory.  If the annotations could be pulled out of the seam-jboss.jar, that would be a big help.  From looking at the code, looks like Pete Muir wrote this part of Scanning for jar files and what not.  I am still not sure why my ejb classes can be seen from the war file's seam jar but then the ejb classes can't see back to the war file's seam jar...this is a bit weird to me unless the ejb classloader is a parent classloader.  I am not sure at how to look at the cl heirarchy in debug mode...anyone know?

              • 4. Re: very very advanced seam internal code question classloading
                Stuart Douglas Master

                Which version of jboss are you using?


                I you are up for trying something experimental I created a patch to allow seam to correctly run multiple WAR files in the same EAR. This patch should also allow you to share the seam libs between applications, as long as they all have a different application name (see the comments in the JIRA, I have not actually tested this). The patch can be found here (multi-war-appname1.diff).


                I think that if you give every war file a different application name it should work, at the very least it should allow you to package up all your wars into an ear.


                Stuart


                • 5. Re: very very advanced seam internal code question classloading
                  Dean Hiller Expert

                  sorry, nothing personal, but I can't stand ear files.  After using osgi for a while, I saw how enterprise app servers should really be including how classloaders should really be done....hopefully someday jboss will catch up there.  We stick with wars and jars on our projects so that we can redeploy stuff without redeploying the other applications......man, I wish jboss would catch up to knopflerfish as a really nice osgi implementation...still a ways to go I think.


                  we are on jboss 5.0.1.
                  later,
                  Dean