ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chema <demablo...@gmail.com>
Subject Re: java.sql.SQLException: You cannot commit during a managed transaction
Date Mon, 06 Oct 2008 15:06:04 GMT
I did it and works fine.
Thanks to everyone

Regards


2008/10/4 Clinton Begin <clinton.begin@gmail.com>:
> The differences between JDBC and EXTERNAL are simply that EXTERNAL does
> NOTHING when commit and rollback are called (which works for 99% of managed
> transaction containers).
>
> http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-2/ibatis-2-core/src/com/ibatis/sqlmap/engine/transaction/external/ExternalTransaction.java
>
> Scroll to the bottom and look at the commit and rollback methods.   Now look
> at the JDBC transaction:
>
> http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-2/ibatis-2-core/src/com/ibatis/sqlmap/engine/transaction/jdbc/JdbcTransaction.java
>
> You'll see that it forwards the commit and rollback calls to the connection,
> as if you had called connection.commit()/.rollback() yourself.
>
> The JTA transaction manager is quite a bit different and takes an active
> role in a managed or distributed transaction, and will actually call commit
> and rollback on the configured transaction if called upon to do so.
>
> http://svn.apache.org/repos/asf/ibatis/trunk/java/ibatis-2/ibatis-2-core/src/com/ibatis/sqlmap/engine/transaction/jta/JtaTransaction.java
>
> So I agree with everyone here, that EXTERNAL is what you want for managed
> transactions.  JDBC is what you want for unmanaged (i.e. programmatic)
> transactions.  If your app is inconsistent, then you need two SqlMapConfig
> files (which can share the same SQL Maps), and two instances of
> SqlMapClient.  There's no way for iBATIS to manage that inconsistency for
> you.
>
> Cheers,
> Clinton
>
>
>
>
> On Fri, Oct 3, 2008 at 4:29 PM, Chema <demablogia@gmail.com> wrote:
>>
>> OK, I'll try it.
>>
>> But I've got a doubt.
>> There is code into my application that runs over JBoss but it doesn't
>> have transactions managed by application server.
>> For example, all classes stored in a deployed WAR file.
>>
>> In this case, I wouldn't like to delegate to an EXTERNAL tx manager,
>> would commitTransaction() work fine ?
>>
>> So, the only difference between EXTERNAL and JDBC tx manager type is
>> autocommit configuration ?
>>
>>
>>
>>
>>
>> 2008/10/3 Jeff Butler <jeffgbutler@gmail.com>:
>> > I'll try one more time - it IS possible if you use the EXTERNAL
>> > transaction manager.  Give it a try - surely it wouldn't take more
>> > than 5 minutes of your time to try it???
>> >
>> > Jeff Butler
>> >
>> > On Fri, Oct 3, 2008 at 4:03 PM, Chema <demablogia@gmail.com> wrote:
>> >> I guess it's not possible.
>> >> I 'm going to use JDBC API, I guess
>> >>
>> >> Thank you very much !!
>> >>
>> >>
>> >> 2008/10/3 Kai Grabfelder <nospam@kinokai.de>:
>> >>> Jeff is totaly right, with this configuration iBATIS will never take
>> >>> part in the container managed transactions...
>> >>>
>> >>>
>> >>> --- Original Nachricht ---
>> >>> Absender: Jeff Butler
>> >>> Datum: 03.10.2008 21:14
>> >>>> I think you should use EXTERNAL transaction manager - this is EXACTLY
>> >>>> why it exists.  JBOSS, not iBATIS, is your transaction manager in
>> >>>> this
>> >>>> case.
>> >>>>
>> >>>> Jeff Butler
>> >>>>
>> >>>> On Fri, Oct 3, 2008 at 2:05 PM, Chema <demablogia@gmail.com>
wrote:
>> >>>>> I don't want to keep the secret :-D
>> >>>>>
>> >>>>>
>> >>>>> <settings
>> >>>>>    cacheModelsEnabled="true"
>> >>>>>    enhancementEnabled="true"
>> >>>>>    maxSessions="128"
>> >>>>>    maxTransactions="64"
>> >>>>>    maxRequests="512"/>
>> >>>>>
>> >>>>>  <transactionManager type="JDBC">
>> >>>>>    <dataSource type="JNDI">
>> >>>>>      <property name="DataSource" value="java:/datasource"/>
>> >>>>>    </dataSource>
>> >>>>>  </transactionManager>
>> >>>>>
>> >>>>>
>> >>>>> No more.
>> >>>>> And like you said, I don't use an EXTERNAL tx manager, but JDBC
type
>> >>>>>
>> >>>>> I think that the only solution is perform "delete" sentences
by JDBC
>> >>>>> API , so don't commit current transaction (managed by application
>> >>>>> server).
>> >>>>> What do you think ?
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>>
>> >>>>> 2008/10/3 Jeff Butler <jeffgbutler@gmail.com>:
>> >>>>>> iBATIS will not call commit() if you have
>> >>>>>>
>> >>>>>> <transactionManager type="EXTERNAL">
>> >>>>>>   ...
>> >>>>>> </transactionManager>
>> >>>>>>
>> >>>>>> I'm guessing this is NOT what you have configured - but
it would be
>> >>>>>> nice to see your configuration.
>> >>>>>>
>> >>>>>> Jeff Butler
>> >>>>>>
>> >>>>>> On Fri, Oct 3, 2008 at 1:44 PM, Chema <demablogia@gmail.com>
wrote:
>> >>>>>>> I can't upgrade because my application runs over JVM
1.4 and
>> >>>>>>> iBatis
>> >>>>>>> 2.3.0 is the last release compatible with JVM 1.4
>> >>>>>>>
>> >>>>>>> About your question, from documentation:
>> >>>>>>>
>> >>>>>>> "The <transactionManager> element also allows
an optional
>> >>>>>>> attribute
>> >>>>>>> commitRequired that can be true or
>> >>>>>>> false. Normally iBATIS will not commit transactions
unless an
>> >>>>>>> insert,
>> >>>>>>> update, or delete operation has been performed
>> >>>>>>> [...]
>> >>>>>>> The startTransaction(), commitTransaction() and endTransaction()
>> >>>>>>> methods, they will all be called
>> >>>>>>> automatically for you whenever you execute a statement
outside of
>> >>>>>>> a
>> >>>>>>> transactional block as demonstrated in
>> >>>>>>> the above."
>> >>>>>>>
>> >>>>>>> I think it's not by cause of my configuration
>> >>>>>>>
>> >>>>>>> Thanks !
>> >>>>>>>
>> >>>>>>> Regards
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>>
>> >>>>>>> 2008/10/3 Kai Grabfelder <nospam@kinokai.de>:
>> >>>>>>>> sqlMap.delete() performs a commit? That should not
be the case if
>> >>>>>>>> the tx manager is configured correctly.
>> >>>>>>>> Whats your configuration? Could you please also
try updating
>> >>>>>>>> ibatis to 2.3.4, 2.3.0 is really old...
>> >>>>>>>>
>> >>>>>>>> Regards
>> >>>>>>>>
>> >>>>>>>> Kai
>> >>>>>>>>
>> >>>>>>>> --- Original Nachricht ---
>> >>>>>>>> Absender: Chema
>> >>>>>>>> Datum: 03.10.2008 15:01
>> >>>>>>>>> That doesn't work because sqlMap.delete() performs
commit
>> >>>>>>>>> automatically.
>> >>>>>>>>> I'm using the transaction manager of JBoss ,
with JNDI/JDBC.
>> >>>>>>>>> Can I disabled this ? By code is not possible
because Jboss TX
>> >>>>>>>>> manager
>> >>>>>>>>> throws a SQLExeception.
>> >>>>>>>>> Another w/a ?
>> >>>>>>>>>
>> >>>>>>>>> Thanls !
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>> 2008/10/3 Kai Grabfelder <nospam@kinokai.de>:
>> >>>>>>>>>> if you are using CTM (container managed
transactions), like in
>> >>>>>>>>>> your case, you can't start, commit or end
>> >>>>>>>>>> transactions manually. The container is
doing this for you.
>> >>>>>>>>>>
>> >>>>>>>>>> The following should work
>> >>>>>>>>>>> sqlMap.delete("deleteRecords", param);
>> >>>>>>>>>>
>> >>>>>>>>>> If it does not I think your sqlmap configuration
is not
>> >>>>>>>>>> correct. Could you post it here?
>> >>>>>>>>>>
>> >>>>>>>>>> Regards
>> >>>>>>>>>>
>> >>>>>>>>>> Kai
>> >>>>>>>>>>
>> >>>>>>>>>> --- Original Nachricht ---
>> >>>>>>>>>> Absender: Chema
>> >>>>>>>>>> Datum: 03.10.2008 12:53
>> >>>>>>>>>>> Hello:
>> >>>>>>>>>>>
>> >>>>>>>>>>> I'm using JBoss 3.2 and EJB 2.0 with
iBatis 2.3.0
>> >>>>>>>>>>> I've got configured a external transaction
manager in SQLMap
>> >>>>>>>>>>> configuration file.
>> >>>>>>>>>>>
>> >>>>>>>>>>> When an EJB component ( session bean
) tries to delete record
>> >>>>>>>>>>> using by
>> >>>>>>>>>>> iBatis sqlMap client, JBoss retrieve
this
>> >>>>>>>>>>> error:
>> >>>>>>>>>>>
>> >>>>>>>>>>> 11:02:09,406 ERROR [Connection] Error
calling
>> >>>>>>>>>>> Connection.commit:
>> >>>>>>>>>>> java.sql.SQLException: You cannot commit
during a managed
>> >>>>>>>>>>> transaction!
>> >>>>>>>>>>>         at
>> >>>>>>>>>>> org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:525)
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>> This error happens when I perform this
>> >>>>>>>>>>>
>> >>>>>>>>>>> sqlMap.startTransaction();
>> >>>>>>>>>>> sqlMap.delete("deleteRecords", param);
>> >>>>>>>>>>> sqlMap.commitTransaction();
>> >>>>>>>>>>> sqlMap.endTransaction();
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>> And with a single call (automatic transaction):
>> >>>>>>>>>>>
>> >>>>>>>>>>> sqlMap.delete("deleteRecords", param);
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>> I would like to delegate all transaction
issues to external
>> >>>>>>>>>>> transaction manager ( in this case,
JBoss)
>> >>>>>>>>>>> How I can solved this ? Any w/a ?
>> >>>>>>>>>>>
>> >>>>>>>>>>>
>> >>>>>>>>>>> Thanks !!
>> >>>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>
>> >>>
>> >>
>> >
>
>

Mime
View raw message