你应该将你的EJB CLASS文件也要放入你的CLASSPATH中的!(可能)呵呵!

解决方案 »

  1.   

    我已经把EJB的JAR包加到CLASSPATH中了呀。
      

  2.   

    我认为是你下面的代码不对
        Properties p = new Properties();
        p.put(Context.INITIAL_CONTEXT_FACTORY,
            "weblogic.jndi.WLInitialContextFactory");
        p.put(Context.PROVIDER_URL, "t3://localhost:7001");
        p.put(Context.SECURITY_PRINCIPAL,"system");
        p.put(Context.SECURITY_CREDENTIALS,"password");
    有可能是你Context.SECURITY_PRINCIPAL,及Context.SECURITY_CREDENTIALS
    不对
      

  3.   

    对,是这段代码报错。但我是用JBUILDER自动生成的代码呀,且在JBUILDER环境中可运行,程序如下:    private Context getInitialContext() throws Exception {
            String url = "t3://localhost:7001";
            String user = "system";
            String password = "12345678";
            Properties properties = null;
            try {
                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);
                }            return new InitialContext(properties);  //这里报错
            }
            catch(Exception e) {
                //System.out.println("Unable to connect to WebLogic server at " + url);
                //System.out.println("Please make sure that the server is running.");
                throw e;
            }
        }
        
    帮我看看怎么会事呀。
      

  4.   

    java -classpath "c:\bea\wlserver6.1\lib\weblogic.jar" ejbClient
      

  5.   

    是连接验证没通过!!!
    把用户名密码加上啊!!!
    properties.put(Context.SECURITY_PRINCIPAL, user);
    properties.put(Context.SECURITY_CREDENTIALS, "password");
      

  6.   

    "c:\bea\wlserver6.1\lib\weblogic.jar"已经在我的CLASSPATH中了。
      

  7.   

    String url = "t3://localhost:7001";
    String user = "system";
    String password = "12345678";我已经加了用户和密码。
      

  8.   

    将 j2ee.jar 加到path 里了没
      

  9.   

    我的CLASSPATH:
    .;C:\JBuilder6\jdk1.3.1\jre\lib\rt.jar;C:\JBuilder6\jdk1.3.1\jre\lib\i18n.jar;C:\JBuilder6\jdk1.3.1\lib\dt.jar;C:\JBuilder6\jdk1.3.1\lib\tools.jar;C:\bea\wlserver6.1\lib\wlepool.jar;C:\bea\wlserver6.1\lib\j2ee12.jar;C:\bea\wlserver6.1\lib\weblogic.jar;C:\bea\wlserver6.1\lib\ejb20.jar;D:\JClass
      

  10.   

    将j2ee.jar加上试试,好多服务器中都有,比如j2ee sdk,weblogic
      

  11.   


    java ........... -Djava.security.manager -Djava.security.policy= sample.policy 你的类名
    sample.policy 的内容为
    grant{
      permission java.security.AllPermission;
    };