你的测试端有问题,如果是weblogic的话,要加上
String url = "t3://wangqiang:7001";
    String user = null;
    String password = null;
    Properties properties = null;
    
      properties = new Properties();
      properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
      properties.put(Context.PROVIDER_URL, url);
      if (user != null) {
        properties.put(Context.SECURITY_PRINCIPAL, user);
        properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
      
 Context context = new InitialContext(properties);
      //look up jndi name
      Object ref = context.lookup("...");
...

解决方案 »

  1.   

    WebSphere:  
    Context.INITIAL_CONTEXT_FACTORY  
     "com.ibm.websphere.naming.WsnInitialContextFactory  "  
    Context.PROVIDER_URL  
     "iiop://localhost:900  "  
    Weblogic:  
    Context.INITIAL_CONTEXT_FACTORY  
       "weblogic.jndi.WLInitialContextFactory  "  
    Context.PROVIDER_URL  
       "t3://127.0.0.1:7001  "               
     
       J2EE  SDK(J2EE  RI):  
    Context.INITIAL_CONTEXT_FACTORY  
       "com.sun.jndi.cosnaming.CNCtxFactory  "  
    Context.PROVIDER_URL  
       "iiop://127.0.0.1:1050  "  
     
    SilverStream:  
    Context.INITIAL_CONTEXT_FACTORY  
     "com.sssw.rt.jndi.AgInitCtxFactory  "  
    Context.PROVIDER_URL  
     "sssw://localhost:80  "   
      
    OC4J
    Context.INITIAL_CONTEXT_FACTORY
    "com.evermind.server.rmi.RMIInitialContextFactory"
    Context.PROVIDER_URL
    "ormi://127.0.0.1/"  
     
    JBOSS的:
    java.naming.factory.initial
    "org.jnp.interfaces.NamingContextFactory"
    java.naming.provider.url
    "localhost:1099"    
    WAS5:
    Context.INITIAL_CONTEXT_FACTORY  
     "com.ibm.websphere.naming.WsnInitialContextFactory  "  
    Context.PROVIDER_URL  
     "iiop://localhost:2809  "
     ------------------------------------------------------
               我们还年轻牛奶会有的奶牛也会有的 
                 可天天在 csdn 混这些会有吗 ??
      

  2.   

    另外,Properties properties = null; 应该属于哪个包?
      

  3.   

    已经按照提示修改了,但编译后又报错如下:javax.naming.ConfigurationException.  Root exception is java.rmi.MarshalException: error marshalling return; nested exception is: 
    java.io.NotSerializableException: sample.ejb.session.LoginSessionBean_ugujnx_LocalHomeImpljava.io.NotSerializableException: sample.ejb.session.LoginSessionBean_ugujnx_LocalHomeImpl <<no stack trace available>>
      

  4.   

    WebLogic中的ConnectPool没有设置成功
      

  5.   

    你的EJB暴露的是LOCAL 接口,而不是 REMOTE  接口!
      

  6.   

    本例中,全部都是Local和LocalHome接口,难道不能正常工作吗?我的应用本来就是在一个JVM下完成的,没有必要使用分布式计算,应该用Local和LocalHome接口呀!