我的测试类代码
package myjsp;import javax.naming.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import javax.sql.RowSet;
import javax.sql.*;
import javax.sql.rowset.CachedRowSet;
import java.sql.*;
import com.sun.rowset.*;//.CachedRowSetImpl;/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */public class myFirstBeanTestClient1 extends Object {
  private static final String ERROR_NULL_REMOTE = "Remote interface reference is null.  It must be created by calling one of the Home interface methods first.";
  private static final int MAX_OUTPUT_LINE_LENGTH = 100;
  private boolean logging = true;
  private myFirstHome myFirstHomeObject = null;
  private myFirst myFirstObject = null;  //Construct the EJB test client
  public myFirstBeanTestClient1() {
    initialize();
  }  public void initialize() {
    long startTime = 0;
    if (logging) {
      log("Initializing bean access.");
      startTime = System.currentTimeMillis();
    }    try {
      //get naming context
      Context context = getInitialContext();      //look up jndi name
      Object ref = context.lookup("myFirstBean");
      //look up jndi name and cast to Home interface
      myFirstHomeObject = (myFirstHome) PortableRemoteObject.narrow(ref, myFirstHome.class);
      System.out.println("fdsf" + myFirstHomeObject);
      myFirstObject = myFirstHomeObject.create();
      System.out.println("Create()->" + myFirstObject);
      CachedRowSet mm = myFirstObject.GetNsrInfo("220204000009");
//      myFirstObject..GetNsrInfo("220204000009");
      if (logging) {
        long endTime = System.currentTimeMillis();
        log("Succeeded initializing bean access through Home interface.");
        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://sf: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;
    }
  }  //----------------------------------------------------------------------------
  // Methods that use Home interface methods to generate a Remote interface reference
  //----------------------------------------------------------------------------  public myFirst create() {
    long startTime = 0;
    if (logging) {
      log("Calling create()");
      startTime = System.currentTimeMillis();
    }
    try {
      myFirstObject = myFirstHomeObject.create();
      if (logging) {
        long endTime = System.currentTimeMillis();
        log("Succeeded: create()");
        log("Execution time: " + (endTime - startTime) + " ms.");
      }
    }
    catch(Exception e) {
      if (logging) {
        log("Failed: create()");
      }
      e.printStackTrace();
    }    if (logging) {
      log("Return value from create(): " + myFirstObject + ".");
    }
    return myFirstObject;
  }  //----------------------------------------------------------------------------
  // Methods that use Remote interface methods to access data through the bean
  //----------------------------------------------------------------------------  public RowSet GetNsrInfo(String swdm) {
    RowSet returnValue = null;    if (myFirstObject == null) {
      System.out.println("Error in GetNsrInfo(): " + ERROR_NULL_REMOTE);
      return returnValue;
    }    long startTime = 0;
    if (logging) {
      log("Calling GetNsrInfo(" + swdm + ")");
      startTime = System.currentTimeMillis();
    }    try {
      returnValue = myFirstObject.GetNsrInfo(swdm);
      if (logging) {
        long endTime = System.currentTimeMillis();
        log("Succeeded: GetNsrInfo(" + swdm + ")");
        log("Execution time: " + (endTime - startTime) + " ms.");
      }
    }
    catch(Exception e) {
      if (logging) {
        log("Failed: GetNsrInfo(" + swdm + ")");
      }
      e.printStackTrace();
    }    if (logging) {
      log("Return value from GetNsrInfo(" + swdm + "): " + returnValue + ".");
    }
    return returnValue;
  }  public void executeRemoteCallsWithDefaultArguments() {
    if (myFirstObject == null) {
      System.out.println("Error in executeRemoteCallsWithDefaultArguments(): " + ERROR_NULL_REMOTE);
      return ;
    }
    GetNsrInfo("");
  }  //----------------------------------------------------------------------------
  // 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) {
    myFirstBeanTestClient1 client = new myFirstBeanTestClient1();
    // 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.
  }
}
-----------------------------------------------------------------

解决方案 »

  1.   

    测试类错误信息
    这是运行测试类的错误信息:
    应该是测试类里的CachedRowSet mm = myFirstObject.GetNsrInfo("220204000009")错了,前面的提示都已经出来了。
    不知道为什么。
    java.rmi.RemoteException: EJB Exception: ; nested exception is: 
    java.lang.NoClassDefFoundError: com/sun/rowset/CachedRowSetImpl at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284) at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)-- Failed initializing bean access. at myjsp.myFirstBean_fljp8g_EOImpl_811_WLStub.GetNsrInfo(Unknown Source) at myjsp.myFirstBeanTestClient1.initialize(myFirstBeanTestClient1.java:51) at myjsp.myFirstBeanTestClient1.<init>(myFirstBeanTestClient1.java:30) at myjsp.myFirstBeanTestClient1.main(myFirstBeanTestClient1.java:187)Caused by: java.lang.NoClassDefFoundError: com/sun/rowset/CachedRowSetImpl at myjsp.myFirstBean.GetNsrInfo(myFirstBean.java:50) at myjsp.myFirstBean_fljp8g_EOImpl.GetNsrInfo(myFirstBean_fljp8g_EOImpl.java:46) at myjsp.myFirstBean_fljp8g_EOImpl_WLSkel.invoke(Unknown Source) at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:466) at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108) at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:409) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144) at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:404) at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30) at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197) at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
      

  2.   

    你的CachedRowSetImpl  类怎么没看到??里面是些什么???
      

  3.   

    看看你的JNDI的名称是否跟你的lookup("...")中的一致