5 Replies Latest reply on Mar 23, 2006 9:10 PM by Bill Burke

    JBoss 4.0.4rc1 deployment performance problem

    Jeff Brooks Newbie

      I encountered a performance problem when deploying a very large .ear in jboss 4.0.4rc1 with ejb3 installed.

      My ear contains 14 modules in it and many libraries. Each module has a manifest that has a Class-Path that references other modules, and some shared libraries in the ear.

      Deploying it took about 6 minutes!

      After hunting down the problem I found out the ejb3 deployer scans class files in jars (I assume to look for annotations).

      The problem is for each module in the ear the Class-Path is checked and for each entry it does some deploy logic that causes a scan.

      This is bad because if all the modules have a Class-Path that reference foo.jar, then foo.jar is scanned once per module.

      My guess is the reason this hasn?t been a problem for most people so far is most people don?t have 14 modules that reference over 20 megs of libraries causing 14 * 20 = 280 megs to scan.

      I think the behavior should be changed so that a .jar in an .ear is only scanned once.

      As a temporary workaround I was able to modify ejb3.deployer/META-INF/jboss-service.xml by adding in all my jars to IgnoredJars. Doing this reduced my deployment time to about 30 seconds.

      Jeff Brooks

        • 1. Re: JBoss 4.0.4rc1 deployment performance problem
          Bill Burke Master

          Can you explain a bit more the structure of your ear and application.xml?

          • 2. Re: JBoss 4.0.4rc1 deployment performance problem
            Bill Burke Master

            what I could do is add a switch that states whether .jar files should be ignored and only .ejb3 and .par files should be scanned....

            Please though, tell me your ear structure in more detail so that I can figure out if this is a deployer issue or just that we're screwed because we just have to scan every .jar

            • 3. Re: JBoss 4.0.4rc1 deployment performance problem
              Jeff Brooks Newbie

              The structure of the ear looks like this:

              meta-inf/application.xml
              module1.jar
              module2.jar
              ...
              module14.jar
              lib1.jar
              lib2.jar
              ...
              lib20.jar

              The application.xml contains a list of all the modules. Nothing special there.

              The only thing interesting for each module is in the manifest there is a Class-Path entry that contains the list of libraries.

              What appears to be happening is:

              foreach module do
              classpath = get module classpath

              for each item in classpath do
              deploy classpath item (includes scan of jar)
              end
              end

              If the above was switched do this it would be MUCH faster:

              foreach module do
              classpath = get module classpath

              for each item in classpath do
              if classpath item hasn't been deployed
              deploy classpath item (includes scan of jar)
              end
              end
              end


              It appears the libraries are getting scanned once per module that has a classpath entry that references it.

              The scanning of the jars appears to take about 22 seconds. The problem is 22 seconds * 14 modules is more than 5 minutes.

              I have no problem with jboss scanning the jars. I just would like jboss changed so it only scans them once per ear, instead of once per module in the ear.

              Jeff Brooks

              • 4. Re: JBoss 4.0.4rc1 deployment performance problem
                Jeff Brooks Newbie

                I did some checking in the code.

                In EJB3Deployer there is a method called accept. This method does some simple checks to see if something has the possiblity of being an ejb3 jar and if it is it exits quickly. If it can't determine if it's an ejb3 jar it eventually calls hasEjbAnnotation which scans the jar for class files with ejb3 annotations.

                The problem is it won't find any annotations for libraries so it will end up scanning all the class files in it.

                I'm new to the code for the jboss deployer but I think something like this should fix the problem:

                rename the hasEjbAnnotation method to scanForEJB3Annotation

                Add this to the EJB3Deployer

                 private Map annotationCache = new HashMap();
                
                 public boolean hasEjbAnnotation(DeploymentInfo di)
                 {
                 Boolean bool = (Boolean)annotationCache.get(di.url);
                
                 if (bool == null)
                 {
                 bool = Boolean.valueOf(scanForEJB3Annotation(di));
                
                 annotationCache.put(di.url, bool);
                 }
                
                 return bool.booleanValue();
                 }
                


                There may be a better way to do this if jboss keeps track of the libraries deployed (won't need the cache).

                Jeff Brooks


                • 5. Re: JBoss 4.0.4rc1 deployment performance problem
                  Bill Burke Master

                  I don't think this would work for redeploy. Plus, it inherently leaks. The real question is why Class-path entries in the manifest are being added to the scan. Looking into that...