0 Replies Latest reply on Jul 28, 2008 6:29 AM by mporhel

    Accessing an EJB with jndi

    mporhel

      Hello !

      I'm doing some tests to acces EJBs from the Tuscany, the Apache's SCA Runtime.

      I would like to acces an ejb deployed in JBoss, from a pojo client, I am using the following code :

      Properties properties = new Properties();
      properties.put("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
      properties.put("java.naming.factory.url.pkgs","org.jboss.naming:org.jnp.interfaces");
      properties.put("java.naming.provider.url", "jnp://127.0.0.1:1099");
      properties.put("jnp.disableDiscovery", "true");
      
      InitialContext jndiContext = new InitialContext(properties);
      
      // Get a reference to the VegetablesCatalogEJB Bean
      Object o = jndiContext.lookup("VegetablesCatalogEJB");
      
      // Get a reference to the Bean's Home interface
      CatalogEJBHome home=(CatalogEJBHome)PortableRemoteObject.narrow(o, CatalogEJBHome.class);


      If the same ejb is deployed in Apache Geronimo, I can access from tuscany thanks to the following uri :
      corbaname:iiop:1.2@localhost:1050#VegetablesCatalogEJB

      and from a java client :
      InitialContext context = new InitialContext();
      Object o = context.lookup("corbaname:iiop:1.2@localhost:1050#VegetablesCatalogEJB");
      CatalogEJBHome home = (CatalogEJBHome)PortableRemoteObject.narrow(o, CatalogEJBHome.class);


      I would like to know if I can access my ejb deployed in JBoss with an uri, like I do in the pojo client for Geronimo.

      I think that if this is not possible, it comes from the "java.naming.initial" factory, isn't it ?

      Thanks

      Maxime Porhel