1 Reply Latest reply on Sep 27, 2006 11:36 PM by warrenc5

    ClassCastException on Home.create

    warrenc5 Newbie

      I am running java 1.5.0_08-b03 and
      Release ID: JBoss [Zion] 4.0.4.GA (build: CVSTag=JBoss_4_0_4_GA date=200605151000)

      I export my entity via iiop

      i have set

      standardjboss.xml

      <name>iiop</name>
       <poa>per-servant</poa>
       <register-ejbs-in-jnp-context>true</register-ejbs-in-jnp-context>
       <jnp-context>iiop</jnp-context>
       <interface-repository-supported>true</interface-repository-supported>
      

      and deploy

      12:22:00,262 INFO [EjbModule] Deploying GroupBean
      12:22:00,857 INFO [GroupBean] CORBA interface repository for GroupBean: IOR:000000000000002149444C3A6F6D672E6F72672F434F5242412F5265706F7369746F72793A312E30000000000000000200000000000000D0000102000000000A3132372E302E302E31000DC8000000124A426F73732F49522F47726F75704265616E0000000000050000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000210000004C000000000000000100000000000000240000001C0000007E00000000000000010000000A3132372E302E302E31000DC9000000000000000000000000000000000000000000000000000000000000002000000004000000000000001F0000000400000003000000010000002000000000000000020000002000000004000000000000001F0000000400000003
      12:22:00,933 INFO [BaseLocalProxyFactory] Bound EJB LocalHome 'GroupBean' to jndi 'GroupBeanLocal'
      12:22:01,341 INFO [ProxyFactory] Bound EJB Home 'GroupBean' to jndi 'GroupBean'
      12:22:01,599 INFO [GroupBean] EJBHome reference for GroupBean:
      IOR:0000000000000032524D493A656E746974792E67726F75702E47726F757052656D6F7465486F6D653A303030303030303030303030303030300000000000000200000000000000C0000102000000000A3132372E302E302E31000DC80000001E4A426F73732F454A42486F6D65262547726F75704265616E2FACED0005700000000000050000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000190000002D0000000000000025687474703A2F2F73706C6963653A383038332F576562434C5B47726F75704265616E5D2F000000000000002000000004000000000000001F000000040000000300000001000000580000000000000003000000190000002D0000000000000025687474703A2F2F73706C6963653A383038332F576562434C5B47726F75704265616E5D2F000000000000002000000004000000000000001F0000000400000003
      12:22:01,600 INFO [GroupBean] Home IOR for GroupBean bound to iiop/GroupBean in JNP naming service
      12:22:01,602 INFO [GroupBean] Home IOR for GroupBean bound to GroupBean in CORBA naming service
      12:22:01,795 INFO [EJBDeployer] Deployed: file:/opt/jboss-4.0.4.GA/server/all/deploy/entity-ejb.jar


      Then I lookup

      corbaname:iiop:localhost:3528/NameService#GroupBean

      Then when I invoke create I get
      GroupRemote remote=home.create("123456");



      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 org.jboss.iiop.rmi.marshal.CDRStream$RemoteReader.read(CDRStream.java:601)
      at org.jboss.iiop.rmi.marshal.strategy.StubStrategy.readRetval(StubStrategy.java:226)
      at org.jboss.proxy.ejb.DynamicIIOPStub.invoke(DynamicIIOPStub.java:128)
      at entity.group._GroupRemoteHome_Stub.create(Unknown Source)
      at service.sip.ua.UserAgentSbb.onServiceStartedEvent(UserAgentSbb.java:168)

      Caused by: java.lang.ClassCastException: Object is not of remote type entity.group.GroupRemote
      at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:221)
      ... 16 more



      If I don't assign the resultant then I dont seem to get an error and the entity is created (ie subsequent creates will return duplicate key errors)

      but then when I do a findByPrimaryKey or a findAll and a narrow on i.next() I get the same crap error.

      I have looked at the resultant

      info(o.getClass().getName() + " " + java.util.Arrays.asList(o.getClass().getInterfaces()).toString());
      

      org.jacorb.orb.Reference [interface java.rmi.Remote]


      Any idea why the home IOR works sweet as but the remote IOR isn't??

      here is some sample code


      <target name="test-iiop">
       <javac fork="yes" compiler="javac1.4" srcdir="src" destdir="${classes}" deprecation="true" failonerror="true" debug="true" includeAntRuntime="false" includeJavaRuntime="false" includes="test/IIOPNamingTest.java">
       <classpath path="${classes}"/>
       </javac>
      
       <java fork="yes" classname="test.IIOPNamingTest">
       <jvmarg value="-DORBInitRef.NameService=JBoss/Naming/root"/>
       <jvmarg value="-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB"/>
       <jvmarg value="-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton"/>
       <jvmarg value="-Djava.security.manager"/>
       <jvmarg value="-Djava.security.policy=security.policy"/>
      
       <classpath refid="jboss.classpath"/>
       <classpath path="${classes}"/>
       </java>
      
      </target>

      package test;
      
      import org.omg.CORBA.*;
      import java.util.*;
      import javax.naming.*;
      import entity.group.*;
      import java.util.*;
      
      public class IIOPNamingTest{
      
       public static void main(String[] args) throws Exception{
       args = new String[]{"-ORBInitRef", "NameService=corbaloc:iiop:1.2@localhost:3528/JBoss/Naming/root"};
      
       // create and initialize the ORB
       ORB orb = ORB.init( args, null );
      
       // get the root naming context
       org.omg.CORBA.Object objRef = orb.resolve_initial_references( "NameService" );
      /*
       NamingContext ncRef = NamingContextHelper.narrow( objRef );
       NameComponent[] name= { new NameComponent("GroupBean","") };
       BindingListHolder blh=new BindingListHolder();
       BindingIteratorHolder bih=new BindingIteratorHolder();
      
       ncRef.list(1000,blh,bih);
      
       for(int i=0;i<blh.value.length;i++)
       for(int j=0;j<blh.value.binding_name.length;j++)
       System.out.println(blh.value.binding_name[j].id);
      
       org.omg.CORBA.Object obj=ncRef.resolve(name);
       System.out.println(obj);
       GroupRemoteHome home=(GroupRemoteHome)javax.rmi.PortableRemoteObject.narrow(obj,GroupRemoteHome.class);
       //home.create(new Long(2));
      */
      
       Properties p = new Properties();
       p.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
       p.put(javax.naming.Context.PROVIDER_URL, "corbaname::localhost:3528/JBoss/Naming/root");
      
       javax.naming.Context ctx= new InitialContext(p);
      /*
       for(NamingEnumeration e=ctx.list("");e.hasMore();)
       System.out.println(e.next());
      */
       java.lang.Object obj1 = ctx.lookup("corbaname::localhost:3528/JBoss/Naming/root#GroupBean");
       obj1 = ctx.lookup("GroupBean");
      
       //ctx= new InitialContext();
       //obj1 = ctx.lookup("corbaname::iiop:localhost:3528/JBoss/Naming/root#GroupBean");
      
       System.out.println(obj1);
      
       GroupRemoteHome home1=(GroupRemoteHome)javax.rmi.PortableRemoteObject.narrow(obj1,GroupRemoteHome.class);
       System.out.println(home1);
      
       GroupRemote remote=home1.create("12");
      
       }
      }


      please email me for the actual ejb entitiy bean





        • 1. Re: ClassCastException on Home.create
          warrenc5 Newbie

           

          <jboss>
           <enterprise-beans>
           <entity>
           <ejb-name>GroupBean</ejb-name>
           <jndi-name>GroupBean</jndi-name>
           <local-jndi-name>GroupBeanLocal</local-jndi-name>
           <!--<configuration-name>Standard CMP 2.x EntityBean</configuration-name>-->
           <invoker-bindings>
           <invoker>
           <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>
           </invoker>
           <!--<invoker>
           <invoker-proxy-binding-name>entity-rmi-invoker</invoker-proxy-binding-name>
           </invoker>-->
           </invoker-bindings>
           </entity>
           </enterprise-beans>
           <!--<container-configurations>
           <configuration-name>Standard CMP 2.x EntityBean</configuration-name>
           <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>
           </container-configurations>-->
           </jboss>