yet another class cast exception
gzhong Aug 1, 2002 11:49 AMI got this thrown at me when running a test example:
Exception in thread "main" java.lang.ClassCastException: java.util.ArrayList
at $Proxy0.findByPrimaryKey(Unknown Source)
at test.TestACL.getPlasmid(TestACL.java:111)
The code to the simple getPlasmid() method is this:
private static PlasmidData getPlasmid(int id) throws Exception{
Context ctx = new InitialContext();
Object ref = ctx.lookup("project/PlasmidData");
System.out.println("Got object: "+ref);
PlasmidDataHome home = (PlasmidDataHome)PortableRemoteObject.narrow(ref,PlasmidDataHome.class);
System.out.println("Got home: "+home+" ("+home.getClass()+")");
Object obj = home.findByPrimaryKey( new Integer(id));
System.out.println(obj.getClass().getName());
return (PlasmidData)obj;
}
The error above is thrown after the line "project/PlasmidDataHome (class $Proxy0)" was outputted. I turned on trace and I saw no errors thrown or printed out:
2002-08-01 10:46:12,450 TRACE [org.jboss.ejb.plugins.LogInterceptor] Start method=findByPrimaryKey
2002-08-01 10:46:12,450 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Current transaction in MI is null
2002-08-01 10:46:12,451 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TX_REQUIRED for findByPrimaryKey
2002-08-01 10:46:12,451 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Thread came in with tx null
2002-08-01 10:46:12,451 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] Starting new tx TransactionImpl:XidImpl [FormatId=257, GlobalId=mcrcr0.med.nyu.edu//78, BranchQual=]
2002-08-01 10:46:12,452 TRACE [org.jboss.ejb.plugins.EntityInstancePool] Get instance org.jboss.ejb.plugins.EntityInstancePool@81b8f5e#true#class edu.nyu.rcr.bioinformatics.PlasmidDataBean
2002-08-01 10:46:12,459 DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.PlasmidData.findByPrimaryKey] Executing SQL: SELECT project_id FROM PLASMID_PROJECT WHERE project_id=?
2002-08-01 10:46:12,461 TRACE [org.jboss.ejb.plugins.cmp.jdbc.JDBCFindByPrimaryKeyQuery.PlasmidData.findByPrimaryKey] Set parameter: index=1, jdbcType=INTEGER, value=62
2002-08-01 10:46:12,840 TRACE [org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCCMP2xFieldBridge.PlasmidData.projectId] Get result: index=1, javaType=java.lang.Integer, Simple, value=62
2002-08-01 10:46:12,842 TRACE [org.jboss.ejb.plugins.cmp.jdbc.ReadAheadCache.PlasmidData] Add finder results: entity=PlasmidData results=[62] readahead=[JDBCReadAheadMetaData : strategy=on-load, pageSize=255, eagerLoadGroup=*]
2002-08-01 10:46:12,886 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TxInterceptorCMT: In finally
2002-08-01 10:46:12,887 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TxInterceptorCMT:before commit of TransactionImpl:XidImpl [FormatId=257, GlobalId=mcrcr0.med.nyu.edu//78, BranchQual=]
2002-08-01 10:46:12,893 TRACE [org.jboss.ejb.plugins.TxInterceptorCMT] TxInterceptorCMT:after commit of TransactionImpl:XidImpl [FormatId=257, GlobalId=mcrcr0.med.nyu.edu//78, BranchQual=]
2002-08-01 10:46:12,893 TRACE [org.jboss.ejb.plugins.LogInterceptor] End method=findByPrimaryKey
So I don't know where to look. The exception is thrown from inside the findByPrimaryKey method, so I have no control over that. I perused several times my xml config files, and if the problem is there, I don't see it. Isn't there a better way to debug? if there's a ClassCastException, wouldn't it help a bit more if I know what I am casting with and into?
Thanks,
G