Discussions

EJB programming & troubleshooting: Bug in "Mastering Enterprise Java Beans" Deployment Descriptor


  1. In chapter 4 of "Mastering Enterprise Java Beans" book,
    there is an example of StatefulSessionBean whose source
    code is on this site). Unfortunately when executed, it does
    NOT provide the same results that the text says it should!
    Particularly, I cannot generate the Server-Side output
    listing (on Page 99) by running the code. I noticed that
    in the deployment descriptor for that example
    (weblogic-ejb-jar.xml), there is nothing that tells the
    container to keep only a maximum of 2 beans at any point of
    time. I think that is the reason why ejbActivate() and
    ejbPassivate() calls are not shown when I run the code.
    Can any one tell how to specify the bean-size in
    the deployment descriptor?
     Current deployment descriptor looks like below :
    ====================================================
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
        "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"
        "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">
    <weblogic-ejb-jar>
      <weblogic-enterprise-bean>
        <ejb-name>Count</ejb-name>
        <jndi-name>CountHome</jndi-name>
      </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    ===================================================

    I tried to put the following, inside
    <weblogic-enterprise-bean> tag, but ejbc20 (of Weblogic)
    didn't like it:
    <pool>
      <max-beans-in-free-pool>2</max-beans-in-free-pool>
      <initial-beans-in-free-pool>0</initial-beans-in-free-pool>
    </pool>

    I appreciate any pointers/help greatly.
    Thanks
     -Srini
  2. <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
        "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"
        "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">
    <weblogic-ejb-jar>
      <weblogic-enterprise-bean>
        <ejb-name>Count</ejb-name>
        <jndi-name>CountHome</jndi-name>
       
        <caching-descriptor>
        <max-beans-in-cache>100</max-beans-in-cache>
        </caching-descriptor>

      </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
  3. Thanks Neeraj. But it doesn't work. Iam running Weblogic6.1
    and ejbc20 doesn't like the "caching-descriptor" tag itself
    and gives the following error message:
    "Element type "caching-descriptor" is not declared in the
    dtd or schema".

     The problem seems to be there may not be a sure way to ever
     illustrate the passivation/activation of SFSB like the
     code in Chapter 4 of "Mastering Enterprise JavaBeans-
     Ed Roman-2nd edition". Book says so, on page 86,
     line#11: "It's up to the container to decide when
     passivation makes sense". Seems like whatever the
     deployment-descriptor settings are, we just cannot
     guarantee that the server-log would show
     passivate/activate calls like shown on page#99. If this is
     so, the example in the chapter is confusing and even
     misleading. It seems to give an impression that we can
     code in such a way to make container invoke
     activate()/passivate() calls, when in reality we just
     don't.
     Any pointers/insights are greatly appreciated.
     -Srini
  4. initial-bean-in-free-pool ...try this
  5. the desriptor looks like this

    <weblogic-enterprise-bean>
    <ejb-name>YOURBEAN</ejb-name>
    <entity-descriptor>
    <entity-cache>
    <max-beans-in-cache>200</max-beans-in-cache> </entity-cache>
    </entity-descriptor>
    </weblogic-enterprise-bean>

    for a more in depth look i refer yout to weblogic 6.0 docs.
    http://edocs.bea.com/wls/docs61/ejb/reference.html#1071069

     
  6. Even if you use a correct syntax, a limit on the number of stateful session beans in the pool doesn't seem to be working. Here is a weblogic-ejb-jar.xml formally accepted by WebLogic 6.1:

    <?xml version="1.0"?>

    <!DOCTYPE weblogic-ejb-jar PUBLIC
        "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN"
        "http://www.bea.com/servers/wls600/dtd/weblogic-ejb-jar.dtd">

    <weblogic-ejb-jar>
      <weblogic-enterprise-bean>
        <ejb-name>Count</ejb-name>
        <stateful-session-descriptor>
         <stateful-session-cache>
    <max-beans-in-cache>2</max-beans-in-cache>
    </stateful-session-cache>
        </stateful-session-descriptor>
        <jndi-name>CountHome</jndi-name>
      </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
  7. Thanks Jerzy Wirecki for the BEA 6.1 compliant
    deployment-descriptor. The interesting thing is, even after
    specifying the max-beans-in-cache to 2, the weblogic server log does NOT show any container invocations of
    "ejbPassivate()" or "ejbActivate()" ! Furthermore, I even
    changed the max-beans-in-cache to just 1 and with the
    same result. It tells me either container plainly ignores
    whatever we specify in the max-beans-in-cache AND/OR
    there is just no guaranteed way to illustrate when a
    container invokes ejbPassivate/ejbActivate calls.
    Any thoughts/insights are greatly appreciated.
    Thanks
     -Srini