I believe I've found the problem, however not the solution yet. The problem has to do with a transaction that is initiated by a stateless SB. So here's the scenario.
The client initiates a request for data retrieval from a remote web service API. This request is handled on the server side by a SLSB. The SLSB now queries the web service and retrieves data to put in the local database. It so happens that the web service retrieval takes a long time, more than the set transaction time and the session timeout. Now the jboss server tries either remove this bean or remove the transaction and things don't quite work out. It then creates a number of context lock messages and finally just hangs.
So that's the problem. the solution to this would be to not use SLSB for these long running tasks. I've been googling this quite a bit and it seems there's something of a Work Manager API in the new jboss and that should be able to handle such tasks.
My question now is a design question. What is the best way to handle a large computation or a large data retrieval task (whose time is going to be longer than either the session timeout or transaction timeout) using EJBs?
Is JMS an option, a work manager api or something else? Also we can now move to something of this sort. Say a user initiates a request, we want to process it at our own time and return the results to the user at some time later. So this is kind of asynchronous.
Please point me to the best solution for this problem in terms of design.
Thanks for your reply, however this does not appear to be the right solution in my case.
System.out.println("Waiting for asynbch invocation to complete");
ret = (String)future.get();
This effectively means that the client is waiting for some response for the server, however in my case my client may simply log off and wish to come back later. The next time the client logs in, some form of UI tells the client
"Welcome Mister, you task is now complete, you can retrieve your data by
thanks once again.
I think JMS is a good candidate for this.
I guess you're right, I was reading a bit about JMS and think that it would work best for our situation. Thanks a lot for your help persabi.
I'll have more questions on MDB later. :))
This post is for other ignorant people like me. Investigate the Service Activator design pattern for this problem.