1 Reply Latest reply on Oct 2, 2006 9:25 PM by warrenc5

    Unable to connect corba client to session bean

    ghoyle Newbie

      I need to be able to get CORBA clients talking to Sessions beans.
      So I have written a v simple session bean and corba client to test it out, I am using Jacorb for the client also in this test.
      Unfortunately I do not seem to be able to call the methods on the remote interface.
      I am running JBOSS 3.2.3 and my client is using Jacorb 2.1
      The error I am getting from jacorb on my client when I run it, is this...



      JacORB V 2.1, www.jacorb.org
      (C) Gerald Brose, XTRADYNE Technologies/FU Berlin, 16-Feb-2004
      [jacorb.orb.intercept] INFO : InterceptorManager started with 0 SIs, 0 CIs and 1 IORIs
      [jacorb.giop] INFO : ClientConnectionManager: created new conn to target 192.168.0.64:3528
      [jacorb.iiop.conn] INFO : Connected to 192.168.0.64:3528 from local port 35513
      [jacorb.giop] INFO : ClientConnectionManager: found conn to target 192.168.0.64:3528
      org.omg.CORBA.BAD_PARAM: Narrow failed
      at com.ssl.GoodDayHelper.narrow(GoodDayHelper.java:65)
      at callbackClient.main(callbackClient.java:56)


      My ejb's do seem to deploy okay and I get the following out of JBOSS when they are deployed


      12:51:46,631 INFO [MainDeployer] Starting deployment of package: file:/opt/jboss-3.2.3/server/all/deploy/Hello.jar
      12:51:46,993 INFO [EjbModule] Deploying GoodDay
      12:51:47,232 INFO [AGoodDay] CORBA interface repository for AGoodDay: IOR:000000000000002149444C3A6F6D672E6F72672F434F5242412F5265706F7369746F72793A312E3000000000000000020000000000000068000102000000000D3139322E3136382E302E363400000DC8000000114A426F73732F49522F41476F6F64446179000000000000020000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000010000002C0000000000000001000000010000001C00000000000100010000000105010001000101090000000105010001
      12:51:47,237 INFO [AGoodDay] EJBHome reference for AGoodDay:
      IOR:0000000000000029524D493A636F6D2E73736C2E476F6F64446179486F6D653A30303030303030303030303030303030000000000000000200000000000000A6000102000000000D3139322E3136382E302E363400000DC80000001D4A426F73732F454A42486F6D65262541476F6F644461792FACED000570000000000000030000000000000008000000004A414300000000010000001C00000000000100010000000105010001000101090000000105010001000000190000002A0000000000000022687474703A2F2F434354563A383038332F576562434C5B41476F6F644461795D2F000000000000010000005E0000000000000002000000010000001C00000000000100010000000105010001000101090000000105010001000000190000002A0000000000000022687474703A2F2F434354563A383038332F576562434C5B41476F6F644461795D2F00
      12:51:47,239 INFO [AGoodDay] Home IOR for GoodDay bound to iiop/AGoodDay in JNP naming service
      12:51:47,241 INFO [AGoodDay] Home IOR for GoodDay bound to AGoodDay in CORBA naming service
      12:51:47,241 INFO [StatelessSessionInstancePool] Started jboss.j2ee:jndiName=AGoodDay,plugin=pool,service=EJB
      12:51:47,241 INFO [StatelessSessionContainer] Started jboss.j2ee:jndiName=AGoodDay,service=EJB
      12:51:47,242 INFO [EjbModule] Started jboss.j2ee:module=Hello.jar,service=EjbModule
      12:51:47,242 INFO [EJBDeployer] Deployed: file:/opt/jboss-3.2.3/server/all/deploy/Hello.jar
      12:51:47,248 INFO [MainDeployer] Deployed package: file:/opt/jboss-3.2.3/server/all/deploy/Hello.jar


      I have included my code below in case it helps.



      My client code is

      import org.omg.CORBA.ORB;
      
      import java.util.Properties;
      import org.omg.CosNaming.NamingContext;
      import org.omg.CosNaming.NamingContextHelper;
      import org.omg.CosNaming.NameComponent;
      import org.jacorb.orb.util.CorbaLoc;
      /**
       *
       * @author geoff
       * @version
       */
      public class callbackClient {
      
       /** Creates new callbackClient */
       public callbackClient() {
       }
      
       /**
       * @param args the command line arguments
       */
       public static void main(String args[]) {
      
       try {
       // setting system properties is necessary in order to use this ORB in JDK
       Properties props = System.getProperties();
       props.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
       props.put("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORB");
       System.setProperties(props);
       ORB orb = ORB.init(args, props);
      
       // the client will use Naming Service
       org.omg.CORBA.Object ns = orb.resolve_initial_references("NameService");
       if (ns == null)
       throw new RuntimeException();
       NamingContext nc = NamingContextHelper.narrow(ns);
       if (nc == null)
       throw new RuntimeException();
      
       // resolve names with the Naming Service
       String[] client_name_hierarchy = new String [] {"AGoodDay", ""};
       NameComponent[] aName = new NameComponent[client_name_hierarchy.length / 2];
       for (int i=0; i<(client_name_hierarchy.length / 2); i++) {
       aName = new NameComponent();
       aName.id = client_name_hierarchy[i*2];
       aName.kind = client_name_hierarchy[i*2+1];
       }
       org.omg.CORBA.Object obj = nc.resolve(aName);
       com.ssl.GoodDay srv = com.ssl.GoodDayHelper.narrow(obj);
       if (srv == null)
       throw new RuntimeException();
       srv.requestHello();
       System.out.println("AFTER METHOD CALL The method should call and display something in the server output");
       // add your client code here
      
       } catch (Exception ex) {
       ex.printStackTrace();
       }
       }
       }
      


      the idl is

      module com{
       module ssl{
       interface GoodDay {
       public void requestHello();
       };
      
       };
      };
      


      I have added a jboss.xml file so that it can use IIOP


      <?xml version="1.0" encoding="UTF-8"?>
      
      <jboss>
       <enterprise-beans>
       <session>
       <ejb-name>GoodDay</ejb-name>
       <jndi-name>AGoodDay</jndi-name>
       <configuration-name>Standard Stateless SessionBean</configuration-name>
       <invoker-bindings>
       <invoker>
       <invoker-proxy-binding-name>iiop</invoker-proxy-binding-name>
       </invoker>
       </invoker-bindings>
       </session>
       </enterprise-beans>
      </jboss>
      


      and my ejb-jar fil is
      <?xml version="1.0"?>
      
      <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN'
       'http://alpha-am02-mx01/dtd/ejb-jar_1_1.dtd'>
      
      <ejb-jar>
       <enterprise-beans>
       <session>
       <ejb-name>GoodDay</ejb-name>
       <home>com.ssl.GoodDayHome</home>
       <remote>com.ssl.GoodDay</remote>
       <ejb-class>com.ssl.GoodDayBean</ejb-class>
      
       <session-type>Stateless</session-type>
      
       <transaction-type>Container</transaction-type>
       </session>
       </enterprise-beans>
      
       <assembly-descriptor>
       <container-transaction>
       <method>
       <ejb-name>GoodDay</ejb-name>
       <method-intf>Remote</method-intf>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Required</trans-attribute>
       </container-transaction>
       </assembly-descriptor>
      </ejb-jar>
      


      My ejb files are

      goodDay
      package com.ssl;
      import java.rmi.RemoteException;
      import javax.ejb.EJBObject;
      
      
      /**
       *Created Jun 2 Wed, 2004 11:2:46 AM
       *Code generated by the NetBeans for java EJB Module
       *@Author geoff
       */
      
      
      public interface GoodDay extends EJBObject {
      
       public void requestHello() throws RemoteException;
      }
      


      GoodDayHome
      package com.ssl;
      import java.rmi.RemoteException;
      import javax.ejb.EJBObject;
      
      
      /**
       *Created Jun 2 Wed, 2004 11:2:46 AM
       *Code generated by the NetBeans for java EJB Module
       *@Author geoff
       */
      
      
      public interface GoodDay extends EJBObject {
      
       public void requestHello() throws RemoteException;
      }
      


      and my implementation class is
      GoodDayBean
      package com.ssl;
      import javax.ejb.CreateException;
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
      import java.rmi.RemoteException;
      /**
       *Created Jun 2 Wed, 2004 11:2:46 AM
       *Code generated by the NetBeans for java EJB Module
       *@Author geoff
       */
      
      
      public class GoodDayBean implements SessionBean {
      
       private SessionContext sessionContext = null;
      
       public void requestHello() throws RemoteException
       {
       System.out.println("The cleient has finally manged to call this");
       //return "Hello, this is a stateless bean access through CORBA";
       }
       public void ejbCreate() throws CreateException {
      
       }
      
       public void ejbActivate() {
       }
      
       public void ejbPassivate() {
       }
      
       public void ejbRemove() {
       }
      
       public void setSessionContext(SessionContext sessionCtx){
      
       this.sessionContext = sessionCtx;
      
       }
      
      }