Hi,
I am having an issue with a ClassCastException whilst trying to remote
an EJB3 entity bean.
I have a simple Entity bean "Account" which appears to function
perfectly. I then have a stateless session bean with the following
function:
public Account findAccountById(int id) {
Account a = (Account)manager.find(Account.class, id);
}
I.e. return the account that matches the given id.
In my client (on top of Tomcat 5.5 - external to JBoss - I know perhaps
that this is not currently supported, but it seems to work in most
cases), I have a call in a Spring MultiActionController:
AccountServices service = (AccountServices)
context.lookup(AccountServices.class.getName());
Account a = service.findAccountById(id);
Which causes:
java.lang.ClassCastException: db.mapping.Account
at $Proxy0.findAccountById(Unknown Source)
at
web.AccountMAController.showAccountSummary(AccountMAController.java:43)
etc..
Interestingly, if I return the account in an ArrayList from the function
findAccountById (i.e. getResultList), and pass this resultant list to a
JSP page, and inject the arraylist as a bean - I can access the members
of the Account object perfectly.
Also, if I return the Entity bean as an "Object", and pass this object
through to a jsp, this works too - i.e. i can access the members. So my
object is clearly of the type db.mapping.Account, but casting to it
causes the above exception.
This exception is the only output given (other than the full stack
trace) - nothing goes to catalina.out
I cannot fault my code, and indeed this workaround seems to work - so my
EJB is clearly returning the correct data, but I cannot cast to the
Account object from within the servlet.
I am running this on Tomcat 5.5.9.
There is no exception thrown on the JBoss Server, so there would appear
to be some issue with the Tomcat class-loader here.
Ideas anyone?
Cheers,
Alex.
--
Alexander Taylor <[EMAIL PROTECTED]>
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]