Is there some magic to using Stateful beans from the GWT servlet?

46 views
Skip to first unread message

Bruce Petro

unread,
Jan 15, 2010, 5:20:05 PM1/15/10
to Google Web Toolkit
OK, I admit it - i'm stumped... If I use stateless session beans, I can find and access the stateless bean as follows...

AccountSessionRemote sessionBean = null;
     try {
sessionBean = (AccountSessionRemote) ServiceLocator.getInstance().getRemote(AccountSessionRemote.RemoteJNDIName);
    } etc....

(I won't go into the plumbing but the ServiceLocator uses the IC and brings back the right item... )

HOWEVER, if I try the exact same on a STATEFUL session bean - it fails with a ClassCastException (note that it is not a lookup failure).  I even tried replacing this lookup with the old fashioned ic context lookup and again the "find" succeeds but gives a classCastException when it goes to cast the return from the lookup.  

AccountStatefulSessionRemote statefulSessionBean=null;
     try {
        statefulSessionBean = (AccountStatefulSessionRemote) context.lookup(AccountStatefulSessionRemote.RemoteJNDIName);
    } etc....

java.lang.ClassCastException: $Proxy134

We debugged during these steps and everything looks good - inspecting the lookup appears to have the right thing.

What am I missing here????

PS: I'm ignoring for the moment the housekeeping stuff to attach the stateful bean to the session, etc... we're not getting to first base yet.
PPS: JUnitTests can load this bean just fine using the same code.  It only seems to fail when run within the context of the GWT Servlet.

bpetro

unread,
Jan 15, 2010, 5:50:40 PM1/15/10
to Google Web Toolkit
Apologies - I forgot to mention - we're using 1.6.4, not 2.0 and we're
running in JBoss 4.3.0GA if that matters.
We have tried both local and remote with no success.
All tests work fine with stateless and fail with stateful.
Reply all
Reply to author
Forward
0 new messages