This week's book giveaway is in the Testing forum.
We're giving away four copies of The Way of the Web Tester: A Beginner's Guide to Automating Tests and have Jonathan Rasmusson on-line!
See this thread for details.
Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Class Cast Excep in ejbFind method

seshu Palamanti
Ranch Hand
Posts: 63
  • 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 ( {
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

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);
try {
System.out.println("Name of the Class"+o.getClass().getName().toString());
} catch (FinderException e3) {
throw new SQAServiceException(e3);

Name of the

I am not able to retrieve the primary key object but I get some this else which are specific to WSAD� 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