2 Replies Latest reply on Nov 17, 2011 1:40 PM by gregcharles

    new InitialContext() fails.

    gregcharles

      Running under JBoss 7.0.2, when I try to instantiate InitialContext in preparation for a JNDI lookup, it fails with this error:

       

      WARNING [javax.enterprise.resource.webcontainer.jsf.config] (MSC service thread 1-1) javax.naming.NamingException: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.xxxxxx.war:main" from Service Module Loader

       

      Following advice on this thread: http://community.jboss.org/thread/168952 , I fixed my problem by setting:

       

      java.naming.factory.initial=org.jboss.as.naming.InitialContextFactory

       

      either in a properties hash fed to the InitialContext constructor, or via a system property set in the startup script.

       

      My question is why is this necessary? Do I have something misconfigured? Is it a bug? I found an issue report at https://issues.jboss.org/browse/AS7-1936, but I really can't tell if that's the same problem or not.

        • 1. Re: new InitialContext() fails.
          jaikiran

          Gregory Charles wrote:

           

           

           

          My question is why is this necessary? Do I have something misconfigured? Is it a bug? I found an issue report at https://issues.jboss.org/browse/AS7-1936, but I really can't tell if that's the same problem or not.

          In previous versions of JBoss AS we used to use jnp project for JNDI naming implementation. Furthermore, the JBoss AS used to ship a default jndi.properties in JBOSS_HOME/server/<servername>/conf folder which had the correct jnp initial context factory reference. In AS7, the jnp project isn't used and the jars aren't shipped. That's why the change in the value of that initial context factory. AS7 doesn't ship a jndi.properties and hence you are passing the properties explicitly now.

          • 2. Re: new InitialContext() fails.
            gregcharles

            Thanks for the explanation Jakiran! Is there somewhere I could put a jndi.properties now which would be equivalant to the JBOSS_HOME/server/<servername>/conf folder of previous versions? I tried JBOSS_HOME/standalone/configuration, but it didn't work.

             

            Also, I have to ask ... JNDI is pretty fundamental to the operations of a Java application server. Why wouldn't it be configured to work right out of the box?