1 Reply Latest reply on Oct 10, 2003 3:19 AM by persabi

    Internal error setting instance field/CMP

    persabi

      Hi,

      I have a simple CMP Entity bean with an Integer PK (with its own class). This PK is auto incremented.

      I am using:

      jboss-3.2.1_tomcat-4.1.24
      Mysql 4.0.14-standard with InnoDB
      Eclipse and JbossIDE 1.2.1

      As soon as I create an instance of this bean, I get the following error:


      09:35:30,062 ERROR [LogInterceptor] TransactionRolledbackException, causedBy:
      java.lang.IllegalArgumentException at sun.reflect.UnsafeIntegerFieldAccessorImpl.set(UnsafeIntegerFieldAccessorImpl.java:80)
      .....
      org.jboss.tm.JBossTransactionRolledbackException: Internal error setting instance field id; CausedByException is: null; CausedByException is: Internal error setting instance field id; CausedByException is: null;
      ....


      As a result, no records have been inserted into the table. I should point out that the tables have been created successfully.

      I have discovered this is NOT a problem with the old mysql JDBC driver version 3.0.6. Both version 3.0.8 and 3.0.9 give the above error message.

      For those who may be interested, here is the javadoc tags for the CMP entity bean.


      /**
      * @ejb.bean
      * type = "CMP"
      * name = "Account"
      * description = "Account CMP Entity Bean"
      * local-jndi-name = "account/ejb/AccountLocal"
      * view-type = "local"
      * schema = "account"
      * transaction-type = "Container"
      *
      * @ejb.persistence
      * table-name = "account"
      *
      * @ejb.pk
      *
      * @jboss.persistence
      * table-name = "account"
      * create-table = "true"
      * remove-table = "true"
      * datasource = "java:/jdbc/testDS"
      * datasource-mapping = "mySQL"
      *
      * @jboss.unknown-pk
      * class = "java.lang.Integer"
      * column-name = "id"
      * jdbc-type = "INTEGER"
      * sql-type = "int"
      * auto-increment = "true"
      *
      * @jboss.entity-command
      * name = "mysql-get-generated-keys"
      .......
      // CMP ATTRIBUTES

      /**
      * @ejb.interface-method
      * view-type = "local"
      * @ejb.transaction
      * type = "NotSupported"
      * @ejb.persistence
      * column-name = "id"
      * jdbc-type = "INTEGER"
      * sql-type = "int"
      * @ejb.pk-field
      * @jboss.persistence
      * auto-increment = "true"
      * not-null = "true"
      * @jboss.column-name
      * name="id"
      * @jboss.jdbc-type
      * type = "INTEGER"
      * @jboss.sql-type
      * type = "int"
      */
      public abstract int getId();
      public abstract void setId(int id);
      ......


      JbossIDE/Xdoclet do all the generation of DDs and packages (jar/war/ear) and they seem fine. Part of jbosscmp-jdbc.xml shows:



      <ejb-name>Account</ejb-name>
      <create-table>true</create-table>
      <remove-table>true</remove-table>
      <table-name>account</table-name>

      <cmp-field>
      <field-name>id</field-name>
      <column-name>id</column-name>
      <not-null/>

      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int</sql-type>

      <auto-increment/>
      </cmp-field>
      .......
      <unknown-pk>
      <unknown-pk-class>java.lang.Integer</unknown-pk-class>
      <column-name>id</column-name>
      <jdbc-type>INTEGER</jdbc-type>
      <sql-type>int</sql-type>
      <auto-increment/>
      </unknown-pk>
      <entity-command name="mysql-get-generated-keys">
      </entity-command>



      At first I thought it may be my fault, but reverting to the older mysql JDBC driver works perfectly. Does anyone see similar behaviour with newer version of the JDBC driver?

      Cheers,
      Vance