views:

117

answers:

1

Hi,

I get the "java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac tory" error while running my packaged ejb3 swing client jar. Here's the stack trace.

G:\Courses\OSUMC\Installables\June 5\New>java -jar MetaDB-Client.jar
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interf
aces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: o
rg.jnp.interfaces.NamingContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at net.massmatrix.metadb.ui.facade.BaseEJBFacade.getInitialContext(BaseE
JBFacade.java:26)
        at net.massmatrix.metadb.ui.facade.UserManagerFacade.getUserManager(User
ManagerFacade.java:24)
        at net.massmatrix.metadb.ui.facade.UserManagerFacade.isUserNameAvailable
(UserManagerFacade.java:44)
        at net.massmatrix.metadb.ui.MainFrame.main(MainFrame.java:269)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFac
tory
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
        ... 8 more
Exception in thread "main" java.lang.NullPointerException
        at net.massmatrix.metadb.ui.facade.UserManagerFacade.isUserNameAvailable
(UserManagerFacade.java:44)
        at net.massmatrix.metadb.ui.MainFrame.main(MainFrame.java:269)

Here are my packaged swing client Jar contents:-

MetaDB-Client.jar
  \net\.. - contains class files(from both client and server)
  META-INF
    MANIFEST.MF
  jndi.properties

Here's my jndi.properties:-

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

Here's my MANIFEST.MF:-

Manifest-Version: 1.0
Main-Class: net.massmatrix.metadb.ui.MainFrame
Class-Path: jbossall-client.jar

Manifest contents from my jar:-

Manifest-Version: 1.0
Created-By: 1.6.0_18 (Sun Microsystems Inc.)
Main-Class: net.massmatrix.metadb.ui.MainFrame

Command used to create the jar:-

jar cfm MetaDB-Client.jar MANIFEST.MF net\* jndi.properties

Command used to run the jar:-

java -jar MetaDB-Client.jar

I have the jbossall-client.jar in my classpath

G:\Courses\OSUMC\Installables\June 5\New>echo %CLASSPATH%
.;G:\Courses\OSUMC\WORK\Software - New\jboss-5.0.1.GA\client

What else am i missing ?

Thanks.

A: 

All you have to do is add the jbossall-client.jar library to the clients lib folder.
ClassPath in the MANIFEST cannot have * in it.
Here is the tutorial for the JAR manifest classpath.

Romain Hippeau
Hi, I have made the changes you suggested. However, I still see the same error. Any other guesses what the problem might be ?Thanks
soontobeared
@soontobeared can you post your MANIFEST contents from your jar ?
Romain Hippeau
@Romain - I did. Please look into my edited post.
soontobeared
@soontobearded After reading more carefully the link I posted in my answer this will not work. Put the jboss Jar file in the classpath/lib folder on your drive and then try it.As per the link ...Note: The Class-Path header points to classes or JAR files on the local network, not JAR files within the JAR file or classes accessible over internet protocols. ...
Romain Hippeau
@Romain - I did as you suggested. I am not including the jbossclient jar and instead had it in my classpath;but, I still see the same error. Please look into my edited post for the changes I made. Thanks.
soontobeared