5 Replies Latest reply on Apr 19, 2003 2:22 PM by cbwilliams

    naming exception-pls help!!

    ravishastri

      I am getting the following error when I run Client.java
      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
      aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
      rg.jnp.interfaces.NamingContextFactory]

      my client.java(bean deployed successfully)


      import javax.naming.*;
      import javax.rmi.PortableRemoteObject;
      import java.util.Properties;
      import com.javapro.ejb.StringProcessor;
      import com.javapro.ejb.StringProcessorHome;

      public class Client {

      public static void main(String[] args) {

      // first argument must be the input
      if (args.length==0) {
      System.out.println("Please specify the input to convert to upper case.");
      return;
      }
      String input = args[0];
      //Properties properties=System.getProperties();
      // preparing properties for constructing an InitialContext object
      Properties properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      properties.put(Context.PROVIDER_URL, "165.197.127.98:8080");

      try {
      // Get an initial context
      InitialContext jndiContext = new InitialContext(properties);
      System.out.println("Got context");

      // Get a reference to the Bean
      Object ref = jndiContext.lookup("StringProcessor");
      System.out.println("Got reference");

      // Get a reference from this to the Bean's Home interface
      StringProcessorHome home = (StringProcessorHome)
      PortableRemoteObject.narrow (ref, StringProcessorHome.class);

      // Create an Adder object from the Home interface
      StringProcessor sp = home.create();
      System.out.println ("Uppercase of '" + input + "' is " +
      sp.toUpperCase(input));
      }
      catch(Exception e) {
      System.out.println(e.toString());
      }
      }
      }


      thanks

        • 1. Re: naming exception-pls help!!

          make sure jnp-client.jar is in your classpath

          • 2. Re: naming exception-pls help!!
            ravishastri

            java -classpath C:\JBoss-3.0.6\client\jboss-client.jar;C:\JBoss-3.0.6\client\jnp-client.jar;. Client "golden retriever"

            I am getting this error

            Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/Lo
            ger
            at org.jnp.interfaces.NamingContext.(NamingContext.java:95)
            at org.jnp.interfaces.NamingContextFactory.getInitialContext(NamingCont
            xtFactory.java:42)
            at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
            62)
            at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:24
            )
            at javax.naming.InitialContext.init(InitialContext.java:219)
            at javax.naming.InitialContext.(InitialContext.java:195)
            at Client.main(Client.java:25)


            log4j is in the claspath

            thanks

            • 3. Re: naming exception-pls help!!

              make sure the jars from jboss/client dir are in your classpath

              • 4. Re: naming exception-pls help!!
                ravishastri

                I have done that,but still error persists
                set path=%PATH%;C:\jBoss-3.0.6\client\*.jar

                • 5. Re: naming exception-pls help!!
                  cbwilliams

                  You've changed the PATH. You need to change the classpath...

                  set CLASSPATH=%JBOSS_HOME%\client\jnp-client.jar;%CLASSPATH%

                  this of course assumes that you've set the JBOSS_HOME environment variable.