#205 Entity Creation Problem

CVS HEAD
open
Bill Burke
5
2002-09-12
2002-04-24
ObjectWiz
No

When I used the CVS tree build of JBoss "as is" I got
the following error when I created Entity Beans:

java.lang.IllegalStateException: do not call
nextTransaction while not synched!
at
org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.nextTransaction(QueuedPessimisticEJBLock.java:400)
at
org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.endTransaction(QueuedPessimisticEJBLock.java:430)
at
org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock.endInvocation(QueuedPessimisticEJBLock.java:454)
at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:246)
at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:176)
at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
at
org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:79)
at
org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:44)
at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:98)
at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:273)
at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:104)
at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:109)
at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:487)
at
org.jboss.ejb.Container.invoke(Container.java:727)
at
org.jboss.ejb.EntityContainer.invoke(EntityContainer.java:1055)
at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:492)
at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:364)
at java.lang.reflect.Method.invoke(Native Method)
at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
at
sun.rmi.transport.Transport$1.run(Transport.java:152)
at
java.security.AccessController.doPrivileged(Native Method)
at
sun.rmi.transport.Transport.serviceCall(Transport.java:148)
at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:465)
at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:706)
at java.lang.Thread.run(Thread.java:484)

So I wrote a patch for it and it seems to work. There
may be many good reasons why this isn't a good idea,
but here it is anyway in unified diff. I left my
System.outs in as it will allow the person viewing the
patch to see the behaviour:

Index:
server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java,v
retrieving revision 1.9
diff -u -r1.9 QueuedPessimisticEJBLock.java
---
server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
10 Apr 2002 05:44:03 -0000 1.9
+++
server/src/main/org/jboss/ejb/plugins/lock/QueuedPessimisticEJBLock.java
24 Apr 2002 08:12:19 -0000
@@ -427,7 +427,43 @@

public void endTransaction(Transaction transaction)
{
- nextTransaction();
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] START >>>" );
+
+ boolean releaseSync = false;
+
+ try
+ {
+ if( !synched )
+ {
+ this.sync();
+ releaseSync = true;
+
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] called
sync()" );
+ }
+ else
+ {
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] already
synched" );
+ }
+
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] \tnext
trans >>>" );
+ nextTransaction();
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] \tnext
trans <<<" );
+ }
+ finally
+ {
+ if( releaseSync )
+ {
+ this.releaseSync();
+
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] called
releaseSync()" );
+ }
+ else
+ {
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] no synch
to release" );
+ }
+
+ System.out.println(
"[QueuedPessimisticEJBLock.endTransaction()] END <<<" );
+ }
}

public void wontSynchronize(Transaction trasaction)

Discussion

  • Dain Sundstrom
    Dain Sundstrom
    2002-09-12

    • assigned_to: nobody --> patriot1burke
     
  • Bill Burke
    Bill Burke
    2002-09-12

    Logged In: YES
    user_id=176497

    Is this a readonly bean you're creating? If so, this isn't allowed.
    You cannot create a read-only entity bean. You must use DB
    scripts to insert, or provide a different "write" entity bean that
    maps to the same interfaces, bean class and table, except that it
    is not marked as read-only.