我测试的源代码是这样的,请帮忙看一下哪个地方错了(我用jbuilder7自动生成的,只在main方法中添加了代码,其他都是自动生成的。):
package cmptest;import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import java.sql.Timestamp;/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author unascribed
 * @version 1.0
 */public class EmployeesTestClient1 {
  static final private String ERROR_NULL_REMOTE = "Remote interface reference is null.  It must be created by calling one of the Home interface methods first.";
  static final private int MAX_OUTPUT_LINE_LENGTH = 100;
  private boolean logging = true;
  private EmployeesRemoteHome employeesRemoteHome = null;
  private EmployeesRemote employeesRemote = null;  //Construct the EJB test client
  public EmployeesTestClient1() {
    long startTime = 0;
    if (logging) {
      log("Initializing bean access.");
      startTime = System.currentTimeMillis();
    }    try {
      //get naming context
      Context ctx = getInitialContext();      //look up jndi name
      Object ref = ctx.lookup("EmployeesRemote");      //cast to Home interface
      employeesRemoteHome = (EmployeesRemoteHome) PortableRemoteObject.narrow(ref, EmployeesRemoteHome.class);
      if (logging) {
        long endTime = System.currentTimeMillis();
        log("Succeeded initializing bean access.");
        log("Execution time: " + (endTime - startTime) + " ms.");
      }
    }
    catch(Exception e) {
      if (logging) {
        log("Failed initializing bean access.");
      }
      e.printStackTrace();
    }
  }  private Context getInitialContext() throws Exception {
    String url = "t3://localhost:7001";
    String user = null;
    String password = null;
    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) {
      log("Unable to connect to WebLogic server at " + url);
      log("Please make sure that the server is running.");
      throw e;
    }
  }

解决方案 »

  1.   

    //----------------------------------------------------------------------------
      // Utility Methods
      //----------------------------------------------------------------------------  private void log(String message) {
        if (message == null) {
          System.out.println("-- null");
          return ;
        }
        if (message.length() > MAX_OUTPUT_LINE_LENGTH) {
          System.out.println("-- " + message.substring(0, MAX_OUTPUT_LINE_LENGTH) + " ...");
        }
        else {
          System.out.println("-- " + message);
        }
      }
      //Main method  public static void main(String[] args) {
        EmployeesTestClient1 client = new EmployeesTestClient1();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
       // EmployeesTestClient1 client=new EmployeesTestClient1();
        client.findByPrimaryKey(new Integer(1));
        if(client.employeesRemote==null){
          System.out.println("使用缺省参数测试远程调用的时候出错:"+ERROR_NULL_REMOTE);
          return;
        }
        client.getEmployeeID();
        client.getLastName();
        client.getFirstName();
        client.getTitle();
        client.getTitleOfCourtesy();
        client.getBirthDate();
        client.getHireDate();
        client.getAddress();
        client.getCity();
        client.getRegion();
        client.getPostalCode();
        client.getCountry();
        client.getHomePhone();
        client.getExtension();
        client.getPhoto();
        client.getNotes();
        client.getReportsTo();
        client.getPhotoPath();  }
    }
      

  2.   

    你的test程序哪里有findByPrimary方法啊,反正我是没有看到
    remote接口也没有看到初始化