You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by Per Newgro <pe...@gmx.ch> on 2006/12/06 08:16:10 UTC
Why is the container managing the autocommit state in BMTs?
Hi *,
afaik BMT means bean managed transactions.
I use SFSB defined in the following way:
<session>
<ejb-name>ExportDatabaseUC</ejb-name>
<home>my.common.ejb.UseCaseHome</home>
<remote>my.common.ejb.UseCaseRemote</remote>
<ejb-class>my.misc.backup.ejb.ExportDatabaseUcEJB</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Bean</transaction-type>
<resource-ref>
<res-ref-name>APPLDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref>
<res-ref-name>APPLDBnoTx</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</session>
If i get a connection from the APPLDBnoTx i try to set the autoCommit flag to
false. But then i get a SQLException from openejbs JdbcConnection "The commit
state is managed by container" (not the exact words). But this confuses me a
little because i use BMT. It would realy be great if someone could explain
this to me (maybe i'm completely wrong).
Cheers
Per
Re: Why is the container managing the autocommit state in BMTs?
Posted by Per Newgro <pe...@gmx.ch>.
Hi David,
i downloaded the new version and added "Unmanaged true" to "openejb.conf".
But i get the exception anyway.
[java] Caused by: java.sql.SQLException: Method not supported. Commit is
managed automatically by container provider
[java] at
org.apache.openejb.resource.jdbc.JdbcConnection.setAutoCommit(JdbcConnection.java:106)
in my code i do the following
/**
* Get connection
* @param ctx context to get connection for
* @return Connection connection to database
* @throws SQLException if error occured (see message)
*/
public static Connection getConnection(ConnectionContext ctx) throws
SQLException {
Connection conn = ctx.run();
if (!ctx.isTransactional()) {
conn.setAutoCommit(false);
}
return conn;
}
The isTransactional of the connection context is false for MYDBnoTx. Thats the
datasource i want to access. I've tested this all, so that i can be sure.
[java] Grund: my.server.data.ServerContext@720f6c; datasource:
org.apache.openejb.resource.jdbc.JdbcConnectionFactory@5284e9; transactional:
false
So my conclusion is: Nope the new version is not soliving the problem :-)
As a hint: The physical database for both datasources (defined in
openejb.conf) is the same! Only the access differs.
Cheers
Per
Re: Why is the container managing the autocommit state in BMTs?
Posted by David Blevins <da...@visi.com>.
Hey Per,
Grab this new binary (updated today):
http://people.apache.org/~dblevins/openejb-3.0-incubating-SNAPSHOT-
bin.zip
and in your Connector declaration that makes calls outside
transactions add 'Unmanaged true'
<Connector id="APPLDBnoTx">
JdbcDriver org.hsqldb.jdbcDriver
JdbcUrl jdbc:hsqldb:file:conf/default.hsql_database.conf
UserName sa
Password
Unmanaged true
</Connector>
Give that a try and let me know. It's really not tested so be sure
to poke at it.
-David
On Jan 3, 2007, at 7:49 AM, Per Newgro wrote:
> Hey David,
>
> happy new year - to the others in newsgroup to :-)
>
> Did i missed something in this thread? I installed the snapshot.
> But i get
> this anyway:
>
> [java] Caused by: java.sql.SQLException: Method not supported.
> Commit is
> managed automatically by container provider
> [java] at
> org.apache.openejb.resource.jdbc.JdbcConnection.setAutoCommit
> (JdbcConnection.java:106)
> [java] at
> my.server.data.ConnectionFactory.getConnection
> (ConnectionFactory.java:40)
> [java] at
> my.server.data.PersistenceLayer.getConnection(PersistenceLayer.java:
> 88)
>
> I have two datasources. One for normal transaction managed access.
> The other
> will be accessed outside all transactions. It will be used for my
> sequence
> table which shouldn't be rolled back if something happend.
>
> All beans should be managed by bean and not by container. Do i have to
> configure it? I don't use ejb-3.0 until now.
>
> Cheers
> Per
>
Re: Why is the container managing the autocommit state in BMTs?
Posted by Per Newgro <pe...@gmx.ch>.
Hey David,
happy new year - to the others in newsgroup to :-)
Did i missed something in this thread? I installed the snapshot. But i get
this anyway:
[java] Caused by: java.sql.SQLException: Method not supported. Commit is
managed automatically by container provider
[java] at
org.apache.openejb.resource.jdbc.JdbcConnection.setAutoCommit(JdbcConnection.java:106)
[java] at
my.server.data.ConnectionFactory.getConnection(ConnectionFactory.java:40)
[java] at
my.server.data.PersistenceLayer.getConnection(PersistenceLayer.java:88)
I have two datasources. One for normal transaction managed access. The other
will be accessed outside all transactions. It will be used for my sequence
table which shouldn't be rolled back if something happend.
All beans should be managed by bean and not by container. Do i have to
configure it? I don't use ejb-3.0 until now.
Cheers
Per
Re: Why is the container managing the autocommit state in BMTs?
Posted by David Blevins <da...@visi.com>.
Will do first thing tomorrow -- wipped out from cooking up geronimo/
openejb2x releases.
-David
On Dec 13, 2006, at 3:47 AM, Per Newgro wrote:
> Hi,
>
> If i want to try out OpenEjb3 do i have to build it myself? Or is
> there a
> build snapshot i can use? The problem is i use cvs and ant and not
> svn and
> maven. WOuld be nice if someone could provide a zip or tar or whatever
> containing the bins.
>
> Cheers
> Per
>
Re: Why is the container managing the autocommit state in BMTs?
Posted by David Blevins <da...@visi.com>.
On Dec 13, 2006, at 3:47 AM, Per Newgro wrote:
> Hi,
>
> If i want to try out OpenEjb3 do i have to build it myself? Or is
> there a
> build snapshot i can use? The problem is i use cvs and ant and not
> svn and
> maven. WOuld be nice if someone could provide a zip or tar or whatever
> containing the bins.
Here you go! Sorry for the delay:
http://people.apache.org/~dblevins/openejb-3.0-incubating-SNAPSHOT-
bin.zip
Should be able to startup with:
./bin/openejb start
Or ..
java -jar lib/openejb-core-3.0-incubating-SNAPSHOT.jar start
-David
Re: Why is the container managing the autocommit state in BMTs?
Posted by Per Newgro <pe...@gmx.ch>.
Hi,
If i want to try out OpenEjb3 do i have to build it myself? Or is there a
build snapshot i can use? The problem is i use cvs and ant and not svn and
maven. WOuld be nice if someone could provide a zip or tar or whatever
containing the bins.
Cheers
Per
Re: Why is the container managing the autocommit state in BMTs?
Posted by Per Newgro <pe...@gmx.ch>.
Hi David,
fine. I feel good, that i didn't miss the spec again :-).
>Couple questions, would you consider trying out OpenEJB 3 (it's java5 only)
No problem i'm using cvs and ant build file to create my standalone version.
So it shouldn't make much effort to include another OpenEJB version And the
application is using java5 to.
> and how soon do you need this?
Its a standalone version so it's not required to work. The only thing is that
it is throwing exceptions where "the other AS" hasn't thrown. I.e. take your
time to implement. Don't get stressed :-)
Cheers
Per
Re: Why is the container managing the autocommit state in BMTs?
Posted by David Blevins <da...@visi.com>.
On Dec 5, 2006, at 11:16 PM, Per Newgro wrote:
> Hi *,
>
> afaik BMT means bean managed transactions.
>
> I use SFSB defined in the following way:
>
> <session>
> <ejb-name>ExportDatabaseUC</ejb-name>
> <home>my.common.ejb.UseCaseHome</home>
> <remote>my.common.ejb.UseCaseRemote</remote>
> <ejb-class>my.misc.backup.ejb.ExportDatabaseUcEJB</ejb-class>
> <session-type>Stateful</session-type>
> <transaction-type>Bean</transaction-type>
> <resource-ref>
> <res-ref-name>APPLDB</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> <resource-ref>
> <res-ref-name>APPLDBnoTx</res-ref-name>
> <res-type>javax.sql.DataSource</res-type>
> <res-auth>Container</res-auth>
> </resource-ref>
> </session>
>
> If i get a connection from the APPLDBnoTx i try to set the
> autoCommit flag to
> false. But then i get a SQLException from openejbs JdbcConnection
> "The commit
> state is managed by container" (not the exact words). But this
> confuses me a
> little because i use BMT. It would realy be great if someone could
> explain
> this to me (maybe i'm completely wrong).
Hi Per,
What we lack is the ability for you to turn this off/on on a per
Connector basis. It wouldn't matter whether the bean is BMT vs CMT
as the real designation is on the DataSource which could be passed
around to any other bean BMT or CMT. I.e. the connection is setup
either as local transactions only or JTA transactions -- a BMT could
use either but the pooling rules are different for each.
We can definitely add this. Couple questions, would you consider
trying out OpenEJB 3 (it's java5 only) and how soon do you need this?
-David