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)
开发者_如何学Pythonat 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.
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.
精彩评论