3 Replies Latest reply on Sep 1, 2007 6:31 AM by boniek

    ClassCastException in JDBCMySQLCreateCommand

    imaeses

      Hello all,

      I have just installed MySQL 5.0.27 on my Windows machine (community-nt flavor). It is being accessed by JBoss 4.0.5.GA using the 5.0.5 Connector/J JDBC driver. I have a series of datasources backing up a variety of CMP's. Previously, I was using local (non-XA) datasources and everything worked fine.

      No I want to set up XA datasources. I upgraded MySQL from 4.0.x and set up my XA datasources. Now, inserts on one of the datasources always fail with an IllegalArgumentException caused by a ClassCastException. (Stack trace below).

      This is my XA datasource configuration:

      <?xml version="1.0" encoding="UTF-8"?>


      <xa-datasource>
      <jndi-name>MySqlDS</jndi-name>

      <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
      <xa-datasource-property name="URL">jdbc:mysql://localhost:3306/franco</xa-datasource-property>
      <track-connection-by-tx/>
      <no-tx-separate-pools/>

      <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>


      <user-name>root</user-name>

      <min-pool-size>50</min-pool-size>
      <max-pool-size>125</max-pool-size>
      <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
      <!-- sql to call when connection is created
      <new-connection-sql>some arbitrary sql</new-connection-sql>
      -->
      <!-- sql to call on an existing pooled connection when it is obtained from pool
      <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
      -->

      <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->

      <type-mapping>mySQL</type-mapping>

      </xa-datasource>



      Any ideas?

      Many thanks!
      Adam

      2007-03-08 11:23:42,626 131990 ERROR [org.jboss.ejb.plugins.LogInterceptor] (JMS SessionPool Worker-0:) TransactionRolledbackLocalException in method: public abstract com.rdcompany.franco.ejb.interfaces.FailedMoLocal com.rdcompany.franco.ejb.interfaces.FailedMoLocalHome.create(com.rdcompany.franco.ejb.value.FailedMoValue) throws javax.ejb.CreateException, causedBy:
      java.lang.IllegalArgumentException: object is not an instance of declaring class
      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:585)
      at org.jboss.ejb.plugins.cmp.jdbc.keygen.JDBCMySQLCreateCommand.executeInsert(JDBCMySQLCreateCommand.java:116)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.performInsert(JDBCAbstractCreateCommand.java:321)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCAbstractCreateCommand.execute(JDBCAbstractCreateCommand.java:151)
      at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.createEntity(JDBCStoreManager.java:587)
      at org.jboss.ejb.plugins.CMPPersistenceManager.createEntity(CMPPersistenceManager.java:237)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.createEntity(CachedConnectionInterceptor.java:225)
      at org.jboss.ejb.EntityContainer.createLocalHome(EntityContainer.java:625)
      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:585)
      at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
      at org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.java:1126)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
      at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchronizationInterceptor.java:203)
      at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
      at org.jboss.ejb.plugins.AbstractInterceptor.invokeHome(AbstractInterceptor.java:105)
      at org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInterceptor.java:134)
      at org.jboss.ejb.plugins.EntityLockInterceptor.invokeHome(EntityLockInterceptor.java:76)
      at org.jboss.ejb.plugins.EntityCreationInterceptor.invokeHome(EntityCreationInterceptor.java:43)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:350)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:161)
      at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
      at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
      at org.jboss.ejb.EntityContainer.internalInvokeHome(EntityContainer.java:521)

        • 1. Re: ClassCastException in JDBCMySQLCreateCommand
          imaeses

          I have some more information about this problem.

          The problem only occurs when an xa-datasource backs an entity bean the classes of which are deployed in a .jar but the deployment descriptor of which is deployed in an .ear.

          Note: the reason for this strange situation is that we are using JBoss Messaging with JBoss 4.x and in order to be able to send or receive messages we have to specify the class loader, and the only way to do that is via a jboss-app.xml in an application (.ear) bundle. However (some of) the supporting classes must be available to other applications/jars so we package them separately.

          • 2. Re: ClassCastException in JDBCMySQLCreateCommand
            imaeses

            Clarification: it doesn't seem to matter if the .jar is included in the ear or not. It seems that we get the exception when the classes are loaded in the context of an ear. In that ear we use the jboss-app to specify a particular ClassLoader - the one that loaded in JBoss Messaging.

            • 3. Re: ClassCastException in JDBCMySQLCreateCommand

              Same stuff here.
              JBossAS 4.2.1
              JBM 1.4.0.CR2