0 Replies Latest reply on Mar 9, 2007 11:56 AM by Nicolas Ploquin

    Just a question

    Nicolas Ploquin Newbie

      Hello all, sorry for my english, I'm french !!

      I've a comprehension problem !

      I had a problem to find an EJB from a web application. To find it I made :

      Context ctx = new InitialContext();
      EjbExemple home = (EjbExempleHome)PortableRemoteObject.narrow( ctx.lookup(?ejbname?), EjbExempleHome.class );
      ejb = home.create();
      


      This lines works only if my client is a simple jsp. If my client was my web application, this don't work. I've solve thi problem with this lines :

      properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      properties.put(Context.PROVIDER_URL, "localhost:1099");
      


      So, I find my EJB with :

      Context ctx = new InitialContext(properties);


      And it work !

      My EJB interact with an Oracle database, so I ahve to find the connection with EJB. To do that, I use :

      Context ic = new InitialContext();
      ds = (DataSource) ic.lookup(?connectionname?);


      It Work !!! Without properties !

      So, here, my question :
      Why the jsp work without context properties whereas my web app need it ?
      And, Why I don't need the context properties to find my connection whereas I need it to find EJB ??

      My application work, but, it's a question which I would like to have the answer.

      Thx