ejb@glassfish.java.net

EJB Class Cast Exception

From: Lichtenwalter, Ryan <ryan.lichtenwalter_at_lmco.com>
Date: Tue, 26 Sep 2006 15:51:07 -0500

Greetings,

I am working with EJBs in the Sun Java System Application Server 9. When
I follow these instructions:

InitialContext ic = new InitialContext();
Foo foo = (Foo) ic.lookup("FooEJB");

On my code, which is as follows:

Context theContext = new InitialContext();
QueryLibraryBean theBean =
(QueryLibraryBean)theContext.lookup("jdbc/QueryLibraryEJB");
theBean.getData();

I get the following exception:


java.lang.ClassCastException: QueryLibrary._QueryLibraryRemote_Wrapper
        at test.Main.main(Main.java:14)

Upon further examination, I found that the lookup call, which is in fact
contacting the application server and finding my QueryLibrary bean, is
not returning the QueryLibraryBean object, but is instead returning a
wrapper class, _QueryLibraryRemote_Wrapper


I do not know how my code differs from the example you provide on your
"glassfish: EJB FAQS" page, but I am at a loss as to how I can correct
this.

Ryan Lichtenwalter
Lockheed Martin Corporation
Software Development
651-456-7590