4 Replies Latest reply on Mar 17, 2003 1:04 PM by Suresh

    NoInitialContextException: New user trying samples

    Richard Catlin Newbie

      Got context
      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

        • 1. Re: NoInitialContextException: New user trying samples
          hamish carpenter Newbie

          i think you need to make sure that jndi.properties is available on the classpath AND that it is configured correctly for your server. Usually localhost is find during development.

          • 2. Re: NoInitialContextException: New user trying samples
            Lesetja Mphafudi Newbie

            Hello there,
            I also new to jboss, and am having the same problem.
            The jndi.properties file is on the classpath but no luck.
            What else should I check?
            Thank you
            Lesetja

            • 3. Re: NoInitialContextException: New user trying samples
              hamish carpenter Newbie

              my jndi.properties file contains the following:
              java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
              java.naming.provider.url=localhost:1099
              java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces

              you could also see if a firewall? is stopping the data.
              check no other apps are using port 1099.

              • 4. Re: NoInitialContextException: New user trying samples
                Suresh Newbie

                Hi I am also new user trying examples.

                I am also getting the same error for JNDI lookup.
                1) I have included jndi.properties in the classpath
                2) I have started and created queue from jmx-console.

                I appreciate any input on my probelm.
                Thanks

                -------------------------------------------
                my jndi.properties look like this

                java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
                java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
                java.naming.provider=localhost:1099
                ------------

                This is part of my program using JNDI lookup

                try {
                jndiContext = new InitialContext();
                } catch (Exception e) {
                System.out.println("Couldnot create JNDI API Context:" +
                e.toString());
                System.exit(1);
                }

                try {
                queueConnectionFactory = (QueueConnectionFactory)
                jndiContext.lookup("ConnectionFactory");
                queue = (Queue) jndiContext.lookup("queue/testQueue");
                } catch (Exception e) {
                System.out.println("JNDI lookup failed" + e.toString());
                System.exit(1);
                }
                ------------

                This is the command I am using

                java -cp /opt/hpws/jboss/server/default/lib/jboss-j2ee.jar:. -Djms.properties=/opt/hpws/jboss/server/default/conf/jndi.properties SimpleQueueSender testQueue 3
                --------------------