You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by beaupral <be...@hotmail.com> on 2014/11/23 18:39:08 UTC
Derby XA Transactions
Hi all,
I'm new to XA transactions and I'm trying to test them with Tomee + ActiveMQ
and Derby.
However, it seems like Derby won't enlist in a XA Transaction, I keep
getting the following error :
org.apache.derby.client.am.XaException: XAER_DUPID : Error executing a
XAResource.start(), server returned XAER_DUPID.
I did some research but it doesn't seems like Derby is frequently used with
XA Transactions.
Can anyone point me to what might be wrong in my configuration ?
Here is my tomee.xml :
<?xml version="1.0" encoding="UTF-8"?>
<tomee>
<Resource id="JmsResourceAdapter" type="ActiveMQResourceAdapter">
# Do not start the embedded ActiveMQ broker
BrokerXmlConfig =
ServerUrl = tcp://localhost:61616
</Resource>
<Container id="JmsMdbContainer" type="MESSAGE">
ResourceAdapter = JmsResourceAdapter
</Container>
<Resource id="derbyDataSource" type="DataSource">
JdbcDriver = org.apache.derby.jdbc.ClientXADataSource
JdbcUrl = jdbc:derby://localhost:1527/MyDbTest
JtaManaged = true
databaseName = MyDbTest
UserName = admin
Password = pass
</Resource>
</tomee>
And here is my simple MDB:
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue =
"test")
})
public class MaxgwMDB implements MessageListener {
@Resource(name="derbyDataSource")
private DataSource dataSource;
/*
* (non-Javadoc)
* @see javax.jms.MessageListener#onMessage(javax.jms.Message)
*/
public void onMessage(Message message) {
PreparedStatement pstm = null;
Connection conn = null;
try {
conn = dataSource.getConnection();
pstm = conn.prepareStatement("insert into persons values(?)");
} catch (SQLException e) {
...
} finally {
...
}
}
}
Thanks for any help!
Alex
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Derby-XA-Transactions-tp4673002.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Derby XA Transactions
Posted by beaupral <be...@hotmail.com>.
Thanks for the quick reply Romain,
I have tried with the following configuration
<Resource id="derbyDataSource" type="DataSource">
XaDataSource = derbyXaDataSource
DataSourceCreator = dbcp
</Resource>
<Resource id="derbyXaDataSource" type="XADataSource"
class-name="org.apache.derby.jdbc.ClientXADataSource">
JdbcDriver = org.apache.derby.jdbc.ClientXADataSource
JdbcUrl = jdbc:derby://localhost:1527/MyDbTest
databaseName = MyDbTest
UserName = admin
Password = pass
</Resource>
However I'm still getting the same error.
I guess I'll try to compare with HSQL.
Thanks
--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Derby-XA-Transactions-tp4673002p4673004.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Re: Derby XA Transactions
Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi
didn't test with derby but:
https://issues.apache.org/jira/browse/TOMEE-1337 and
https://issues.apache.org/jira/browse/TOMEE-1169 should give you the
basic xa config (you configured a "local" xa datasource, ie just a
datasource working with local jta).
Romain Manni-Bucau
@rmannibucau
http://www.tomitribe.com
http://rmannibucau.wordpress.com
https://github.com/rmannibucau
2014-11-23 18:39 GMT+01:00 beaupral <be...@hotmail.com>:
> Hi all,
>
> I'm new to XA transactions and I'm trying to test them with Tomee + ActiveMQ
> and Derby.
>
> However, it seems like Derby won't enlist in a XA Transaction, I keep
> getting the following error :
>
> org.apache.derby.client.am.XaException: XAER_DUPID : Error executing a
> XAResource.start(), server returned XAER_DUPID.
>
> I did some research but it doesn't seems like Derby is frequently used with
> XA Transactions.
>
> Can anyone point me to what might be wrong in my configuration ?
> Here is my tomee.xml :
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tomee>
>
> <Resource id="JmsResourceAdapter" type="ActiveMQResourceAdapter">
> # Do not start the embedded ActiveMQ broker
> BrokerXmlConfig =
> ServerUrl = tcp://localhost:61616
> </Resource>
>
> <Container id="JmsMdbContainer" type="MESSAGE">
> ResourceAdapter = JmsResourceAdapter
> </Container>
>
> <Resource id="derbyDataSource" type="DataSource">
> JdbcDriver = org.apache.derby.jdbc.ClientXADataSource
> JdbcUrl = jdbc:derby://localhost:1527/MyDbTest
> JtaManaged = true
> databaseName = MyDbTest
> UserName = admin
> Password = pass
> </Resource>
>
> </tomee>
>
>
> And here is my simple MDB:
>
> @MessageDriven(
> activationConfig = {
> @ActivationConfigProperty(propertyName = "destinationType",
> propertyValue = "javax.jms.Queue"),
> @ActivationConfigProperty(propertyName = "destination", propertyValue =
> "test")
> })
> public class MaxgwMDB implements MessageListener {
>
> @Resource(name="derbyDataSource")
> private DataSource dataSource;
>
>
> /*
> * (non-Javadoc)
> * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
> */
> public void onMessage(Message message) {
>
> PreparedStatement pstm = null;
> Connection conn = null;
>
> try {
> conn = dataSource.getConnection();
> pstm = conn.prepareStatement("insert into persons values(?)");
> } catch (SQLException e) {
> ...
> } finally {
> ...
> }
> }
>
> }
>
>
> Thanks for any help!
>
> Alex
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.n4.nabble.com/Derby-XA-Transactions-tp4673002.html
> Sent from the TomEE Users mailing list archive at Nabble.com.