5 Replies Latest reply on Jan 21, 2009 11:37 PM by maximall

    Stateful EJB's cached in container ignored by SEAM when injected.

      Hello,


      We are using stateful EJB’s extensively in our project.  Using the Weblogic server admin console we have noticed that excessive EJB’s are created to support a single Seam invocation.  The problem is compounded when a Seam component contains injected stateful EJB’s (and they contain injected EJB’s and so on).  It appears that new EJB’s are created each time (cached ones are ignored) until the containers cached max is reached (in our case 1000 for each stateful EJB).  Once the cached max for an EJB is reached, all invocations from that point result in numerous EJB’s being passivated.  It appears some of the cached beans do get reused but very very few.  We are concerned that this will be a performance issue with multiple users hitting our application – we want to make sure we are not missing something in our configuration.


      We have configured all the EJB’s as documented in the SEAM docs for Weblogic – everything is working.  We are only using local interfaces for our EJB’s.


      Sample web.xml configuration:



      <ejb-local-ref>
           <ejb-ref-name>texdt/RoadListBean/local</ejb-ref-name>
           <ejb-ref-type>Session</ejb-ref-type>
           <local>texdt.action. RoadList</local>
           <ejb-link>RoadListBean</ejb-link>
       </ejb-local-ref>
      



      Sample ejb-jar.xml configuration:



        <interceptor-binding>
            <ejb-name>RoadListBean</ejb-name>
               <interceptor-class>org.jboss.seam.ejb.SeamInterceptor</interceptor-class>
         </interceptor-binding>
      



      Sample EJB being injected into parent stateful session bean (we have to include the @EJB annotation or an exception is thrown – similar to OC4J and Glassfish):



          @In(create=true)
          @EJB(name="texdt/RoadListBean/local")
          private RoadList roadList;
      



      We are using Seam 2.1.0.GA on the Weblogic 10.3 application server and Richfaces 3.2.2.GA for our JSF components.


      Any help would be appreciated.


      Thanks


        • 1. Re: Stateful EJB's cached in container ignored by SEAM when injected.
          maximall

          Hello,


          We are developing our project using almost the same configuration as you are.


          Try to add something like the listing below to your ejb-jar.xml.


          <session>
                  <ejb-name>RoadListBean</ejb-name>
                  <ejb-local-ref>
                          <ejb-ref-name>texdt/RoadListBean/local</ejb-ref-name>
                          <ejb-ref-type>Session</ejb-ref-type>
                          <local>texdt.action.RoadList</local>
                  </ejb-local-ref>
          </session>
          



          Afterwards you could remove @EJB annotation from the code.



          • 2. Re: Stateful EJB's cached in container ignored by SEAM when injected.

            Thanks Maxim for the suggestion.  I did try adding your recommendation in the ejb-jar.xml and I removed the @EJB annotation where the bean is being injected but unfortunately I get this exception:



            org.jboss.seam.RequiredException: @In attribute requires non-null value

            Just curious, are you running your application on Weblogic?

            • 3. Re: Stateful EJB's cached in container ignored by SEAM when injected.
              maximall

              Hello, David.


              Actually during deveping period we are deploying project on JBOSS, but I spent a lot of time and efforts to run it on Weblogic AS.


              There are a lot of problems which are not clarified in documentation. I could send you an example of our configuration files tomorrow. As far as I understant the problem is inside Weblogic container - it can not instantiate EJBs without additinal configuration in descriptors.


              Moreover one more issue was revealed. In case if you inject Stateful EJB in JSF Managed Bean using @EJB annotation than it won't be the same as if you inject the same EJB using @IN annotation. The contexts seem to be different.

              • 4. Re: Stateful EJB's cached in container ignored by SEAM when injected.

                Thanks Maxim for your help.  I'm looking at some other possibilities such as Component.getInstance() which seems to work for pulling in stateful EJB's in the SEAM context.  I could use it in cases where the price of injecting at the class level is fairly expensive for a bean that may only be used in a limited feature - such as a delete method.  In this case I could use the Component.getInstance inside the delete method and not pay for the injection everytime the parent bean is invoked for more common features.

                • 5. Re: Stateful EJB's cached in container ignored by SEAM when injected.
                  maximall

                  Hello David,


                  Have you managed to deploy successfully your seam application on Weblogic?
                  Do you use hot deployment in Weblogic during developing process?