Because I want to control the max capacity of my Stateful Bean, I modify standardjboss.xml.
I set "min-capacity" to 5 and "max-capacity" to 10 which "container-name" is "Standard Stateful SessionBean".
In the client code, It create 100 threads. Each thread create a remote object from the home object, and then call "noop" method in remote ojbect.
But the server is not always passivate the ejb successful, sometime it print a warnning message "Unable to passivate due to ctx lock ..." in the console.
When this happen, server seems to be in a deadlock. All the clients can't get result from the server, they will block until the transaction timeout.
EJB code:
public void noop() {
try {
File f = File.createTempFile("Temp","txt");
FileOutputStream fos = new FileOutputStream(f);
for (int i = 0; i < 1000; i++) {
fos.write("1234567890".getBytes());
}
fos.close();
f.delete();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) throws Exception{
Context ctx = getInitialContext();
Object ref = ctx.lookup("TestBean");
TestHome home = (TestHome)PortableRemoteObject.narrow(ref,TestHome.class);
Vector v = new Vector();
for (int i = 0; i < 100; i++) {
RunThread thread = new RunThread(home.create(),i);
v.add(thread);
thread.start();
}
for (int i = 0; i < 100; i++)
((Thread)v.get(i)).join();
System.out.println("All Done!");
}
public static class RunThread extends Thread {
private int id;
private Test test;
public RunThread(Test test,int id) {
this.test = test;
this.id = id;
}
public void run() {
try {
test.noop();
System.out.println("Job " + id + " Done!!!!!!!!!!!!!");
test.remove();
}
catch (Exception ex) {
System.err.println("Err:" + id + ":" + ex.getMessage());
//ex.printStackTrace();
}
}
}
Hallo man,
I have a exactly the same problem when I passicate my Statefull session bean that is calling some Entity Bean.
Any ideas ????
Jan