Werner thanks for your help.
My environment JBoss 3.2.3 + Oracle 10g + Oracle XA + Castor 0.9.5.3
I would like the database.xml file to use the JNDI datasource instead of
stand-alone JDBC connection. When I invoke
qry.execute(Database.ReadOnly), I receive an exception. I am at a loss
as how to tell Castor to ignore setAutoCommit() on the connection.
The below code works fine if i change database.xml to use stand-alone
jdbc.
database.xml =>
<database name="at4" engine="oracle">
<jndi name="java:/AT4ServerDS" />
<mapping href="conf/castor_mapping.xml" />
</database>
Code snippet =>
try {
// construct JDO adapter
JDO jdo = new JDO("at4");
// load database file
jdo.setConfiguration(getClass().getClassLoader().getResource(dbFileName).toString());
// aquire database handle
Database db = jdo.getDatabase();
// initialize castor transaction
db.begin();
// initialize query
OQLQuery qry = db.getOQLQuery("SELECT p FROM
com.attempt4.framework.oracle.DatasetLayoutBean p where p.dataSetName =
$1");
// bind parameters
qry.bind(datasetName);
// execute query (read-only)
QueryResults results = qry.execute(Database.ReadOnly);
Stack Trace =>
ERROR 11:32:39,877 [STDERR] java.sql.SQLException: You cannot set
autocommit during a managed transaction!
ERROR 11:32:39,878 [STDERR] at
org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.setJdbcAutoCommit(BaseWrapperManagedConnection.java:440)
ERROR 11:32:39,878 [STDERR] at
org.jboss.resource.adapter.jdbc.WrappedConnection.setAutoCommit(WrappedConnection.java:446)
ERROR 11:32:39,879 [STDERR] at
org.exolab.castor.jdo.engine.TransactionContextImpl.getConnection(TransactionContextImpl.java:211)
ERROR 11:32:39,879 [STDERR] at
org.exolab.castor.persist.TransactionContext.query(TransactionContext.java:718)
ERROR 11:32:39,879 [STDERR] at
org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:508)
ERROR 11:32:39,879 [STDERR] at
org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:459)
ERROR 11:32:39,880 [STDERR] at
org.exolab.castor.jdo.engine.OQLQueryImpl.execute(OQLQueryImpl.java:451)
ERROR 11:32:39,880 [STDERR] at
com.attempt4.framework.ejb.DeDdlEJBBean.describe(DeDdlEJBBean.java:135)
ERROR 11:32:39,880 [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
ERROR 11:32:39,880 [STDERR] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
ERROR 11:32:39,880 [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
ERROR 11:32:39,880 [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
ERROR 11:32:39,881 [STDERR] at
org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
ERROR 11:32:39,881 [STDERR] at
org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
ERROR 11:32:39,881 [STDERR] at
org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
ERROR 11:32:39,881 [STDERR] at
org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
ERROR 11:32:39,884 [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:267)
ERROR 11:32:39,884 [STDERR] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:128)
ERROR 11:32:39,884 [STDERR] at
org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
ERROR 11:32:39,884 [STDERR] at
org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
ERROR 11:32:39,885 [STDERR] at
org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
ERROR 11:32:39,885 [STDERR] at
org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
ERROR 11:32:39,885 [STDERR] at
org.jboss.ejb.Container.invoke(Container.java:700)
ERROR 11:32:39,886 [STDERR] at
sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
ERROR 11:32:39,887 [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
ERROR 11:32:39,887 [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
ERROR 11:32:39,887 [STDERR] at
org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
ERROR 11:32:39,887 [STDERR] at
org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
ERROR 11:32:39,887 [STDERR] at
org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
ERROR 11:32:39,887 [STDERR] at
sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
ERROR 11:32:39,888 [STDERR] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
ERROR 11:32:39,888 [STDERR] at
java.lang.reflect.Method.invoke(Method.java:324)
ERROR 11:32:39,888 [STDERR] at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
ERROR 11:32:39,888 [STDERR] at
sun.rmi.transport.Transport$1.run(Transport.java:148)
ERROR 11:32:39,888 [STDERR] at
java.security.AccessController.doPrivileged(Native Method)
ERROR 11:32:39,888 [STDERR] at
sun.rmi.transport.Transport.serviceCall(Transport.java:144)
ERROR 11:32:39,889 [STDERR] at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
ERROR 11:32:39,889 [STDERR] at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
ERROR 11:32:39,889 [STDERR] at java.lang.Thread.run(Thread.java:536)
On Thu, 2004-06-17 at 04:54, Werner Guttmann wrote:
> Donnie,
>
> I've seen your previous message to this list. Let me assure you that Castor will not
> call Connection.setAutoCommit(boolean) when configured to run
> within a XA environment. Having said that, it looks to me like you have not
> configured Castor correctly, as it will call Connection.setAutoCommit(false)
> when running in stand-alone mode.
>
> Can you please (once again) post your JDO config file (aka database.xml) and explain
> how you are running things, i.e. how the JNDI DataSource is
> setup, etc.
>
> Regards
> Werner
On Tue, 2004-06-15 at 10:53, Donnie Armstrong wrote:
> Hello! fp :)
>
> Oracle 10g + Castor 9.5.3 + jboss 3.2.3
>
> A simple O/R mapping works in fine if jdbc parameters are defined in
> database.xml file. I reference that as stand-alone mode.
>
> <!--stand-alone database.xml -->
> <database name="beer_db" engine="oracle" >
> <driver url="jdbc:oracle:thin:@beer:1521:orcl"
> class-name="oracle.jdbc.OracleDriver">
> <param name="user" value="user" />
> <param name="password" value="password" />
> </driver>
> <mapping href="mapping.xml" />
> </database>
>
> When deployed to jboss, the qry.execute() fails with error message:
> You cannot set autocommit during a managed transaction!
>
> Is there a way to disable castor from making the autoCommit() call?
>
> Thanks,
> Donnie
>
> <!-- j2ee datasource -->
> <database name="at4" engine="oracle">
> <jndi name="java:/AT4ServerDS" />
> <mapping href="castor_mapping.xml" />
> </database>
>
> code snippet:
> try {
> // initialize castor transaction
> db.begin();
>
> // initialize query
> qry = db.getOQLQuery("SELECT p FROM myObj.DataSetLayout p
> where p.dataSetName = $1");
>
> // bind parameters
> qry.bind(datasetName);
>
> // execute query
> results = qry.execute();
>
> // only one is needed
> DataSetLayout layout = null;
>
> // process results
> while (results.hasMore()) {
> // grab new layout
> layout = (DataSetLayout) results.next();
>
> // add object to array
> retArr.add(layout);
> }
>
> } catch (Exception ex) {
> String message = ExMsgFormatter.format("Castor lookup
> failed", ex);
>
> _logger.error(message);
> throw new Exception(message);
>
> } finally {
>
> try {
> db.commit();
> } catch (Exception ignored) {
> // ignored
> }
>
> }
>
>
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-user
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user