5 Replies Latest reply on Jun 2, 2004 4:56 AM by ghoyle

    CORBA Call back Client and Session beans

    ghoyle Newbie

      Hi,

      has anyone got a good example of a CORBA client talking to a session bean and receiving a callback. I am using JACorb for the client also, although clients may well be written in C++ etc, hence why i need to know how to do this.
      I have been trying and I think I am nearly there. However not sure how the client gets hold of the session bean using the naming service etc, with JBOSS.
      I am running it with -c all option.

      Thanks,


      Geoff

        • 1. Re: CORBA Call back Client and Session beans
          Adrian Brock Master

          There are examples in the testsuite, e.g. the ubiquotous HelloWorld

          • 2. Re: CORBA Call back Client and Session beans
            Vishal Sharma Expert

            Just a suggestion on yr scenario, if you dont want to use CORBA to talk to bean then use GSOAP for C/C++ cleint to talk to Stateless Session Bean.

            Vishal


            • 3. Re: CORBA Call back Client and Session beans
              ghoyle Newbie

              I can not seem to find the test suite, can you tell me where it is please.

              Thanks

              Geoff

              • 4. Re: CORBA Call back Client and Session beans
                ghoyle Newbie

                I have simplified my CORBA client and session bean, so that it should just return a String, no callback, so that I can test a very simple case.

                The error i get in my client when i run it is:

                [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 33511
                org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0
                 at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(Unknown Source)
                 at org.omg.CosNaming._NamingContextStub.resolve(Unknown Source)
                 at callbackClient.main(callbackClient.java:59)
                


                I have copied my code below. Can you see where I am going wrong? Do I need to do something else with JBOSS to get it to accept CORBA connections?
                Also does JBOSS just output the IOR for the naming service to the terminal when it starts up, or can you get it to put it elsewhere.

                Lots of questions I know, sorry.



                The Client code is the following

                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 com.ssl.simple.*;
                /**
                 *
                 * @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");
                 //org.omg.CORBA.Object ns = orb.resolve_initial_references("CorbaNaming");
                 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 [] {"CorbaNaming", "JBoss"};
                 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.simple.GoodDay srv = com.ssl.simple.GoodDayHelper.narrow(obj);
                 if (srv == null)
                 throw new RuntimeException();
                 System.out.println(srv.requestHello());
                 // add your client code here
                
                 } catch (Exception ex) {
                 ex.printStackTrace();
                 }
                 }
                 }
                


                the Goodday bean class
                package com.ssl.simple;
                
                import javax.ejb.CreateException;
                import javax.ejb.SessionBean;
                import javax.ejb.SessionContext;
                
                
                /**
                 *Created May 28 Fri, 2004 3:28:29 PM
                 *@Author geoff
                 */
                
                
                public class GoodDayBean implements SessionBean {
                
                 private SessionContext sessionContext = null;
                
                 public void ejbCreate() throws CreateException {
                
                
                 }
                
                 public String requestHello() {
                
                 return "hello I WONDER IF THIS WILL WORK";
                
                 }
                
                
                
                 public void ejbActivate() {
                 }
                
                 public void ejbPassivate() {
                 }
                
                 public void ejbRemove() {
                 }
                
                 public void setSessionContext(SessionContext sessionCtx){
                
                 this.sessionContext = sessionCtx;
                
                 }
                
                }
                


                The Goodday interface
                package com.ssl.simple;
                
                import java.rmi.RemoteException;
                import javax.ejb.EJBObject;
                
                
                /**
                 *Created May 28 Fri, 2004 3:28:29 PM
                 *@Author geoff
                 */
                
                
                public interface GoodDay extends EJBObject {
                 public String requestHello() throws RemoteException ;
                
                }
                


                and the goodday home

                package com.ssl.simple;
                
                import java.rmi.RemoteException;
                import javax.ejb.CreateException;
                import javax.ejb.EJBHome;
                
                
                /**
                 *Created May 28 Fri, 2004 3:28:29 PM
                 *Code generated by the NetBeans for java EJB Module
                 *@Author geoff
                 */
                
                
                public interface GoodDayHome extends EJBHome {
                
                 public GoodDay create() throws CreateException,RemoteException;
                
                }
                


                And finally the deployent descriptor for this.

                ejb-jar.xml

                <?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.simple.GoodDayHome</home>
                 <remote>com.ssl.simple.GoodDay</remote>
                 <ejb-class>com.ssl.simple.GoodDayBean</ejb-class>
                
                 <session-type>Stateful</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>
                


                • 5. Re: CORBA Call back Client and Session beans
                  ghoyle Newbie

                  I have got a copy of the test suite now.
                  ALthough I can not find the CORBA Client to session bean example


                  There are examples in the testsuite, e.g. the ubiquotous HelloWorld


                  Can you pint me in the right direction please.