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 Test1.main(Test1.java:41) 
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 
我的客户端是这么写的: Properties properties = new Properties(); properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, 
                "org.jnp.interfaces.NamingContextFactory"); properties.setProperty(Context.URL_PKG_PREFIXES, 
"org.jboss.naming:org.jnp.interfaces"); properties.setProperty(Context.PROVIDER_URL, "jnp://localhost:8080"); Context context; 
try { 
context = new InitialContext(properties); 
Object o = context.lookup("ejb/Hello"); HelloHome hwh = (HelloHome) PortableRemoteObject.narrow(o, HelloHome.class); 
Hello hw = hwh.create(); 
String s = hw.sayHello(); 
System.out.println(s); 
} catch (NamingException e) { 
e.printStackTrace(); 
} catch (RemoteException e) { 
e.printStackTrace(); 
} catch (CreateException e) { 
e.printStackTrace(); 


解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【yukuo】截止到2008-07-15 15:50:05的历史汇总数据(不包括此帖):
    发帖的总数量:5                        发帖的总分数:190                      每贴平均分数:38                       
    回帖的总数量:5                        得分贴总数量:1                        回帖的得分率:20%                      
    结贴的总数量:4                        结贴的总分数:170                      
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:1                        未结的总分数:20                       
    结贴的百分比:80.00 %               结分的百分比:89.47 %                  
    无满意结贴率:0.00  %               无满意结分率:0.00  %                  
    楼主加油
      

  2.   

    没有相应的包,EJB需要很多包!
      

  3.   


    我已经在myeclipse里引进很多包了 能说的在详细些吗??  谢谢