0 Replies Latest reply on Jun 7, 2005 7:05 PM by Alex Taylor

    EJB3/Entity Bean/Remote Tomcat

    Alex Taylor Newbie

      Does anyone know how to correctly package an EJB3 entity bean so that I can return an entity bean from a call to a session bean, to a remote Tomcat session?

      I keep getting a ClassCastException in the way I am doing it now - though if I leave the return as an Object, then I can retrieve the data using Java reflection, so the data is clearly getting across.

      For example:

      I have a session bean with a function like:

      public Account findAccountById(int id) {
      Account a = (Account)manager.find(Account.class, id);
      }

      I.e. returning an instance of the entity bean "Account"

      And then from Tomcat I call it like:

      AccountServices service = (AccountServices) context.lookup(AccountServices.class.getName());
      Account a = service.findAccountById(id);


      But this gives me:

      java.lang.ClassCastException: db.mapping.Account
      at $Proxy0.findAccountById(Unknown Source)
      at web.AccountMAController.showAccountSummary(AccountMAController.java:43)


      I have heard mentions of a packaging issue here, but no one seems to know what the problem is.

      At the moment, I am including my entity beans in a .jar file within the tomcat/shared/lib directory - is this wrong?

      Any ideas would be greatly appreciated.

      Cheers,
      Alex.