7 Replies Latest reply on Feb 15, 2003 8:26 PM by Richard Doust

    Weird ClassNotFoundException when running application client

    Peter Korsten Newbie

      I have a weird problem with an application client that I want to put in a self-contained JAR file, so it can be executed on any machine without having to install additional software or libraries.

      The application client works well if I call the main class directly, with the four required JBoss client classes in the class path.

      But if I try it from the JAR, what I get is this:

      java.lang.Exception: javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
      at vodafonemalta.directory.client.DirectoryClient.sessionOpen(DirectoryClient.java:70)
      at vodafonemalta.directory.client.DirectoryClient.main(DirectoryClient.java:178)
      Caused by: 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:652)
      at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
      at javax.naming.InitialContext.init(InitialContext.java:219)
      at javax.naming.InitialContext.(InitialContext.java:175)
      at vodafonemalta.directory.client.DirectoryClient.sessionOpen(DirectoryClient.java:61)
      ... 1 more


      This is the jndi.properties file, which I included in the 'Class-Path' field of the MANIFEST.MF file:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.provider.url=jnp://phobos/
      java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
      jnp.socketFactory=org.jnp.interfaces.TimedSocketFactory
      jnp.timeout=0
      jnp.sotimeout=0


      These are the JBoss JAR files that I included in the application client's JAR file, and which are also included in the 'Class-Path' fields of the manifest, as mentioned above:

      jbossall-client.jar
      jbossjmx-ant.jar
      jnp-client.jar
      log4j.jar


      (I put the five files - the jndi.properties and the four client JARs - each in their own 'Class-Path' field, after I discovered that Ant wrapped the line, but it didn't make a difference.)

      I've written a small test application that instantiates a NamingContextFactory object, and put it in a JAR file, with the manifest file and the four client JARs. It works fine.

      It seems to me that I have everything covered, yet it complains that it can't locate the NamingContextFactory class. Is it something obvious that I'm overlooking?

      Thanks,

      - Peter