1 Reply Latest reply on Feb 17, 2004 9:17 AM by Nagurva Reddy

    ClassCastException  or UndeclaredThrowableException while tr

    Nagurva Reddy Newbie

      Functionality: Simple stateless session bean has methods, which return the non-serialized remote object.

      Problem 1:
      I have generated stubs and skeleton using rmic with iiop option and used the following property for initial context creation
      java.naming.provider.url=jnp://localhost:1099/iiop

      In this case, if try to lookup for bean, I am getting the following error

      [java] java.lang.ClassCastException
      [java] at com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narr
      ow(PortableRemoteObject.java:293)
      [java] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.ja
      va:134)

      Problem 2:

      I have generated stubs and skeleton using rmic with iiop option and used the following property for initial context creation
      java.naming.provider.url=jnp://localhost:1099

      In this case, if try to access bean method, I am getting the following error

      [java] java.lang.reflect.UndeclaredThrowableException
      [java] at $Proxy1.getRemoteSession(Unknown Source)


      Please see below for my code

      Session Bean implementation:

      public RemoteSession getRemoteSession() throws javax.ejb.EJBException {
      
       RemoteSession remoteReference = new RemoteSessionImpl();
       try {
       javax.rmi.PortableRemoteObject.exportObject(remoteReference);
       System.out.println("Object is exported");
       //return (RemoteSession)javax.rmi.PortableRemoteObject.toStub(remoteReference);
       return remoteReference;
       }catch(Exception ex){
       ex.printStackTrace();
       }
       return null;
       }


      RemoteSessionImpl Code:

      public class RemoteSessionImpl implements RemoteSession {
      
       /* (non-Javadoc)
       * @see interfaces.MyRemoteSession#open()
       */
       public String open() throws RemoteException {
       return "Session Opened Successfully !!";
       }
      }


      RemoteSession Code
      public interface RemoteSession extends java.rmi.Remote {
       public String open() throws java.rmi.RemoteException;
      }


      JBOSS.xml

      <enterprise-beans>

      <ejb-name>RemObjTestBean</ejb-name>
      <jndi-name>RemObjTestBean</jndi-name>
      <configuration-name>Standard Stateless SessionBean</configuration-name>
      <invoker-bindings>

      <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>


      <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>

      </invoker-bindings>

      </enterprise-beans>



      JNDI.Properties

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      java.naming.provider.url=jnp://localhost:1099/iiop

      Please help me in transferring the non-serialized remote object between two JVM using IIOP protocol.

      Thanks,
      Nagurva.