2 Replies Latest reply on Mar 14, 2002 9:40 AM by David Yuan

    get value object throws ClassCastException from a stateless

    David Yuan Newbie

      Hi all,

      I use JBoss3.0Beta with builtin tomcat. EJB and servlet are deployed separately. The stateless session bean (SecurityOfficerBean) has a method getUser(String loginname) that retrieves an entity bean (Userbean) and returns a serialized value object. From the log message, I can see that the session bean did find the user entity entry correctly and a new value object is instantiated with correct content and returned to the caller (the servlet). But the servlet never received the value object.


      Following is the logic in the session bean:

      ========================
      SecurityOfficer.getUser(String loginname) {
      UserHome userHome = UserUtil.getHome();
      User ul = userHome.findByPrimaryKey((loginname));
      UserData ud = ul.getData();
      CAT.debug("UserData: " + ud);
      return ud;
      }
      =====================


      Here is the code in my servlet:
      =================
      try {
      InitialContext jndiContext = new InitialContext();
      Object ref = jndiContext.lookup
      ("users/SecurityOfficer");
      SecurityOfficerHome userManagerHome =
      (SecurityOfficerHome)PortableRemoteObject.narrow
      (ref, SecurityOfficerHome.class);
      SecurityOfficer userManager = userManagerHome.create();
      UserData user = (UserData)userManager.getUser
      (loginname);
      } catch (Exception x) {
      CAT.error("Cannot retrieve user: " +
      x.getMessage());
      x.printStackTrace();
      }
      CAT.debug("user=" + user);
      ===================

      Here is the complete stack trace:
      16:49:39,078 DEBUG [SecurityOfficerBean] Return it...UserData={loginname=dyuan...(complete user entity bean contentomitted here)}
      16:49:39,078 DEBUG [User] Store command NOT executed. Entity is not dirty: pk=dyuan
      16:49:39,078 ERROR [LogonAction] Cannot retrieve user: com.knowledge.users.UserData
      16:49:39,078 ERROR [Default] java.lang.ClassCastException: com.knowledge.users.UserData
      16:49:39,078 ERROR [Default] at $Proxy18.getUser(Unknown Source)
      16:49:39,078 ERROR [Default] at com.knowledge.webapp.LogonAction.perform(LogonAction.java:102)
      16:49:39,078 ERROR [Default] at org.apache.struts.action.ActionServlet.processActionPerform(ActionServlet.java:1787)
      16:49:39,078 ERROR [Default] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1586)
      16:49:39,078 ERROR [Default] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:510)
      16:49:39,078 ERROR [Default] at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      16:49:39,078 ERROR [Default] at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      16:49:39,078 ERROR [Default] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      16:49:39,093 ERROR [Default] at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      16:49:39,093 ERROR [Default] at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      16:49:39,093 ERROR [Default] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
      16:49:39,093 ERROR [Default] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
      16:49:39,093 ERROR [Default] at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
      16:49:39,093 ERROR [Default] at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
      16:49:39,093 ERROR [Default] at java.lang.Thread.run(Thread.java:484)
      16:49:39,093 DEBUG [LogonAction] user=null

      David Yuan