好,我先把错误信息打出来,下面我输入执行命令 java henryclient 以后错误如下
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial上面就是全部了还有,我的EJB方面应该是没有问题,原因有2:1,我的EJB远程接口是好了的,我用本地JSP调用远程接口没有错误。2,就算我把EJB那台电脑关了,或者开着,上面的错误都一样,我认为EJB绝对没有问题。情告诉我怎么解决

解决方案 »

  1.   

    有两个可能:
    1. weblogic.jar不在classpath2.请替换如下代码:
    原:
    p.put("javax.naming.factory.initial","weblogic.jndi.WLinitialContextFactory");
    p.put("javax.naming.provider.url","t3://192.168.0.2:7001");
    改:
    p.put("java.naming.factory.initial","weblogic.jndi.WLinitialContextFactory");
    p.put("java.naming.provider.url","t3://192.168.0.2:7001");以第2种可能居大.
      

  2.   

    你必须在你实验得那台机器上classpath加上weblogic。jar路径,
      

  3.   

    我觉得这个问题并不简单,哈哈哈哈,我都弄了三天了。
    在CSDN也发了不少帖子了,可是到现在仍然没有解决。
    可能使我太弱智的缘故吧,也可能问题就在某一个细小的地方,
    很多人说的方法我都试过很多了,可问题依旧是这样。
    看来还要继续啊,哦,对了,我出现的问题基本上和楼主是同一类型的。
    用j2ee1.3本地测试成功,拿到另一台机器上就出异常.用weblogic也一样。
    用j2ee1.4本地也出异常。根本无法成功。
    都不知道该怎么办了,是不是我书看得少啊,哈哈哈哈哈。
      

  4.   

    String EJBSERVERURL = "t3://192.168.0.2:7001";
          Properties properties = null;
            properties = new Properties();
            properties.put(Context.INITIAL_CONTEXT_FACTORY,
                           "weblogic.jndi.WLInitialContextFactory");
            properties.put(Context.PROVIDER_URL, EJBSERVERURL);     
            Context context = new InitialContext(properties);
      

  5.   

    我认为是ejb的客户端类路径的问题.把客户端jar拷贝到客户机上,加入路径就应该可以的.试试吧.我也是刚学
      

  6.   

    支持augustbu()的观点
    String EJBSERVERURL = "t3://192.168.0.2:7001";
          Properties properties = null;
            properties = new Properties();
            properties.put(Context.INITIAL_CONTEXT_FACTORY,
                           "weblogic.jndi.WLInitialContextFactory");
            properties.put(Context.PROVIDER_URL, EJBSERVERURL);     
            Context context = new InitialContext(properties);可以试一试
      

  7.   

    <%@ page contentType="text/html; charset=GBK" %>
    <%@ page import="java.util.*"%>
    <%@ page import="javax.naming.*"%>
    <%@ page import="javax.rmi.PortableRemoteObject"%>
    <%@ page import="testejb.*"%>
    <html>
    <head>
        <title>TestPage</title>
    </head>
    <body bgcolor="#ffffff">
    <%
        Context context = null;
        Sample sample = null;
        
        //获取Context
        try 
        {
            String url = "t3://192.168.1.130:7001";
            String user = null;
            String password = null;
            Properties properties = null;
            out.println("debug | ready to set property ... <br/>");        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);
            }
            //
            out.println("debug | ready to create context ... <br/>");
            context = new InitialContext(properties);
        }
        catch (Exception ex) 
        {
            out.println("<br/>创建Context对象出错:" + ex);
            return;
        }    //查找Home接口,创建对象引用
        try
        {
            //look up jndi name
            Object ref = context.lookup("Sample");
            //look up jndi name and cast to Home interface
            SampleHome sampleHome = (SampleHome) PortableRemoteObject.narrow(ref, SampleHome.class);        //
            sample = sampleHome.create();
        }
        catch (Exception ex)
        {
            out.println("<br/>查找Home接口出错:" + ex);
            return;
        }    //调用EJB对象
        try
        {
            if (sample == null)
                throw new Exception("EJBObject is null.");
            //
            Vector v_result = sample.getUserList();
            while(!v_result.isEmpty())
                out.println("<br/>\t" + v_result.remove(0));
        }
        catch (Exception ex)
        {
            out.println("调用EJB对象出错:" + ex);
        }
    %>
    </body>
    </html>
      

  8.   

    http://expert.csdn.net/Expert/topic/2843/2843813.xml?temp=.5729334
      

  9.   

    用IIOP做客户到服务器的访问协议如何?