findall()出错!

钟伟海 2003-08-21 01:53:16
原代码:
try {
Context context = new InitialContext();

Object ref = context.lookup("Supplier");
supplierHome = (SupplierHome) PortableRemoteObject.narrow(ref, SupplierHome.class);

Collection c = supplierHome.findAll();
Iterator iterator = c.iterator();
while(iterator.hasNext()){
Supplier supplier = (Supplier)iterator.next();
System.out.println("the ordersitem's orderid "+ supplier.getShortName());
}

}
catch(Exception e) {
e.printStackTrace();
}

出错信息:

java.lang.ClassCastException: com.inprise.vbroker.rmi.CORBA.ObjectImpl

at supplier.SupplierTestClient1.initialize(SupplierTestClient1.java:40)

at supplier.SupplierTestClient1.<init>(SupplierTestClient1.java:17)

at supplier.SupplierTestClient1.main(SupplierTestClient1.java:112)


但我用findByPrimaryKey(String primaryKey)时没有问题,可以取出值来!
到底哪里出问题了
我是用JB8和BES服务器!
...全文
197 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sundery 2003-08-21
  • 打赏
  • 举报
回复
说说怎么解决的?
钟伟海 2003-08-21
  • 打赏
  • 举报
回复
我靠,终于是被我解决了,
钟伟海 2003-08-21
  • 打赏
  • 举报
回复
更正:
错误抛出在这句:
Supplier supplier = (Supplier)iterator.next();
System.out.println("ok");

"ok" 不会输出,如果屏蔽掉Supplier supplier = (Supplier)iterator.next();则没有错误提示!!!!

钟伟海 2003-08-21
  • 打赏
  • 举报
回复
//finall()

public java.util.Collection findAll () throws java.rmi.RemoteException, javax.ejb.FinderException {

try {
while (true) {
if (!_is_local()) {
org.omg.CORBA.portable.OutputStream _output = null;
org.omg.CORBA.portable.InputStream _input = null;
java.util.Collection _result;
try {
_output = this._request("findAll", true);
_input = this._invoke(_output);
_result = (java.util.Collection)((org.omg.CORBA_2_3.portable.InputStream)_input).read_value(java.util.Collection.class);
return _result;
}
catch (org.omg.CORBA.portable.ApplicationException _exception) {
final org.omg.CORBA.portable.InputStream in = _exception.getInputStream();
java.lang.String _exception_id = _exception.getId();
if (_exception_id.equals("IDL:javax/ejb/FinderEx:1.0")) {
_exception_id = in.read_string();
throw (javax.ejb.FinderException)((org.omg.CORBA_2_3.portable.InputStream)in).read_value();
}
//FIX: Wrap original Exception here?
throw new java.rmi.UnexpectedException("Unexpected User Exception: " + _exception_id);
}
catch (org.omg.CORBA.portable.RemarshalException _exception) {
continue;
}
finally {
this._releaseReply(_input);
}
} else {
final org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("findAll", _opsClass);
if (_so == null) {
continue;
}
final supplier.SupplierHomeOperations _self = (supplier.SupplierHomeOperations)_so.servant;
try {
java.util.Collection _ret = _self.findAll();
if (_so instanceof org.omg.CORBA.portable.ServantObjectExt) {
((org.omg.CORBA.portable.ServantObjectExt)_so).normalCompletion();
}
return _ret;
} catch (javax.ejb.FinderException x_1) {
if (_so instanceof org.omg.CORBA.portable.ServantObjectExt) {
((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion((Throwable)x_1);
}
throw x_1;
} catch (java.lang.RuntimeException re) {
if (_so instanceof org.omg.CORBA.portable.ServantObjectExt) {
((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion((Throwable)re);
}
throw re;
} catch (java.lang.Error err) {
if (_so instanceof org.omg.CORBA.portable.ServantObjectExt) {
((org.omg.CORBA.portable.ServantObjectExt)_so).exceptionalCompletion((Throwable)err);
}
throw err;
} finally {
_servant_postinvoke(_so);
}
}
}
}
catch (org.omg.CORBA.portable.UnknownException ex) {
if (ex.originalEx instanceof java.lang.RuntimeException) {
throw (java.lang.RuntimeException) ex.originalEx;
} else if (ex.originalEx instanceof Exception) {
throw new java.rmi.ServerException(ex.getMessage(), (java.lang.Exception)ex.originalEx);
} else {
throw new java.rmi.ServerError(ex.getMessage(), (java.lang.Error) ex.originalEx);
}
}
catch (org.omg.CORBA.SystemException ex) {
throw javax.rmi.CORBA.Util.mapSystemException(ex);
}
}
zhousm6 2003-08-21
  • 打赏
  • 举报
回复
supplierHome.findAll();
看看你的实体bean里面findAll函数是怎么实现的,返回的collection到底封装了什么类型的类,如果看不懂的话把findAll()这个函数贴出来。
Morgan_ma 2003-08-21
  • 打赏
  • 举报
回复
楼主,你的findall返回的是collection么?
chenwg168 2003-08-21
  • 打赏
  • 举报
回复
更正一下
Supplier类应该为实体bean的远程接口类
钟伟海 2003-08-21
  • 打赏
  • 举报
回复
chenwg168(aa) :
我用你的方法,还是同样的错误!!!!
Sundery 2003-08-21
  • 打赏
  • 举报
回复
哈哈哈,原来高手在这里!!!!

楼上的,麻烦你去看看我的帖子好吗?
http://expert.csdn.net/Expert/topic/2166/2166162.xml?temp=.4388849

是不是也是这个问题?
chenwg168 2003-08-21
  • 打赏
  • 举报
回复
Supplier supplier = (Supplier)iterator.next();
Supplier类应该为实体bean的home接口
用这种方法试试:
i=c.size();
while(i>=1)
{
Supplier supplier = (Supplier)iterator.next();
System.out.println("the ordersitem's orderid "+ supplier.getShortName());
i=i-1;
}

钟伟海 2003-08-21
  • 打赏
  • 举报
回复
类型转换?能否说清楚点!
我调试了,这个出错信息实在Collection c = supplierHome.findAll();这句抛出的,
但是我用System.out.println(c.size());可以显示表中记录数,记录数显示在出错信息的下面!
不明白!
chenwg168 2003-08-21
  • 打赏
  • 举报
回复
类型转换出错啦

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧