1 Reply Latest reply: Jul 23, 2009 3:41 AM by 843833 RSS

    error "ClassCastException"  in a Client(Session Bean)

      Hy at all. I use Netbeans 6.5+Jboss5.1.
      I have realized a very easy session bean and i have deploied..
      10:22:57,377 INFO  [EjbModule] Deploying tommy2 
      10:22:57,393 WARN  [EjbModule] EJB configured to bypass security. 
      Please verify if this is intended. Bean=tommy2 Deployment=vfszip:/C:/ 
      10:22:57,799 INFO  [BaseLocalProxyFactory] Bound EJB LocalHome 
      'tommy2' to jndi 'tommy2'
      Now I'm developing, in the same directory of bean project but in other
      package, a client that must to be use the bean:
      public class tommy2client { 
          public static void main(String[] args) throws NamingException, 
              if (System.getSecurityManager() == null) 
                  System.setSecurityManager(new RMISecurityManager()); 
      Hashtable env = new Hashtable(); 
      "org.jboss.naming:org.jnp.interfaces" ); 
      env.put(Context.PROVIDER_URL, "localhost:1099"); 
      Context contesto = new InitialContext(env); 
      Object riferimentooggetto = contesto.lookup("tommy2");/*OKKK*/ 
      tommy2Home istanzahome = (tommy2Home)PortableRemoteObject.narrow 
      (riferimentooggetto, tommy2Home.class);/*debug error!*/
      but a debug error is present on last row of code
      Exception in thread "main" java.lang.ClassCastException 
              at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow 
              at javax.rmi.PortableRemoteObject.narrow 
              at tommy2client.tommy2client.main(tommy2client.java:34) 
      Caused by: java.lang.ClassCastException: $Proxy0 cannot be cast to 
              at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow 
      Anyone can help me?
      Thanks at all