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

    error "ClassCastException"  in a Client(Session Bean)

    843833
      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:/ 
      Programmi/JBoss/server/default/deploy/TOMMY2-ejb.jar/ 
      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, 
      CreateException 
          { 
              if (System.getSecurityManager() == null) 
              { 
                  System.setSecurityManager(new RMISecurityManager()); 
              } 
      Hashtable env = new Hashtable(); 
      env.put(Context.INITIAL_CONTEXT_FACTORY, 
      "org.jnp.interfaces.NamingContextFactory"); 
      env.put(Context.URL_PKG_PREFIXES, 
      "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 
      (PortableRemoteObject.java:229) 
              at javax.rmi.PortableRemoteObject.narrow 
      (PortableRemoteObject.java:137) 
              at tommy2client.tommy2client.main(tommy2client.java:34) 
      Caused by: java.lang.ClassCastException: $Proxy0 cannot be cast to 
      org.omg.CORBA.Object 
              at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow 
      (PortableRemoteObject.java:212)
      Anyone can help me?
      Thanks at all
      Bye