7 Replies Latest reply on Apr 18, 2002 6:25 PM by lasterra

    InitilaContext instantiation error

    javier_arrieta

      Hi,

      Whenever I try to create an initialcontext my jboss/tomcat distro (2.4.4) throws the following exception.

      javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory. Root exception is
      java.lang.ClassCastException: org.jnp.interfaces.NamingContextFactory
      at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:659)

      I tried specifying the properties explicitly also
      Properties h = new Properties();
      h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      h.put(Context.PROVIDER_URL, "localhost:1099");
      h.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

      with no result

      Any guess appreciated. Thanx in advance

      Javier Arrieta

        • 1. Re: InitilaContext instantiation error
          mikefinn

          Javier,
          Dumb question, but are you passing the properties object ("h" in you're example) to InitialContext constructor?

          like...

          InitialContext iCtx = new InitialContext(h);

          Otherwise you'll need to set these pros via System.setProperty() or
          -D propertyname=value on command line.

          Mike

          • 2. Re: InitilaContext instantiation error
            javier_arrieta

            Yes, of course I passed the Properties to the constructor...

            Any other guess?

            PS: Thnx anyway Mike

            • 3. Re: InitilaContext instantiation error
              jsents

              We use the following settings
              env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
              env.put(Context.PROVIDER_URL ,"jnp://localhost:1099");
              We don't use Context.URL_PKG_PREFIXES setting.

              Hope this Helps

              • 4. Re: InitilaContext instantiation error
                lasterra

                Hola Javier,

                Are you using winXP and jdk1.4.0???

                I have a friend with the same problem and the only different between my config and his is that he's using winXP.

                When i Instantiate the InitialContext a only do this:

                Context initial = new InitialContext ();

                no propierties, nothing, th jndi.propierties should be in your classpath, nothing else.

                Please, tell me if you are using winxp and jdk1.4.0 becouse maybe is a bug.

                Regards, Enrique.

                • 5. Re: InitilaContext instantiation error
                  javier_arrieta

                  No, Enrique. I'm using Sun's jdk1.3.1_02 in a win2k machine. And i've also (my first tries) used the no-properties constructor with the same results.

                  Th most shocking issue is the ClassCastException error wrapped in a NamingException

                  Thanx anyway

                  • 6. Re: InitilaContext instantiation error
                    lasterra

                    Hola Javi,

                    We find the error¡¡¡

                    In our case the problem was that jndi.jar was inside the webapp (war file) in the lib directory. The problem was in our ANTs files.

                    When we correct it, the app was ok.

                    So i suspect that you have a similar problem, you are trying to cast a javax.naming.NoInitialContextException to a class different of org.jnp.interfaces.NamingContextFactory becouse in your CLASSPATH you have another jndi classess.

                    Hope That Help

                    Enrique.

                    • 7. Re: InitilaContext instantiation error
                      lasterra

                      Hola Javi,

                      We find the error¡¡¡

                      In our case the problem was that jndi.jar was inside the webapp (war file) in the lib directory. The problem was in our ANTs files.

                      When we correct it, the app was ok.

                      So i suspect that you have a similar problem, you are trying to cast a javax.naming.NoInitialContextException to a class different of org.jnp.interfaces.NamingContextFactory becouse in your CLASSPATH you have another jndi classess.

                      Hope That Help

                      Enrique.