1 Reply Latest reply on Aug 31, 2011 12:03 PM by Thomas Goettlich

    Default EJB-Pool Per Application

    Thomas Goettlich Novice



      I hope this is the correct forum to ask my question. If not, feel free to move it.


      How would I define a default EJB-Pool per Application in JBoss 4.x and/or JBoss 5+(most likely JBoss 6.x)?


      The reason is this:


      We have several component libraries (deployed as JAR-Files) that contain stateless session beans and are used in several applications.

      We're planning to migrate the applications to JBoss 6.x but we still need to support JBoss 4.x.


      Until now, our session beans are annotated with @PoolClass, which has several drawbacks, as you can imagine:


      1. That class has been moved and renamed to @Pool as of JBoss 5.

      2. The pool configuration is the same for every application using that session bean.


      Thus, we'd like to remove the @PoolClass annotation from the session beans and configure that via XML in the application.

      However, we'd like to not have to list all session beans just to define the same default pool configuration for all.


      As of JBoss 4.x I could edit the ejb3-interceptors-aop.xml file, but that would be a per JBoss instance config.

      Since one server could host multiple applications with different requirements that's less then optimal.


      I managed to override the default annotation via a jboss-aop.xml in the ear, but unless I define a custom aspect domain that override would not be used. I could define a custom aspect domain for the session beans but here's a similar problem: the AspectDomain has been moved as of JBoss 5 and I'd like to define a default domain for all session beans in an application.


      As you can see, what we need is a solution that doesn't require to add JBoss version specific annotations to our session beans and that works for JBoss 4.x as well as the newer JBoss versions. It doesn't necessarily have to be the same solution for 4.x and 5+ since we'd have to adapt the application itself anyway, but as for our component libraries, it would be necessary not to maintain a Jboss 4.x and a JBoss 5+ version.


      Any ideas or hints on hwo that might be possible?

      Thanks in advance,




      Update: it seems like setting ScopedClassLoaderDomain#parentFirst

      to true would do the trick (I can override the "Stateless Bean" in a jboss-aop.xml file inside one of the packaged jars), however, this was just done using a debugger. There doesn't seem to be a setter and the only constructor call to set this is called with false, thus it seems there's no possibility to configure that.


      Another way might be to override Ejb3Deployment#defaultSLSBDomain

      (there is a setter) and define a custom domain per application, but I didn't find any official looking possibility to do that.


      Update 2: The actual problem seems to be the getContainer() method in the Domain class. As of JBoss AOP 1.5.6 (which is used by JBoss 4.2.3.GA) the code is as follows:



      public DomainDefinition getContainer(String name)


         DomainDefinition container = null;

         if (!(this.parentFirst))


           container = this.parent.getContainer(name);

           if (container != null) return container;


         container = super.getContainer(name);

         if (container != null) return container;

         return this.parent.getContainer(name);



      As you can see, the container is retrieved from the parent if parentFirst is false, which seems to be a bug.

      Looking at the JBoss AOP 2.0 source (I'm not sure, but it seems the version to be used by JBoss 5.1), that was changed to if(parentFirst), which makes more sense.


      Thus the question would be if this is a bug (I didn't find any filed one, however) and if so, if there is a fix.

        • 1. Re: Default EJB-Pool Per Application
          Thomas Goettlich Novice

          Looks like I've found a solution: upgrade JBoss AOP from 1.5.6 to 2.1.8 (any 2.x should do).


          The source of the problem seems to be my last observation: the if(!(this.parentFirst)) line.

          In the newer aop version this is changed and now the scoped pool definitions work like a charm.


          Thanks to the JBoss AOP developers who provided a way to use it with the "old" Jboss 4.x version.

          This should also work in JBoss 5+ since aop 2.x should be standard there, so problem solved for now