请教一个关于EJB创建对象时的问题

04-04-28 flag
在调试一个有状态会话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();

}

kevinyao
2004-04-28 18:22
此问题我常遇见,一般是如下原因(自己不仔细导致):

1.没有按照EJB规范写代码.

2.部署EJB时有问题.

廉价劳力
2004-04-29 08:45
你的Stateful Bean序列化有没有问题?

猜你喜欢