1 Reply Latest reply on May 12, 2002 10:25 PM by Greg Turner

    How to compile & run manually Interest example

    hakim Newbie


      I am trying to run the interest example manually but it fails. I got the context but the line:

      Object ref = jndiContext.lookup("interest/Interest");

      So I can't have the reference.
      The exception I have is :

      javax.naming.NoInitialContextException : Need to specify class name in environnement or system properties, or as a applet parameter, or in an application resource file : javax.naming.factory.initial

      I have included in the classpath all the client jars, and interest.jar

      I am using JBoss2.4.4 on Windows Me.

      Thanks a lot for your help!

        • 1. Re: How to compile & run manually Interest example
          Greg Turner Apprentice

          I suggest that you read up on JNDI. If you do this:

          Context jndiContext = new InitialContext();
          Object ref = jndiContext.lookup("interest/Interest");

          then the InitialContext is trying to get init info from System.properties. Your exception makes clear that it can not find the info it needs. There are at least 2 ways to solve this. One is to pass the required info as system properties in the command line of your main. The other is to specify the info explicitly in the code:

          Properties props = new Properties();
          props.put (Context.PROVIDER_URL,
          Context jndiContext = new InitialContext(props);
          Object ref = jndiContext.lookup("interest/Interest");

          Of course replace localhost above, with whatever is appropriate for your environment.

          This is an excellent book on JNDI: