1 Reply Latest reply on Dec 19, 2002 7:24 PM by Alp

    mySQL & Entity EJB

    Vance Karimi Newbie

      The following environment has been configured:

      -Linux RH 7.2
      -Embedded Tomcat been replaced with separate Tomcat-4.0.4 install.
      -mySQL-3.23.52 max
      -mySQL connector 2.0.14 JDBC driver
      -Eclipse 2.0.1
      -Jakarta-ant-1.4 & xdoclet-1.1.2

      There are no errors with starting and deploying mysql-services.
      A simple Session EJB accessing records works with a standalone client and web client.
      A simple BMP Entity EJB was compiled and deployed without errors. However the following errors were received in the sserver log at executiong:

      2002-09-26 15:06:06,330 DEBUG [org.jboss.resource.adapter.jdbc.local.LocalManagedConnectionFactory] Using properties: {user=mysql, password=}
      2002-09-26 15:06:06,369 ERROR [org.jboss.ejb.GlobalTxEntityMap] Store failed on entity: [.Duke.]
      javax.ejb.EJBException: ejbStore: Storing row for id 123 failed.
      at src.entity.SavingsAccountBean.ejbStore(SavingsAccountBean.java:398)
      at src.entity.SavingsAccountBMP.ejbStore(SavingsAccountBMP.java:126)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.jboss.ejb.plugins.BMPPersistenceManager.storeEntity(BMPPersistenceManager.java:4

      The following error appear at the sys prompt:

      Caught an exception.
      at $Proxy0.create(Unknown Source)
      at client.SavingsAccountClient.main(SavingsAccountClient.java:44)
      Caused by: javax.transaction.RollbackException: Unable to commit, tx=XidImpl [FormatId=257, GlobalId=freedom.telequity.com.au//49, BranchQual=] status=STATUS_ROLLEDBACK
      at org.jboss.tm.TxCapsule.commit(TxCapsule.java:393)
      at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:73)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:201)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:52)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:105)

      If you do a:
      % show table status;
      in the DB engine, it shows that the 'Rows' field has incremented by 1, illustrating the attempted insert, failing to commit and rollback (as indicated in the errors above).

      To make things easier, the relevant client listing:

      SavingsAccountHome home = (SavingsAccountHome) initial.lookup("ejb/jdbc/SavingsAccount");

      BigDecimal zeroAmount = new BigDecimal("0.00");
      SavingsAccountData lData = new SavingsAccountData();
      lData.setBalance( zeroAmount );
      SavingsAccount duke = home.create( lData );

      duke.credit( new BigDecimal("88.50") );
      duke.debit( new BigDecimal("20.25") );
      BigDecimal balance = duke.currentBalance();
      System.out.println("balance = " + balance);

      Problems relating to NamingExceptions have all been fixed.
      The first instruction is to create the EJB.

      The bean header contains the following:

      * ...
      * @ejb:bean name="jdbc/SavingsAccount"
      * display-name="SavingAccountBean to test saving account BMP"
      * type="BMP"
      * jndi-name="ejb/jdbc/SavingsAccount"
      * @ejb:env-entry name="DataSourceName"
      * value="SavingsAccountDS"
      * @ejb:transaction type="Required"
      * @ejb:data-object extends="src.interfaces.AbstractData"
      * setdata="false"
      * @ejb:finder signature="java.util.Collection findAll()"

      Xdoclet generates all required files.

      The closest issue I could find was a mySQL and XADataSource support issue, and this I believe is a lack of support in the mySQL JDBC driver.

      Any help on this issue would be really appreciated. It has really brought us to a halt.

      If you require the full listings or code please let me know.