-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: EJB3&XATransactions
PostPosted: Mon Jun 26, 2006 4:50 am 
Newbie

Joined: Mon Jun 26, 2006 4:45 am
Posts: 4
Hi
Can you tell me how to bind or map XADatasource in EJB3 .
I am using JBoss server, I have no problem with DataSource.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 6:11 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
You set this in your -ds.xml file.

Code:
    <xa-datasource>
      <jndi-name>PortalDS</jndi-name>

        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
        <xa-datasource-property name="ServerName">zorba</xa-datasource-property>
        <xa-datasource-property name="Port">3326</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">test</xa-datasource-property>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

        <user-name>uu</user-name>
        <password>pp</password>

        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>

        <idle-timeout-minutes>5</idle-timeout-minutes>

        <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
        <check-valid-connection-sql>select 1</check-valid-connection-sql>

      <metadata>
         <type-mapping>mySQL</type-mapping>
      </metadata>
    </xa-datasource>



It is basically the same.
In EJB3 you are referencing to the JNDI bound DataSource.
If that DS is XA, JPA cares just about getting the connection and using JTA - it knows nothing about XA - that's JTA's job.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 8:39 am 
Newbie

Joined: Mon Jun 26, 2006 4:45 am
Posts: 4
hi
you think alesj that , JTA knows nothing about XA? and if I want use XADataSource in my Serverside?
i am using Oracle10g
i am ds.xml configured in jboss 4.x and averything warks fine with DataSource when i am doing lookup, i'd like tu use XADataSource in EJB3
can you help me?

ds.xml

<datasources>
<xa-datasource>
<jndi-name>XAOracleDS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@192.9.200.177:1521:devnbtwo</xa-datasource-property>
<xa-datasource-property name="User">b1</xa-datasource-property>
<xa-datasource-property name="Password">b2</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
<attribute name="Drivers">oracle.jdbc.driver.OracleDriver</attribute>
</mbean>


<mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=XAODS">
<attribute name="PoolName">XAODS</attribute>
<attribute name="DataSourceClass">XADataSource</attribute>
<attribute name="datasourceName">devnbtwo</attribute>
<attribute name="URL">jdbc:oracle:thin:@192.9.200.177:1521:devnbtwo</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password" />
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>

</xa-datasource>

<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager </depends>
</mbean>
</datasources>


Top
 Profile  
 
 Post subject: EJB3&XATransactions
PostPosted: Tue Jun 27, 2006 8:43 am 
Newbie

Joined: Mon Jun 26, 2006 4:45 am
Posts: 4
alesj wrote:
You set this in your -ds.xml file.

Code:
    <xa-datasource>
      <jndi-name>PortalDS</jndi-name>

        <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
        <xa-datasource-property name="ServerName">zorba</xa-datasource-property>
        <xa-datasource-property name="Port">3326</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">test</xa-datasource-property>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>

        <user-name>uu</user-name>
        <password>pp</password>

        <min-pool-size>5</min-pool-size>
        <max-pool-size>20</max-pool-size>

        <idle-timeout-minutes>5</idle-timeout-minutes>

        <exception-sorter-class-name>com.mysql.jdbc.integration.jboss.ExtendedMysqlExceptionSorter</exception-sorter-class-name>
        <check-valid-connection-sql>select 1</check-valid-connection-sql>

      <metadata>
         <type-mapping>mySQL</type-mapping>
      </metadata>
    </xa-datasource>



It is basically the same.
In EJB3 you are referencing to the JNDI bound DataSource.
If that DS is XA, JPA cares just about getting the connection and using JTA - it knows nothing about XA - that's JTA's job.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 8:53 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
keti wrote:
you think alesj that , JTA knows nothing about XA?


No, EJB3 persistence doesn't know about XA.
JTA definitely knows :-).

There is an example.
Do the same thing as in <JBOSS_HOME>\docs\examples\jca\oracle-xa-ds.xml

btw: What is the problem??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 9:35 am 
Newbie

Joined: Mon Jun 26, 2006 4:45 am
Posts: 4
hi
in EJB3 , in Session bean i am mapping dataSource , there is my code
@Resource(mappedName="java:/XAOracleDS") DataSource myTestDB;

with myTestDB datasource object i am doing operations
Connevtion con = myTestDB.getConnection(); and ect....

that works well, but when i am trying
@Resource(name="java:/XAOracleDS",type=javax.sql.XADataSource.class) XADataSource myTestDB; - do not .
Can you tell me how to bind XADataSource?

ds.xml

<datasources>
<xa-datasource>
<jndi-name>XAOracleDS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">jdbc:oracle:thin:@192.9.200.177:1521:devnbtwo</xa-datasource-property>
<xa-datasource-property name="User">b1</xa-datasource-property>
<xa-datasource-property name="Password">b2</xa-datasource-property>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<mbean code="org.jboss.jdbc.JdbcProvider" name="DefaultDomain:service=JdbcProvider">
<attribute name="Drivers">oracle.jdbc.driver.OracleDriver</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader" name="DefaultDomain:service=XADataSource,name=XAODS">
<attribute name="PoolName">XAODS</attribute>
<attribute name="DataSourceClass">XADataSource</attribute>
<attribute name="datasourceName">devnbtwo</attribute>
<attribute name="URL">jdbc:oracle:thin:@192.9.200.177:1521:devnbtwo</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password" />
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
</xa-datasource>

<mbean code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter" name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">jboss:service=TransactionManager </depends>
</mbean>
</datasources>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 10:01 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Try using @JndiInject.

Or you can even use this: http://it.sys-con.com/read/180386.htm


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 09, 2006 7:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
As ales said, Hibernate EntityManager doesn't care at all on the XA or non XA behavior of a datasource. Same for 2PC and all trasnaction related protocol.
the transaction implementation (in JTA) is completly transparent for the persistence provider.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.