1 Reply Latest reply on Sep 22, 2005 7:27 AM by alecsandru.chirosca

    Local stateless session bean ClassCastException

    alecsandru.chirosca

      Hi to all!

      I'm developing a project based on EJB3 with JBOSS.
      At this time I have one Stateless Session Bean ant this bean is accesed in the DVD demo web, by one class that does the JNDI lookup and pushes the interface in web logic (faces).

      When I do the lookup I get :
      11:38:47,442 INFO [STDOUT] OOPS
      11:38:47,443 INFO [STDOUT] java.lang.ClassCastException: $Proxy76
      11:38:47,466 INFO [STDOUT] at ro.test.web.Utils.getAdministrareSocietati(Utils.java:14)
      11:38:47,467 INFO [STDOUT] at ro.test.web.WebBean.getUtilizator(WebBean.java:47)
      11:38:47,467 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      11:38:47,468 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      11:38:47,518 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      11:38:47,519 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      11:38:47,520 INFO [STDOUT] at org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:419)
      11:38:47,565 INFO [STDOUT] at org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:104)

      The bean does not have the remote addnotation... It does not have an admotation at all.
      The tomcat that access the ejb3 logic is embeded.
      I tested on jboss 403RC1 and RC2 with the same results.

      I'm pretty stuck here. Can anyone help me?
      Utils.java:

      public class Utils {

      public static AdministrareSocietatiBean getAdministrareSocietati(){
      try {
      InitialContext context = new InitialContext();
      return (AdministrareSocietatiBean) context.lookup(AdministrareSocietati.class.getName()); // line 14
      } catch (NamingException e) {
      e.printStackTrace();
      return null;
      }

      }
      Web Bean
      public Utilizator getUtilizator() {
      if (this.utilizator == null){
      try {
      AdministrareSocietati soc =
      Utils.getAdministrareSocietati(); // line 47
      System.out.println("Am obtinut "+soc);
      String user = FacesContext.getCurrentInstance().getExternalContext()
      .getUserPrincipal().getName();
      Utilizator ut = soc.getUtilizatorFromUsername(user);
      System.out.println("User "+ut.getNume()+"!");
      setUtilizator(ut);
      } catch (Exception e) {
      System.out.print("OOPS");
      e.printStackTrace();
      }
      }
      return this.utilizator;
      }


      BR,
      Alecs