6 Replies Latest reply on Mar 3, 2011 2:35 AM by Adam Lasek

    JNDI-Exception in NamingContextFactory

    Adam Lasek Newbie

      I've got Exception  when I've trying to run EJB3 client. It works in Eclipse.

       

      java -jar Client.jar  -cp /opt/jboss/client/jbossall-client.jar

      Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]

          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)

          at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

          at javax.naming.InitialContext.init(InitialContext.java:223)

          at javax.naming.InitialContext.<init>(InitialContext.java:175)

          at pz.ejb3.client.Client.main(Unknown Source)

      Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

          at java.net.URLClassLoader$1.run(URLClassLoader.java:200)

          at java.security.AccessController.doPrivileged(Native Method)

          at java.net.URLClassLoader.findClass(URLClassLoader.java:188)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:307)

          at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

          at java.lang.ClassLoader.loadClass(ClassLoader.java:252)

          at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)

          at java.lang.Class.forName0(Native Method)

          at java.lang.Class.forName(Class.java:247)

          at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)

          at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)

          ... 4 more

        • 1. JNDI-Exception in NamingContextFactory
          Wolf-Dieter Fink Master

          What JBoss version do you use?

          With JB5 the all-client is only with link to all other jars.

          Otherwise it looks like a misconfigured Eclipse.

          • 2. JNDI-Exception in NamingContextFactory
            Adam Lasek Newbie

            Jboos  5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)

             

            When I run my program in Eclipse I don't have any problems, but when I try to run its from command line, I get this exception.

            • 3. JNDI-Exception in NamingContextFactory
              Wolf-Dieter Fink Master

              Oh I read wrong 'It works in eclipse' sorry.

              Is /opt/jboss your running JBoss instance with the complete client archives?

               

              The jnp-client.jar should include the class.

              Do you made changes in the client directory?

              For me it works.

              • 4. JNDI-Exception in NamingContextFactory
                Adam Lasek Newbie

                No problem. My English isn't good.

                No I don't . This is list of jars in client direcotry.

                jarlist.jpg

                I also set CLASSPATH

                export CLASSPATH=$CLASSPATH:/opt/jboss/client

                but it still doesn't work.

                • 5. JNDI-Exception in NamingContextFactory
                  Wolfgang Knauf Master

                  Hi,

                   

                  when the "CLASSPATH" is specified for a directory, it will only inlcude "*.class" files, but not "*.jar" files.

                   

                  But it might work, if you add a wildcard to thee end:

                  export CLASSPATH=$CLASSPATH:/opt/jboss/client/*

                   

                  See here:

                  http://download.oracle.com/javase/6/docs/technotes/tools/windows/classpath.html

                   

                  I am not sure whether this feature was added in Java 1.5 or 1.6, so depending on your version it might not work. In this case, you have to add every single jar to the Classpath.

                   

                  Hope this helps

                   

                  Wolfgang

                  • 6. JNDI-Exception in NamingContextFactory
                    Adam Lasek Newbie

                    Hi.

                    No, this didn' t help.

                    I have also ant build script, when I run it, I got exactly the same exception.

                     

                        <path id="jboss.client">

                           <fileset dir="${jboss.home}/client" includes="*.jar" />

                         </path>

                     

                     

                        <target name ="run-client">

                            <echo>running with classpath ${toString:jboss.client}</echo>

                            <java  classpath="${build.dir}" jar="${build.dir}/Client.jar" fork="true" classpathref="jboss.client"/>

                        </target>

                     

                    run-client:

                         [echo] running with classpath /opt/jboss/client/FastInfoset.jar:/opt/jboss/client/activation.jar:/opt/jboss/client/antlr.jar:/opt/jboss/client/avalon-framework.jar:/opt/jboss/client/commons-logging.jar:/opt/jboss/client/concurrent.jar:/opt/jboss/client/ejb3-persistence.jar:/opt/jboss/client/getopt.jar:/opt/jboss/client/hibernate-annotations.jar:/opt/jboss/client/jacorb.jar:/opt/jboss/client/javassist.jar:/opt/jboss/client/jaxb-api.jar:/opt/jboss/client/jaxb-impl.jar:/opt/jboss/client/jaxb-xjc.jar:/opt/jboss/client/jaxws-rt.jar:/opt/jboss/client/jaxws-tools.jar:/opt/jboss/client/jboss-aop-client.jar:/opt/jboss/client/jboss-appclient.jar:/opt/jboss/client/jboss-aspect-jdk50-client.jar:/opt/jboss/client/jboss-client.jar:/opt/jboss/client/jboss-common-core.jar:/opt/jboss/client/jboss-deployers-client-spi.jar:/opt/jboss/client/jboss-deployers-client.jar:/opt/jboss/client/jboss-deployers-core-spi.jar:/opt/jboss/client/jboss-deployers-core.jar:/opt/jboss/client/jboss-deployers-vfs-spi.jar:/opt/jboss/client/jboss-deployers-vfs.jar:/opt/jboss/client/jboss-deployment.jar:/opt/jboss/client/jboss-ejb3-common-client.jar:/opt/jboss/client/jboss-ejb3-core-client.jar:/opt/jboss/client/jboss-ejb3-ext-api-impl.jar:/opt/jboss/client/jboss-ejb3-ext-api.jar:/opt/jboss/client/jboss-ejb3-proxy-clustered-client.jar:/opt/jboss/client/jboss-ejb3-proxy-impl-client.jar:/opt/jboss/client/jboss-ejb3-proxy-spi-client.jar:/opt/jboss/client/jboss-ejb3-security-client.jar:/opt/jboss/client/jboss-ha-client.jar:/opt/jboss/client/jboss-ha-legacy-client.jar:/opt/jboss/client/jboss-iiop-client.jar:/opt/jboss/client/jboss-integration.jar:/opt/jboss/client/jboss-j2se.jar:/opt/jboss/client/jboss-jaspi-api.jar:/opt/jboss/client/jboss-javaee.jar:/opt/jboss/client/jboss-jsr77-client.jar:/opt/jboss/client/jboss-logging-jdk.jar:/opt/jboss/client/jboss-logging-log4j.jar:/opt/jboss/client/jboss-logging-spi.jar:/opt/jboss/client/jboss-main-client.jar:/opt/jboss/client/jboss-mdr.jar:/opt/jboss/client/jboss-messaging-client.jar:/opt/jboss/client/jboss-metadata.jar:/opt/jboss/client/jboss-remoting.jar:/opt/jboss/client/jboss-security-spi.jar:/opt/jboss/client/jboss-serialization.jar:/opt/jboss/client/jboss-srp-client.jar:/opt/jboss/client/jboss-system-client.jar:/opt/jboss/client/jboss-system-jmx-client.jar:/opt/jboss/client/jboss-xml-binding.jar:/opt/jboss/client/jbossall-client.jar:/opt/jboss/client/jbosscx-client.jar:/opt/jboss/client/jbossjmx-ant.jar:/opt/jboss/client/jbossjts-integration.jar:/opt/jboss/client/jbossjts.jar:/opt/jboss/client/jbosssx-as-client.jar:/opt/jboss/client/jbosssx-client.jar:/opt/jboss/client/jbossws-common.jar:/opt/jboss/client/jbossws-framework.jar:/opt/jboss/client/jbossws-jboss50.jar:/opt/jboss/client/jbossws-native-client.jar:/opt/jboss/client/jbossws-native-core.jar:/opt/jboss/client/jbossws-native-jaxrpc.jar:/opt/jboss/client/jbossws-native-jaxws-ext.jar:/opt/jboss/client/jbossws-native-jaxws.jar:/opt/jboss/client/jbossws-native-saaj.jar:/opt/jboss/client/jbossws-spi.jar:/opt/jboss/client/jettison.jar:/opt/jboss/client/jmx-client.jar:/opt/jboss/client/jmx-invoker-adaptor-client.jar:/opt/jboss/client/jnp-client.jar:/opt/jboss/client/log4j.jar:/opt/jboss/client/logkit.jar:/opt/jboss/client/mail.jar:/opt/jboss/client/policy.jar:/opt/jboss/client/scout.jar:/opt/jboss/client/slf4j-api.jar:/opt/jboss/client/slf4j-jboss-logging.jar:/opt/jboss/client/stax-api.jar:/opt/jboss/client/stax-ex.jar:/opt/jboss/client/streambuffer.jar:/opt/jboss/client/trove.jar:/opt/jboss/client/wsdl4j.jar:/opt/jboss/client/wstx.jar:/opt/jboss/client/xmlsec.jar

                         [java] Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]

                         [java]     at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)

                         [java]     at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)

                         [java]     at javax.naming.InitialContext.init(InitialContext.java:223)

                         [java]     at javax.naming.InitialContext.<init>(InitialContext.java:175)

                         [java]     at pz.ejb3.client.Client.main(Unknown Source)

                         [java] Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

                    .....

                     

                    Adam