JBoss 3 Alpha - Problem with finder-Method (CMP2.0)
maku01 Oct 18, 2001 3:13 AMHI GURU'S
I'm relative new to EJB and I want to switch the server part of an application
to EJB. So I want to use CMP2.0 to solve my persistence.
But now I run into troubles:
When I try to call a simple finder-Method with CMP which returns a Collection
and I try to access the fields of the Interface - I receive an exception:
The Exception:
Exception java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Could not load field value: description; nested exception is:
javax.ejb.EJBException: Could not load field value: description
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.ServerException: Could not load field value: description; nested exception is:
javax.ejb.EJBException: Could not load field value: description
java.rmi.ServerException: Could not load field value: description; nested exception is:
javax.ejb.EJBException: Could not load field value: description
javax.ejb.EJBException: Could not load field value: description
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:245)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invoke(Unknown Source)
at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:362)
at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
at org.jboss.ejb.plugins.jrmp.interfaces.ListEntityProxy.invoke(ListEntityProxy.java:147)
at $Proxy2.getDescription(Unknown Source)
at at.mfa.test.ejb.RegionClient.main(RegionClient.java:49)
CAN ANYBODY OUT THERE EXPLAIN WHAT'S GOING WRONG????
OR IS IT REALLY NECESSARY TO CALL findByPrimaryKey TO GET THE BEAN
PLEASE HELP!
TIA
Martin
CLIENT-CODE:
============
Object objref = initial.lookup( "ejb/RegionBean" );
System.out.println("Nach Lookup ejb/RegionBean");
RegionHome home = ( RegionHome ) PortableRemoteObject.narrow( objref, RegionHome.class );
System.out.println("Home Interface erhalten");
Region region = null;
// The Client-Code which throws the exception:
Collection c = home.findAllByDescription();
Iterator i = ((Collection)c).iterator();
while ( i.hasNext() ) {
region = ( Region ) i.next();
// CAN'T call region.getId() or region.getDescription() -> EXCEPTION
System.out.println( "Region: " + region.getId() + " " + region.getDescription() );
}
// The Client-Code which works:
Collection c = home.findAllByDescription();
Iterator i = ((Collection)c).iterator();
while ( i.hasNext() ) {
region = ( Region ) i.next();
// IS THIS REALLY NECESSARY ?????????????
region = home.findByPrimaryKey((RegionPK)region.getPrimaryKey());
System.out.println( "Region: " + region.getId() + " " + region.getDescription() );
}
DEFINITION in HOME-INTERFACE (RegionHome)
=========================================
public Collection findAllByDescription() throws FinderException;
The Definition in ejb-jar.xml:
===============================
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>MFA</display-name>
<enterprise-beans>
<display-name>RegionBean</display-name>
<ejb-name>RegionBean</ejb-name>
<ejb-class>at.mfa.domain.ejb.RegionBean</ejb-class>
at.mfa.domain.ejb.RegionHome
at.mfa.domain.ejb.Region
<persistence-type>Container</persistence-type>
<prim-key-class>at.mfa.domain.ejb.RegionPK</prim-key-class>
False
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Region</abstract-schema-name>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
Find all regions
<query-method>
<method-name>findAllByDescription</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>SELECT OBJECT(r) FROM Region r</ejb-ql>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>RegionBean</ejb-name>
<method-name>*</method-name>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
The definition in jbosscmp-jdbc.xml:
====================================
<jbosscmp-jdbc>
<enterprise-beans>
<ejb-name>RegionBean</ejb-name>
<table-name>region</table-name>
<remove-table>false</remove-table>
<cmp-field>
<field-name>id</field-name>
<column-name>id</column-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<column-name>description</column-name>
</cmp-field>
</enterprise-beans>
</jbosscmp-jdbc>
THE LOG FILE (the essential part):
==================================
[ContainerFactory,INFO] Deployed application: file:/D:/jboss-3.0.0alpha/deploy/Default/mfa.jar
[J2eeDeployer#Default,INFO] J2EE application: file:/D:/jboss-3.0.0alpha/deploy/mfa.jar is deployed.
[TxCapsule,DEBUG] Created new instance for tx=XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=]
[TxManager,DEBUG] began tx: TransactionImpl:XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=]
[Default,INFO] RegionBean()
[DefaultDS,DEBUG] Pool DefaultDS [1/1/10] gave out pooled object: org.jboss.resource.adapter.jdbc.local.JDBCManagedConnection@57ea52
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=] status=STATUS_ACTIVE
[DefaultDS,DEBUG] Connection handle 'org.jboss.resource.adapter.jdbc.local.ConnectionInPool@6a5461' issued by connection manager 'org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCM@629820' from mcf 'org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory@401369'
[CMP,DEBUG] findAllByDescription command executing: SELECT t1_r.id FROM region t1_r
[CMP,DEBUG] Get result: index=1, javaType=int, S value=10
[CMP,DEBUG] Get result: index=1, javaType=int, S value=11
[DefaultDS,DEBUG] Connection handle 'org.jboss.resource.adapter.jdbc.local.ConnectionInPool@6a5461' closed from connection manager 'org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCM@629820' from mcf 'org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory@401369'
[TxCapsule,DEBUG] Committing, tx=XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=], status=STATUS_ACTIVE
[TxCapsule,DEBUG] Before completion done, tx=XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=], status=STATUS_ACTIVE
[TxCapsule,DEBUG] Zero phase commit: No resources.
[DefaultDS,DEBUG] Pool DefaultDS [0/1/10] returned object org.jboss.resource.adapter.jdbc.local.JDBCManagedConnection@57ea52 to the pool.
[TxCapsule,DEBUG] Committed OK, tx=XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=]
[TxManager,DEBUG] suspended tx: TransactionImpl:XidImpl [FormatId=257, GlobalId=gd2303//0, BranchQual=]
[TxCapsule,DEBUG] Reused instance for tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=]
[TxManager,DEBUG] began tx: TransactionImpl:XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=]
[Default,INFO] RegionBean()
[AbstractInstanceCache,DEBUG] Activated bean RegionBean with id = 10
[Default,INFO] readAhead
[DefaultDS,DEBUG] Pool DefaultDS [1/1/10] gave out pooled object: org.jboss.resource.adapter.jdbc.local.JDBCManagedConnection@57ea52
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[DefaultDS,DEBUG] Connection handle 'org.jboss.resource.adapter.jdbc.local.ConnectionInPool@732ed2' issued by connection manager 'org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCM@629820' from mcf 'org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory@401369'
[CMP,DEBUG] ReadAhead command executing: SELECT id, description, id FROM region WHERE id=? OR id=?
[CMP,DEBUG] Set parameter: index=1, jdbcType=INTEGER, value=10
[CMP,DEBUG] Set parameter: index=2, jdbcType=INTEGER, value=11
[CMP,DEBUG] Get result: index=1, javaType=int, S value=10
[CMP,DEBUG] Get result: index=2, javaType=java.lang.String, S value=Turkistan
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[CMP,DEBUG] Get result: index=3, javaType=int, S value=10
[CMP,DEBUG] Get result: index=1, javaType=int, S value=11
[CMP,DEBUG] Get result: index=2, javaType=java.lang.String, S value=Timbuktu
[CMP,DEBUG] Get result: index=3, javaType=int, S value=11
[DefaultDS,DEBUG] Connection handle 'org.jboss.resource.adapter.jdbc.local.ConnectionInPool@732ed2' closed from connection manager 'org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCM@629820' from mcf 'org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory@401369'
[CMP,WARN] Didn't read ahead field 'description'
[Default,INFO] readAhead
[CMP,DEBUG] ReadAhead command executing: SELECT id, id FROM region WHERE id=? OR id=?
[CMP,DEBUG] Set parameter: index=1, jdbcType=INTEGER, value=10
[CMP,DEBUG] Set parameter: index=2, jdbcType=INTEGER, value=11
[CMP,DEBUG] Get result: index=1, javaType=int, S value=10
[CMP,DEBUG] Get result: index=2, javaType=int, S value=10
[CMP,DEBUG] Get result: index=1, javaType=int, S value=11
[CMP,DEBUG] Get result: index=2, javaType=int, S value=11
[DefaultDS,DEBUG] Connection handle 'org.jboss.resource.adapter.jdbc.local.ConnectionInPool@3e76c7' closed from connection manager 'org.jboss.resource.connectionmanager.jboss.MinervaSharedLocalCM@629820' from mcf 'org.jboss.resource.adapter.jdbc.local.JDBCManagedConnectionFactory@401369'
[CMP,WARN] Didn't read ahead field 'id'
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[TxCapsule,DEBUG] registerSynchronization(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[TxCapsule,DEBUG] setRollbackOnly(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_ACTIVE
[TxCapsule,DEBUG] rollback(): Entered, tx=XidImpl [FormatId=257, GlobalId=gd2303//1, BranchQual=] status=STATUS_MARKED_ROLLBACK
[DefaultDS,DEBUG] Pool DefaultDS [0/1/10] returned object org.jboss.resource.adapter.jdbc.local.JDBCManagedConnection@57ea52 to the pool.