請教一個關於EJB建立物件時的問題

flag發表於2004-04-28
在除錯一個有狀態會話Bean時,用了一個如下客戶端測試程式(如下),但在執行到:
//建立EJB物件(注:“112233445566”是ID,"123456"是密碼)
UserAccount user=hm.create("112233445566","123456");

發生如下異常錯誤(注:EJB元件已經部署到容器上):
java.rmi.RemoteException: EJB Exception:; nested exception is:
java.lang.NullPointerException

at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)
.......

各位高手,若知道原因,請回復一下,非常感謝!
客戶端測試程式相關程式碼如下(用EJB Client Test模板生成):
public static void main(String[] args)
{
UserAccountTestClient client = new UserAccountTestClient();
//返回Home介面
UserAccountHome hm=client.getHome();
try
{
//建立EJB物件
UserAccount user=hm.create("112233445566","123456");
//UserAccount user=hm.create(username,password);

System.out.println("Balance:"+user.Balance());
//呼叫EJB物件中的方法
user.Deposit(10000);
System.out.println("The user has deposit some money. Now the balance is:"
+user.Balance());
user.Withdraw(200);
System.out.println("The user has withdraw some money. Now the balance is:"
+user.Balance());
user.Transfer("123456123456",4000);
System.out.println("The user has transfer some money. Now the balance is:"
+user.Balance());
user.remove();
}
catch(Exception ex)
{
ex.printStackTrace();
}

相關文章