3 Replies Latest reply on Oct 18, 2002 4:49 AM by aloubyansky

    javax.transaction.TransactionRolledbackException: id may not

    thedandy

      Hi everyone,

      my application give me this error:

      javax.transaction.TransactionRolledbackException: id may not be null; nested exception is: java.lang.Error: id may not be null; nested exception is:javax.transaction.TransactionRolledbackException: id may not be null; nested exception is:java.lang.Error: id may not be null
      javax.transaction.TransactionRolledbackException: id may not be null; nested exception is:
      java.lang.Error: id may not be null
      java.lang.Error: id may not be null
      at org.jboss.ejb.CacheKey.(CacheKey.java:67)
      at org.jboss.ejb.plugins.EntityInstanceCache.createCacheKey(EntityInstanceCache.java:48)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:237)
      at org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:616)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:843)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:231)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:154)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:108)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:103)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
      at org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:420)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContainerInvoker.java:441)
      at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invokeHome(HomeProxy.java:237)
      at org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:182)
      at $Proxy251.create(Unknown Source)
      at com.ejb.session.gestore.gestoreBean.eseguiPuntata(gestoreBean.java:327)
      at java.lang.reflect.Method.invoke(Native Method)
      at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:543)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:87)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:133)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:307)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:99)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:128)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:195)
      at org.jboss.ejb.StatelessSessionContainer.invoke(StatelessSessionContainer.java:286)
      at org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invoke(JRMPContainerInvoker.java:489)
      at org.jboss.ejb.plugins.jrmp.interfaces.GenericProxy.invokeContainer(GenericProxy.java:335)
      at org.jboss.ejb.plugins.jrmp.interfaces.StatelessSessionProxy.invoke(StatelessSessionProxy.java:123)
      at $Proxy243.eseguiPuntata(Unknown Source)
      at com.servlet.main.main.doPost(main.java:404)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
      at org.apache.tomcat.core.Handler.service(Handler.java:287)
      at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
      at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:812)
      at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758)
      at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
      at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
      at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
      at java.lang.Thread.run(Thread.java:484)


      I made a CMP entity bean the pk is autoincrement so i have write the create like this:

      create(Integer ID_Puntata,String _ID_Cliente,Integer _ID_Scommessa,double _Quota,int _Puntata)

      and the

      ejbCreate(Integer ID_Puntata,String _ID_Cliente,Integer _ID_Scommessa,double _Quota,int _Puntata)

      where is the problem?

      thanks for all and excuse me for my bad english,

        • 1. Re: javax.transaction.TransactionRolledbackException: id may
          aloubyansky

          You can't use auto-increment behind the scene trying to deceive JBossCMP. It just won't ley you do it :)
          But instead you could just let JBossCMP know that you would like to use db generated keys.
          For now you have several choices, though not too much.
          This requires setting up a unknown primary key for the bean. Available options:
          - using JDK1.4 that supports getGeneratedKeys from JDBC3;
          - using custom SQL query to fetch the next key value if your db supports sequences;
          - using UUIDKeyGenerator for key values;
          - if you use MySQL you really can make use of auto-increment (and even not only configuring unknown primary key).

          This all works in JBoss-3.2 and upper.

          • 2. Re: javax.transaction.TransactionRolledbackException: id may
            thedandy

            >- if you use MySQL you really can make use of auto->increment (and even not only configuring unknown primary >key).

            realy i use MySql but jboss-2.4...

            so if i use jboss 3.0.3 (where is jboss-3.2?) i resolve my problem or i need to use the other options that you explain in your answer.

            another question i have the same problem if a made a BMP instead a CMP?

            • 3. Re: javax.transaction.TransactionRolledbackException: id may
              aloubyansky

              If you don't use cvs, then on sf.net there is a JBoss-3.2.0beta. But I am not sure whether that version has the feature. I know, the bulds on sourceforge will be updated soon (if not yet).

              Using BMP, yes, you can make use of autoincrement using MySQL specific api to fetch the generated key value.