MySQL and CMP Entity (sigh...)
davidsills Jan 8, 2002 7:44 AMI see I'm in good company, but perhaps have put a slightly different spin on a common problem.
I'm working with
Windows NT 4 (sp 6a)
MySQL (mysql-3.23.46a-win.zip)
JDBC driver (mm.mysql-2.0.8)
JBoss (2.4.4.2001-12-29 02:04:40 PST) (bundled with Tomcat 4)
MySQL has proven excellent to work with, and JBoss has been truly impressive, though along with everyone else, I imagine, I sometimes deplore the documentation. (And plan to help, when I know enough to help--I've been a writer in half a dozen fields.) I've tried to buy the documentation, but Flashline can't seem to get my credit card authorization right.
I've read seemingly endlessly from these postings, and they've got me past many an issue, but I'm finally stumped. I am trying to do something wrong (I know that), but before I implement it correctly, want to know why it doesn't work.
I want to return a list of these value objects for my OwnerProduct bean, which is a CMP entity bean:
public class OwnerProductVO implements Serializable
{
private int id;
private String ownerName;
private String productTitle;
private int strategyId;
private int version;
...
}
The correct solution according to the J2EE design patterns book is to do this with straight JDBC from a session bean for performance, but this OwnerProductBean code should work as well:
public List getAllData() throws RemoteException, FinderException
{
System.err.println("in getAllData");
List list = new ArrayList();
System.err.println("getting Home");
Object ref = ctx.getEJBHome();
OwnerProductHome home = (OwnerProductHome) PortableRemoteObject
.narrow(ref, OwnerProductHome.class);
System.err.println("getting Collection");
Collection col = home.findAll();
System.err.println("collection size = " + col.size() + "; getting Iterator");
Iterator iter = col.iterator();
System.err.println("traversing Iterator");
OwnerProduct op = null;
while (iter.hasNext())
{
op = (OwnerProduct) iter.next();
>>>> System.err.println("forcing data retrieval");
Integer dummy = op.getId();
System.err.println("retrieved OwnerProduct with id " + dummy);
list.add(op.getData());
}
return list;
}
The getData method just copies values into the VO and returns it.
Right after the point marked by >>>> the system simply hangs. I have a useful datasource: I have tried using straight JDBC from within the bean, JDBC from a client, JDBC from a dependent object, all with connections from the datasource as configured below and all worked fine (thanks to hints from this list). The finders other than findAll work great from a client.
I include the log file, which is not enlightening for me, but perhaps it will be for someone else, and the relevant configuration file (taken from another post). I should note that I have not set up any database security (username, password) for the moment, trying not to complicate things if possible.
Many thanks in advance for thoughts....
David Sills
///////////////
log file (includes stack trace):
[07:22:46,334,Default] JBoss-2.4.4 Started in 0m:22s.513
[07:22:54,546,DefaultDS] Resource 'org.jboss.pool.jdbc.xa.wrapper.XAResourceImpl@1db992' enlisted for 'org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@88e6c'.
[07:22:54,766,DefaultDS] Resource 'org.jboss.pool.jdbc.xa.wrapper.XAResourceImpl@1db992' enlisted for 'org.jboss.pool.jdbc.xa.wrapper.XAConnectionImpl@88e6c'.
[07:22:54,776,Default] in getAllData
[07:22:54,776,Default] getting Home
[07:22:54,796,Default] getting Collection
[07:22:54,816,Default] collection size = 5; getting Iterator
[07:22:54,816,Default] traversing Iterator
[07:22:54,816,Default] forcing data retrieval
[07:24:56,962,LRUEnterpriseContextCachePolicy] Resized cache for bean OwnerProduct: old capacity = 1000, new capacity = 50
[07:27:44,032,LRUEnterpriseContextCachePolicy] Resized cache for bean CDBean: old capacity = 1000, new capacity = 50
[07:27:54,757,TxCapsule] Transaction XidImpl [FormatId=257, GlobalId=CC832421-A//1, BranchQual=] timed out. status=STATUS_ACTIVE
[07:27:55,288,BeanLock] Saw rolled back tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=CC832421-A//1, BranchQual=] waiting for methodLock.
[07:27:55,298,OwnerProduct] TRANSACTION ROLLBACK EXCEPTION:
javax.transaction.TransactionRolledbackException: Transaction marked for rollback, possibly a timeout; nested exception is:
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.doSchedule(QueuedPessimisticEJBLock.java:191)
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.schedule(QueuedPessimisticEJBLock.java:137)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:121)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:504)
at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
at $Proxy10.getId(Unknown Source)
at com.bn.maintenance.beans.OwnerProductBean.getAllData(OwnerProductBean.java:185)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:942)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:308)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
at java.lang.reflect.Method.invoke(Native Method)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
[07:27:55,318,OwnerProduct] TRANSACTION ROLLBACK EXCEPTION:
javax.transaction.TransactionRolledbackException: Transaction marked for rollback, possibly a timeout; nested exception is:
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout; nested exception is:
javax.transaction.TransactionRolledbackException: Transaction marked for rollback, possibly a timeout; nested exception is:
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
javax.transaction.TransactionRolledbackException: Transaction marked for rollback, possibly a timeout; nested exception is:
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
java.lang.RuntimeException: Transaction marked for rollback, possibly a timeout
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.doSchedule(QueuedPessimisticEJBLock.java:191)
at org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.schedule(QueuedPessimisticEJBLock.java:137)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:121)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:504)
at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
at org.jboss.ejb.plugins.jrmp.interfaces.EntityProxy.invoke(EntityProxy.java:133)
at $Proxy10.getId(Unknown Source)
at com.bn.maintenance.beans.OwnerProductBean.getAllData(OwnerProductBean.java:185)
at java.lang.reflect.Method.invoke(Native Method)
at org.jboss.ejb.EntityContainer$ContainerInterceptor.invoke(EntityContainer.java:942)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:308)
at org.jboss.ejb.plugins.EntityInstanceInterceptor.invoke(EntityInstanceInterceptor.java:197)
at org.jboss.ejb.plugins.EntityLockInterceptor.invoke(EntityLockInterceptor.java:125)
at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:138)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:347)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:100)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:127)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:170)
at org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:428)
at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:410)
at java.lang.reflect.Method.invoke(Native Method)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
///////////////
jboss.jcml:
org.gjt.mm.mysql.Driver
DefaultDS
org.jboss.pool.jdbc.xa.wrapper.XADataSourceImpl
jdbc:mysql://localhost/jboss
false
1200000
10
1
false
false
true
120000
1800000
false
true
1.0