[jboss-jira] [JBoss JIRA] Commented: (JBAS-4260) JBossMQ table schema can not be created within a transaction when using MS SQL Server jdbc driver

Luc Texier (JIRA) jira-events at lists.jboss.org
Wed Mar 28 08:59:27 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBAS-4260?page=comments#action_12357614 ] 
            
Luc Texier commented on JBAS-4260:
----------------------------------

here are the proposed changes


Index: jdbc2/PersistenceManager.java
===================================================================
--- jdbc2/PersistenceManager.java       (revision 60904)
+++ jdbc2/PersistenceManager.java       (working copy)
@@ -241,8 +241,6 @@

    synchronized protected void createSchema() throws JMSException
    {
-      TransactionManagerStrategy tms = new TransactionManagerStrategy();
-      tms.startTX();
       Connection c = null;
       PreparedStatement stmt = null;
       boolean threadWasInterrupted = Thread.interrupted();
@@ -351,7 +349,6 @@
       }
       catch (SQLException e)
       {
-         tms.setRollbackOnly();
          throw new SpyJMSException("Could not get a connection for jdbc2 table construction ", e);
       }
       finally
@@ -374,7 +371,6 @@
          {
          }
          c = null;
-         tms.endTX();

          // Restore the interrupted state of the thread
          if (threadWasInterrupted)
@@ -439,9 +435,7 @@
       catch (SQLException e)
       {
          tms.setRollbackOnly();
-         throw new SpyJMSException(
-            "Could not resolve uncommited transactions.  Message recovery may not be accurate",
-            e);
+         throw new SpyJMSException("Could not resolve uncommited transactions.  Message recovery may not be accurate", e);
       }
       finally
       {


Index: jdbc/JDBCStateManager.java
===================================================================
--- jdbc/JDBCStateManager.java  (revision 60904)
+++ jdbc/JDBCStateManager.java  (working copy)
@@ -412,13 +412,15 @@

       if (createTables)
       {
-         JDBCSession session = new JDBCSession();
+         Connection connection = null;
+         connection = dataSource.getConnection();
+
          try
          {
             PreparedStatement statement;
             try
             {
-               statement = session.prepareStatement(CREATE_USER_TABLE);
+               statement = connection.prepareStatement(CREATE_USER_TABLE);
                statement.executeUpdate();
             }
             catch (SQLException ignored)
@@ -427,7 +429,7 @@
             }
             try
             {
-               statement = session.prepareStatement(CREATE_ROLE_TABLE);
+               statement = connection.prepareStatement(CREATE_ROLE_TABLE);
                statement.executeUpdate();
             }
             catch (SQLException ignored)
@@ -436,7 +438,7 @@
             }
             try
             {
-               statement = session.prepareStatement(CREATE_SUBSCRIPTION_TABLE);
+               statement = connection.prepareStatement(CREATE_SUBSCRIPTION_TABLE);
                statement.executeUpdate();
             }
             catch (SQLException ignored)
@@ -451,7 +453,7 @@
                try
                {
                   nextQry = (String) iter.next();
-                  statement = session.prepareStatement(nextQry);
+                  statement = connection.prepareStatement(nextQry);
                   statement.execute();
                }
                catch (SQLException ignored)
@@ -462,7 +464,13 @@
          }
          finally
          {
-            session.close();
+            try {
+               if(connection != null)
+                   connection.close();
+
+            }catch(SQLException sqle){
+                log.trace("Error when closing connection " +sqle);
+            }
          }
       }
    }


Note that these changes should end up in MS SQL specific subclasses, namely MSSQLPersistenceManager.java and MSSQLJDBCStateManager.java



> JBossMQ table schema can not be created within a transaction when using MS SQL Server jdbc driver
> -------------------------------------------------------------------------------------------------
>
>                 Key: JBAS-4260
>                 URL: http://jira.jboss.com/jira/browse/JBAS-4260
>             Project: JBoss Application Server
>          Issue Type: Task
>      Security Level: Public(Everyone can see) 
>          Components: JMS service
>    Affects Versions: JBossAS-4.0.5.GA, JBossAS-4.0.4.GA
>         Environment: MS SQL Server jdbd driver 1.1
> MS SQL Server 2005 database
>            Reporter: Luc Texier
>         Assigned To: Luc Texier
>             Fix For: JBossAS-4.2.0.GA, JBossAS-4.0.5.SP1 
>
>
> After the table schema has been created once during the first boot, on subsequent restarts the following error is thrown
> 11:19:15,468 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:name=JmsXA,service=ConnectionFactoryBinding' to JNDI name 'java:JmsXA'
> 11:19:15,539 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:name=KANA/jdbc/realm1,service=DataSourceBinding' to JNDI name 'java:KANA/jdbc/realm1'
> 11:19:15,870 WARN [TransactionImpl] XAException: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=mht-vani/1, BranchQual=, localId=1] errorCode=XA_RBROLLBACK
> org.jboss.resource.connectionmanager.JBossLocalXAException: could not commit local tx; - nested throwable: (org.jboss.resource.JBossResourceException: SQLException; - nested throwable: (com.microsoft.sqlserver.jdbc.SQLServerException: New request is not allowed to start because it should come with valid transaction descriptor.))
> at org.jboss.resource.connectionmanager.TxConnectionManager$LocalXAResource.commit(TxConnectionManager.java:912)
> at org.jboss.tm.TransactionImpl$Resource.commit(TransactionImpl.java:2253)
> at org.jboss.tm.TransactionImpl.commitResources(TransactionImpl.java:1784)
> at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:340)
> at org.jboss.tm.TxManager.commit(TxManager.java:240)
> at org.jboss.mq.sm.jdbc.JDBCStateManager$JDBCSession.close(JDBCStateManager.java:613)
> at org.jboss.mq.sm.jdbc.JDBCStateManager.initDB(JDBCStateManager.java:465)
> at org.jboss.mq.sm.jdbc.JDBCStateManager.startService(JDBCStateManager.java:378)
> at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
> at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
> at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:324)
> at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
> at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
> at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
> at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
> at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
> at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
> The MS JDBC driver is doing an internal rollback - anti-spec behaviour when JBossMQ fails
> to create a table that already exists

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list