Quick HOW-TO

Setting up: 
TopLink 9.0.3/Oracle (8.1.7,9.2,9.0)/Oracle XA 
DataSource/JBoss 3.0.4/JDK1.4.1

1. Run initjvm.sql and initxa.sql in the oracle databases
that you will be connecting to with the Oracle XA 
DataSources configured in JBoss. They can be 
found in $ORACLE_HOME/javavm/install. 

2. Get the latest Oracle JDBC Driver from 
http://technet.oracle.com. The one I used is the 
latest and is named ojdbc14.jar (not classes12.zip).

3. Copy $JBOSS_HOME/docs/examples/jca/
oracle-xa-service.xml to the appropriate 
$JBOSS_HOME/server/[all|default|minimal]/deploy 
and configure it for your database. 

4. Modify $JBOSS_HOME/server/[all|default|minimal]/conf/
jboss-service.xml to include the attribute pad true
for the XidFactory. It should look as follows: 
<mbean code="org.jboss.tm.XidFactory" 
name="jboss:service=XidFactory">
<attribute name="Pad">true</attribute>
</mbean>

5. In your code to connect up to JNDI using the TopLink
JNDIConnector you will need to lookup and get the 
DataSource yourself and pass it in the JNDIConnector
constructor. If you user the a jndi name string 
the JNDIConnector will generate a CompositeName, which
results in a InvalidNamingException - not a 
CompoundName. It appears that CompositeNames do not
work in JBoss 3.0.4. Here is some sample code: 

//jndiProperties are the your properties
Context context = InitialContext(jndiProperties);
javax.sql.DataSource ds =
(javax.sql.DataSource) context.lookup(
"java:/XATestDS");
JNDIConnector connector = new JNDIConnector(ds);
login.setConnector(connector);

6. You will need to write code to lookup and get 
the JBoss TransactionManager and then use the 
TopLink JTSSynchronizationListener to set the
transaction manager so TopLink knows about it. 
The following code is an example: 
import javax.transaction.TransactionManager;
import oracle.toplink.jts.*;
......
TransactionManager tm = 
(TransactionManager)context.lookup(
transactionMgrJndiName);
JTSSynchronizationListener.
setTransactionManager(tm);

7. Finally you need to also set in TopLink the 
the external JTS Controller class and let 
TopLink know you want to use external
transactions. The generic TopLink class
JTSExternalTransactionController seems to 
work so far. An example: 

login.useExternalTransactionController();

String jtsControllerClassName = 
"JTSExternalTransactionController";
Class jtsControllerClass =
Thread .currentThread()
.getContextClassLoader()
.loadClass(
jtsControllerClassName);
ExternalTransactionController jtsController =
(ExternalTransactionController)
jtsControllerClass
.newInstance();
serverSession.setExternalTransactionController(
jtsController);
login.useExternalConnectionPooling();


That does it. Hopefully this helps others who may
struggle as well. 



Mike H. Sr.
                                                              
Michael Huneycutt Sr.
TRC - A perotsystems* Company
Email: [EMAIL PROTECTED] 
Office FL: (813) 891-6084 x47395
Office VA: (804) 934-0977
Cell: (804) 304-7655
URL:   www.trcinc.com
           www.perotsys.com




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to