aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Seting instance pool limit for stateful session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Seting instance pool limit for stateful session bean" Watch "Seting instance pool limit for stateful session bean" New topic
Author

Seting instance pool limit for stateful session bean

Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Anybody ran Ed Roman’s "Count" Stateful Session Bean example (Mastering EJB chapter 4) in weblogic 6.1 before ?
For this example, we need to limit the stateful session bean pool to only 2 beans so that we can simulate passivation and activation.
However, I don’t know how to set EJB instance pool limit for stateful EJB in WLS 6.1.
From Bea docs (ejb.pdf), only stateless session & message-driven beans’ pool can have instance limit.
<stateless-session-descriptor>
<pool>
<max-beans-in-free-pool>2</max-beans-in-free-pool>
</pool>
</stateless-session-descriptor>

So ???
Pls shed some light. Thanks.
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Even I had the same question, but for Sun's RI. But I didn't receive any replies to my post last month.
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3211
    
    6
Hi,
You guys both using wrong forum.
Did you read the forum title ?


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

SFSB are not pooled.


Groovy
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Mikalai,
U r right.Strictly speaking this question is more appropriate in the EJB forum and may be we could have even got some answers by now...
Pradeep,
What I meant was the Container's max pool size for SFSB, which I imagine is configurable for each App Server. Ed Roman's book pages, 123-130 has a good example code that shows passivation/activation for the SFSB beans, when this max limit is reached. We want to see this same example in action.
[ November 10, 2003: Message edited by: Vish Kumar ]
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Vish Kumar,
you really understand my question, thanks. (But still no answer.. )
Mikalai Zaikin,
OK...strictly speaking, this is the wrong place. How can I transfer this to the EJB forum and yet still receive email notifications of updates ? The reason I accidentally posted it here is because I am also preparing for SCBCD exam... and I frequent here.

Roman's source code are meant to be run without (or little) modification to them. He provided compilation/deployment and even client test scripts... and when these are run they should show activation/passivation in action ...like what's printed in the book. But sadly it doesn't. When I ran it, activation/passivation did not happen... limitation of 2 beans instances did not happen and all 3 beans were instantiated.

How ?
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

ok. I understood now.
http://edocs.bea.com/wls/docs70/ejb/reference.html#1071069
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1064
Cheers Pradeep,
This property sounds container specific. Not sure, if all EJB Containers support it.From the lnk, I understand it is applicable to both SFSB and Entity beans, as is activation and passivation.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

It applies to both SFSB and Entity bean.
Yes, it is container specific.
[ November 11, 2003: Message edited by: Pradeep Bhat ]
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Thanks for all the help ! From the post above, I now know that the xml property to set is max-beans-in-cache. However, when I try creating the jar, I get the following error.
C:\book\EJB20\code\StatefulSession\Count\lib>java weblogic.ejbc20 -keepgenerated tmp.jar Count.jar
ERROR: Error parsing 'META-INF/weblogic-ejb-jar.xml' line 16: The content of element type "weblogic-enterprise-bean" must match "(ejb-name,(entity-descriptor|stateless-session-descriptor|stateful-session-descriptor|message-driven-descriptor)?,transaction-descriptor?,reference-descriptor?,enable-call-by-reference?,run-as-identity-principal?,jndi-name?,local-jndi-name?)".
ERROR: ejbc found errors

Below is my weblogic-ejb-jar.xml. To me, it looks fine.


Why ?
Thanks again.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

stateful-session-descriptor should come before jndi-name, isn't?
Amer Khan
Ranch Hand

Joined: Apr 05, 2003
Posts: 163
QUOTE: stateful-session-descriptor should come before jndi-name, isn't?
-----------------------
YES!


<i>Dare to dream - everything that exists today,was once a figment of someone's imagination, nobody says tomorrow can't be a figment of your today.</i>
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
Thanks for highlighting the sequence.
Timothy Toe
Ranch Hand

Joined: Oct 19, 2002
Posts: 156
The error is gone after making sure that the order of the xml elements are right.
However, I am still unable to limit the number of SFSB instances to only 2. That is, I am still unable to simulate activation and passivation.

My ejb-jar.xml
----------------
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Count</ejb-name>
<home>examples.CountHome</home>
<remote>examples.Count</remote>
<ejb-class>examples.CountBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
My weblogic-ejb-jar.xml
------------------------
<?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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Seting instance pool limit for stateful session bean