javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory

今天遇到了一个很郁闷的 问题,以下内容摘自

 

http://www.dingkao.com/a/100724/167554/

 

 哪位仁兄懂EJB3,我用InitialContext init = new InitialContext();
读取jndi.properties ,jboss中client包已经全部导入怎么还是不行。
我已经晕掉了,我用myeclipse6+jboss4.2

报异常:

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.(Unknown Source)
at Test.main(Test.java:20)
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.ClassLoader.loadClassInternal(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

 

 我晕啊,java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory后面带给空格就不能处理了,这个InitialContext 不能去空格

 

 

解决办法: jndiproperties的属性值后面不能带空格

你可能感兴趣的:(EJB3)