一个Servlet调用一个EJB的方法的问题?(100分)

Z

zhfhq

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在正在用EJB开发一个电子商场的例子,我其中用到了一个是用一个Servlet调用一个EJB的方法,
可是总是出现以下的异常:
ava.rmi.MarshalException: CORBA MARSHAL 0[Error unmarshaling value [Error unmarshaling value [The delegate has not been set!]]]
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.newInstance(UtilImpl.java:82)
at com.inprise.vbroker.rmi.CORBA.UtilImpl._mapSystemException(UtilImpl.java:326)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.mapSystemException(UtilImpl.java:451)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
at storetest._Quote_Stub.getLineItems(_Quote_Stub.java:450)
at storetest.ShowQuoteServlet.doGet(ShowQuoteServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:597)
at org.apache.tomcat.servlets.InvokerServlet.service(InvokerServlet.java:257)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:160)
at org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
at java.lang.Thread.run(Thread.java:484)
我的调用语句如下:
Collection lineItems=(Collection)PortableRemoteObject.narrow(quote.getLineItems(),Collection.class);

Collection lineItems=(Collection)quote.getLineItems();
其中quote是一个Sateful Session Bean,而getLineItems方法很简单,
就是把我这个Session Bean中的lineItems变量返回。
但是我调用这个quote的其他方法都行,请问这是为何?
 
大侠,回答吗?
 
检查一下getLineItem()是不是返回空(NULL),有可能是这问题。先试试,等我想想。
 
to JJams_King:
调用其他方法是没有问题,并且getLineItems()也没有返回空
 
lineItems变量是Collection类型,我开始用的是Vector类型,也不行
 
lineItems变量是Collection类型,我开始用的是Vector类型,也不行
 
我的LineItems中的元素是我的另外一个EJB对象,也就是说我现在的getLineItems()是我的购物车的EJB对象
中的一个方法,而放入购物车的是我的物品,它是一个EJB对象,我现在在服务器段的getLineItems方法中加入
了这样的代码:
public Collection getLineItems() throws RemoteException
{
System.out.println("Quote Called GetLinetItems()");
if(lineItems==null)
System.out.println("The Quote LineItems is Null");
Object[] e=lineItems.toArray();
for(int i=0;i<e.length;i++)
{
System.out.println("Print The LineItems's element");
System.out.println((Object)e);
}
return lineItems;
}
得到的结果是(我放入了一个物品):
Quote Called GetLinetItems()
Print The LineItems's element
Stub[repository_id=RMI:storetest.QuoteLineItem:0000000000000000,key=ServiceId[service=/EJB[ejbcontainer]QuoteLineItem,id={1 bytes: [0]}],codebase=null]
 
sorry ,少写了一些:
public Collection getLineItems() throws RemoteException
{
System.out.println("Quote Called GetLinetItems()");
if(lineItems==null)
System.out.println("The Quote LineItems is Null");
Object[] e=lineItems.toArray();
for(int i=0;i<e.length;i++)
{
System.out.println("Print The LineItems's element");
System.out.println((Object)e);
}
return lineItems;
}
输出结果:
Quote Called GetLinetItems()
Print The LineItems's element
Stub[repository_id=RMI:storetest.QuoteLineItem:0000000000000000,key=ServiceId[service=/EJB[ejbcontainer]QuoteLineItem,id={1 bytes: [0]}],codebase=null]
 
没搞错吧,我写的都没有出来:
for(int i=0;i<e.length;i++)
{
System.out.println("Print The LineItems's element");
System.out.println((Object)e);
}
return lineItems;
 
没搞错吧,我写的不出来,我的for循环是将Lineitems的元素都打印出来:
System.out.println("Print The LineItems's element");
System.out.println((Object)e);
输出的结果是:
Print The LineItems's element
Stub[repository_id=RMI:storetest.QuoteLineItem:0000000000000000,key=ServiceId[service=/EJB[ejbcontainer]QuoteLineItem,id={1 bytes: [0]}],codebase=null]
 
lineItems变量是什么类型?
Collection的各个元素是什么,能不能打出来看看?
搞不懂为什么。能不能先写一个客户试一下,看看问题是在Servlet上,还是在EJB上。
 
还不行呀,在客户端一调用这个方法就出现这个问题,根本看不出来那里出了问题。
我现在怀疑是我那里没有配置好,因为我还有另外一个EJB的方法,我连续执行两次都没有问题,可是一到第三次,我就回出现这个
类似的问题。
 
这个问题实在是太难了,搞的我的头都大了
 
这个问题可能太难了,谁要是帮我回答,我愿意给他500分
 
试一下把Collection的各个元素narrow一下然后再用。
 
这个问题,我在去年的一个项目中也遇到过,不止一次。并不一定是程序的问题。
也有可能,是Server的问题。去年项目:JB+Weblogic+JRun+Oracle8.1.6的环境配置。
在混乱的Classpath,及不明的情况下有时会出现java.rmi.MarshalException。
可看到表现的rmi的例外具体程序也要认真check。
 
To JJams_King:
I try it ,it is notdo
 
多人接受答案了。
 
顶部