[jboss-user] [JNDI and Naming] - dependent class can't be found when invoke by java -classpath xxx -jar jarfile, but can be found by java -classpath xx class

Bond Chan do-not-reply at jboss.com
Thu Jun 21 03:36:46 EDT 2012


Bond Chan [https://community.jboss.org/people/bondchan921] created the discussion

"dependent class can't be found when invoke by java -classpath xxx -jar jarfile, but can be found by java -classpath xx class"

To view the discussion, visit: https://community.jboss.org/message/743272#743272

--------------------------------------------------------------
c1, java -cp LRS3rdPartyClient.jar -jar tasks.jar
c2, java -classpath LRS3rdPartyClient.jar;tasks.jar com.lombardrisk.build.WaitForServerStart
c1 can't be executed due to an class(org.jnp.interfaces.NamingContextFactory) can't be found which reside in LRS3rdPartyClient.jar, whereas the c2 can execute
quite confused,

exception thrown by c1:
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(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.init(Unknown Source)
        at javax.naming.InitialContext.<init>(Unknown Source)
        at com.lombardrisk.build.WaitForServerStart.main(WaitForServerStart.java:29)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory
        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)
        ... 5 more
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/743272#743272]

Start a new discussion in JNDI and Naming at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120621/63acad0c/attachment-0001.html 


More information about the jboss-user mailing list