0 Replies Latest reply on Sep 6, 2002 10:29 AM by thl-mot

    How can i access EJBs with Corba

    thl-mot

      Hi,
      Id like to use jboss as server for a delphi program.
      I'd like to know how to use Corba to contact jboss ejb's. In the first step a small java example to do this would be fine. JBoss is using jacorb as ORB.
      Important for me is how to get the context of the NameService. I tried this with the standard way:
      NamingContext context= NamingContextHelper.narrow( orb.resolve_initial_references("NameService"));
      But this didn't work. If I use
      NamingContext context= NamingContextHelper.narrow( orb.string_to_object( objId) );
      with the objId that is shown on startup of jboss, I at least didn't get an error.

      How do I get the ejb's do i have to asc for 'Shop' or for 'ShopHome' if i want to get my Shop-ejb? Both didn't work on my first try.

      It would be perfect if somebody can post a short example here.

      Here my example that did't work:

      public static void main ( String[] args) {
      try {
      Properties p= new Properties();
      p.setProperty("org.omg.CORBA.ORBInitialHost", "myMachine");
      p.setProperty("org.omg.CORBA.ORBInitialPort", "900");
      org.omg.CORBA.ORB orb= org.omg.CORBA.ORB.init( new String[]{}, p);
      // NamingContext context= NamingContextHelper.narrow( orb.resolve_initial_references("NameService"));

      String objId="IOR:000000000000002B49444C3A6F6D672E6F72672F436F734E616D696E672F4E616D696E67436F6E746578744578743A312E300000000000020000000000000034000102000000000E31302E31332E3235332E3130350021EB000000114A426F73732F4E616D696E672F726F6F7400000000000000000000010000002C0000000000000001000000010000001C00000000000100010000000105010001000101090000000105010001";
      NamingContext context= NamingContextHelper.narrow( orb.string_to_object( objId) );
      NameComponent[] names= { new NameComponent("ShopHome","") };
      Object o = context.resolve( names);

      System.out.println("ok.");
      }
      catch (Exception ex) {
      ex.printStackTrace();
      }
      }



      Thomas