• Post Reply Bookmark Topic Watch Topic
  • New Topic

Class Cast Excep in ejbFind method  RSS feed

seshu Palamanti
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had written a BMP Bean which has a method ejbFindbyID() the method returns a collection of primary keys of beans which match the criterion. The method code goes like this

public Collection ejbFindById(BigDecimal id)throws FinderException {
DBHelper dbhelper = new DBHelper();
Vector keys = new Vector();
Connection conn=null;
conn = dbhelper.getConnection();
ResultSet rs = null;
PreparedStatement stmt = null;
try {
stmt = conn.prepareStatement("select comp_id from exp_table where compliance_id=?");
rs = stmt.executeQuery();
while (rs.next()) {
BigDecimal key=rs.getBigDecimal("comp_id");
keys.addElement(new reviewBmpKey(key));
Iterator itr=keys.iterator();


} catch (Exception e) {

throw new FinderException(e.toString());
} finally {
* Release DB Connection for other beans

dbhelper.close(conn, stmt, rs);


return keys;


I print the contents of the vector in this method, its says the correct content being that of the key class
SystemOut O KEYSclass com.bcs.works.reviewBmpKey

But when get back the collection I try the same way of knowing which object the collection contains I get this�.

reviewBmpLocalHome localhome = null;
reviewBmpLocal local = null;
//Sqa_audit_reviewBmpKey key=(Sqa_audit_reviewBmpKey)itr.next();
try {
Object o=itr.next();
System.out.println("Name of the Class"+o.getClass().getName().toString());
} catch (FinderException e3) {
throw new SQAServiceException(e3);

Name of the Classcom.bcs.works.ejb.EJSLocalBMPreviewBmp_86f3ee75

I am not able to retrieve the primary key object but I get some this else which are specific to WSAD�..so I can cast back the returned object to get back the key I get a class cast exception

xceptionUtil E CNTR0020E: Non-application exception occurred while processing method "searchById" on bean "BeanId(SQA#SQAEJB.jar#ReviewFacade, null)". Exception data: java.lang.ClassCastException: com.sbc.eworks.ejb.EJSLocalBMPreviewBmp_86f3ee75

where I am I going wrong�..please let me know...thanks in advance.........
[ December 07, 2004: Message edited by: seshu palmanti ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!