2 Replies Latest reply on Apr 13, 2004 10:01 AM by aldeponk

    EJB trial failed

    aldeponk Newbie

      Hi,

      I developed an EJB through JBuilder, coupled with JBOSS.

      When I run a client that uses this EJB, I get an error due to JNDI lack of registration (see following error message).

      javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial

      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)

      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)

      at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)

      at javax.naming.InitialContext.lookup(InitialContext.java:347)

      at ejb_tarification.Bean_TarificationTestClient1.initialize(Bean_TarificationTestClient1.java:30)

      at ejb_tarification.Bean_TarificationTestClient1.(Bean_TarificationTestClient1.java:15)

      at ejb_tarification.Bean_TarificationTestClient1.main(Bean_TarificationTestClient1.java:241)


      Any idea ?

      Alain

        • 1. Re: EJB trial failed
          Nicholas Whitehead Novice

          Alain;

          It looks like your client did not complete a proper JNDI remote context initialization. The required code looks something like this:

          import java.util.*;
          import javax.naming.*;
          .
          .
          .
           Properties p = new Properties();
           p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
           p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
           p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
           Context ctx = new InitialContext(p);
          


          You can then use the ctx object to performa valid JNDI lookups. Also, make sure the according client lib jar file is in the path of the client. Something like: <jboss-home>\client\jbossall-client.jar

          If you have difficulty, post your code.

          //Nicholas

          • 2. Re: EJB trial failed
            aldeponk Newbie

             

            "nickman" wrote:
            Alain;

            It looks like your client did not complete a proper JNDI remote context initialization. The required code looks something like this:

            import java.util.*;
            import javax.naming.*;
            .
            .
            .
             Properties p = new Properties();
             p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
             p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
             p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
             Context ctx = new InitialContext(p);
            


            You can then use the ctx object to performa valid JNDI lookups. Also, make sure the according client lib jar file is in the path of the client. Something like: <jboss-home>\client\jbossall-client.jar

            If you have difficulty, post your code.

            //Nicholas