2 Replies Latest reply on Apr 24, 2006 1:34 PM by Didi

    ClassCastException after return entity from slsb method with

    Didi Newbie

      Hi!

      I am using EJB 3 quite a while and with JBoss 4.0.3SP1 everything was working fine. So I updated to 4.0.4RC1... well here is my question: I have an pretty simple stateless session bean with a method

       public UserEntityBean findUserByUsername(String username) {
       UserEntityBean user = em.find(UserEntityBean.class, username);
       System.out.println(user);
       System.out.println(user.getUsername());
       System.out.println(user.getPassword());
       System.out.println(user.getEmail());
       return user;
       }
      

      When I call this method from within a struts action via
       InitialContext ctx = new InitialContext();
       UserFacadeLocal facade = (UserFacadeLocal) ctx.lookup("um/UserFacadeBean/local");
       System.out.println(facade.findUserByUsername(username));
      

      I get the following exception
      10:09:44,265 ERROR [STDERR] java.lang.ClassCastException: neu.ejb.UserEntityBean
      10:09:44,266 ERROR [STDERR] at $Proxy73.findUserByUsername(Unknown Source)
      10:09:44,266 ERROR [STDERR] at neu.struts.action.UserAddAction.execute(UserAddAction.java:36)
      10:09:44,267 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
      10:09:44,267 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
      10:09:44,267 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
      10:09:44,267 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
      10:09:44,267 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:697)
      10:09:44,269 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
      10:09:44,269 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
      10:09:44,269 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:09:44,269 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
      10:09:44,269 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
      10:09:44,269 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
      10:09:44,270 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
      10:09:44,270 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
      10:09:44,270 ERROR [STDERR] at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:54)
      10:09:44,270 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
      10:09:44,270 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
      10:09:44,270 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
      10:09:44,271 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
      10:09:44,271 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
      10:09:44,271 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
      10:09:44,271 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
      10:09:44,271 ERROR [STDERR] at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
      10:09:44,271 ERROR [STDERR] at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
      10:09:44,272 ERROR [STDERR] at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
      10:09:44,272 ERROR [STDERR] at java.lang.Thread.run(Thread.java:595)
      

      In jira I found something similiar http://jira.jboss.com/jira/browse/EJBTHREE-174 but there no solution is posted there. And as posted there using
       public Collection<UserEntityBean> getAllUser() {
       return em.createQuery("from UserEntityBean u").getResultList();
       }
      

      works fine.

      I hope someone can help me. Thanks!