Umm... I'd rather post it here, you can copy it later to Wiki if you know how to do it
... as I don't :(
Note: each of the JTA implementations used has its own problems: JOTM doesn't
automatically shutdown with Tomcat; Atomikos has its own log framework that is a pain to
configure (they promised to migrate to log4j/CL though); and JBoss Tx doesn't seem to
have a way to configure XA-aware datasources (I've asked for help on their forum,
waiting for answers). Nevertheless, all of them allow to start up Seam without the
Microcontainer (that's 3.5Mb of JARs and a bunch of nasty restrictions, mind you...).
All that is needed is the Tomcat's standard META-INF/context.xml file (or use
server.xml if you prefer), some declarations in META-INF/persistence.xml file, plus some
glue code and some property files.
JOTM setup (
http://jotm.objectweb.org/):
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <Context>
| <Resource name="DataSource" auth="Container"
type="javax.sql.DataSource"
| maxActive="100" maxIdle="30" maxWait="10000"
username="user"
| password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
| url="url"
| factory="org.objectweb.jndi.DataSourceFactory" />
| <Transaction name="UserTransaction" auth="Container"
| type="javax.transaction.UserTransaction"
| factory="org.objectweb.jotm.UserTransactionFactory"
jotm.timeout="60000" />
| </Context>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <persistence
xmlns="http://java.sun.com/xml/ns/persistence"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="unitName" transaction-type="JTA">
| <jta-data-source>java:comp/env/DataSource</jta-data-source>
| <properties>
| <property name="hibernate.transaction.manager_lookup_class"
| value="org.hibernate.transaction.JOTMTransactionManagerLookup" />
| </properties>
| </persistence-unit>
| </persistence>
jndi.properties (place in classpath):
java.naming.factory.initial=com.sun.jndi.rmi.registry.RegistryContextFactory
| java.naming.provider.url=rmi://localhost:1099
carol.properties (place in classpath):
carol.protocols=jrmp
| carol.start.jndi=false
| carol.start.ns=false
| carol.start.rmi=false
| carol.jndi.java.naming.factory.url.pkgs=org.apache.naming
JOTM is the only one that doesn't need any glue code, as all the necessary factories
(Hibernate TM lookup, UT factory, and XA DataSource factory) are already in place.
Atomikos setup (
http://www.atomikos.com/):
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <Context>
| <Resource auth="Container" name="DataSource"
| type="com.atomikos.jdbc.nonxa.NonXADataSourceBean"
connectionTimeout="20"
| factory="org.apache.naming.factory.BeanFactory" poolSize="1"
| user="user" password="password"
| driverClassName="oracle.jdbc.driver.OracleDriver"
| url="url" />
| <Transaction name="UserTransaction" auth="Container"
| type="javax.transaction.UserTransaction"
factory="test.util.AtomikosUTLookup" />
| </Context>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <persistence
xmlns="http://java.sun.com/xml/ns/persistence"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="unitName" transaction-type="JTA">
| <jta-data-source>java:comp/env/DataSource</jta-data-source>
| <properties>
| <property name="hibernate.transaction.manager_lookup_class"
| value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"
/>
| </properties>
| </persistence-unit>
| </persistence>
jta.properties (place in classpath):
com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
Atomikos needs one piece of "glue" code, and that is to look up the
UserTransaction properly. The developers promised to create the lookup class in later
versions, but for now, use this:
public class AtomikosUTLookup implements ObjectFactory {
| public AtomikosUTLookup() {
| }
| public Object getObjectInstance(Object obj, Name name, Context nameCtx,
| Hashtable environment) throws Exception {
| return new UserTransactionImp();
| }
| }
JBoss Transactions (formerly Arjuna JTA) setup (
http://labs.jboss.com/portal/jbosstm/):
context.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <Context>
| <Resource name="DataSource" auth="Container"
type="javax.sql.DataSource"
| maxActive="100" maxIdle="30" maxWait="10000"
username="user"
| password="password"
driverClassName="oracle.jdbc.driver.OracleDriver"
| url="url" />
| <Transaction name="UserTransaction" auth="Container"
| type="javax.transaction.UserTransaction"
factory="test.util.JBossJTAUTLookup" />
| </Context>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <persistence
xmlns="http://java.sun.com/xml/ns/persistence"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
| <persistence-unit name="unitName" transaction-type="JTA">
| <jta-data-source>java:comp/env/DataSource</jta-data-source>
| <properties>
| <property name="hibernate.transaction.manager_lookup_class"
| value="test.util.JBossJTATMLookup" />
| </properties>
| </persistence-unit>
| </persistence>
JBoss Tx requires both TM lookup code and UT lookup, and here they are:
JBossJTATMLookup.java:
public class JBossJTATMLookup implements TransactionManagerLookup {
| public TransactionManager getTransactionManager(Properties props)
| throws HibernateException {
| return com.arjuna.ats.jta.TransactionManager.transactionManager();
| }
| public String getUserTransactionName() {
| return "java:comp/UserTransaction";
| }
| }
JBossJTAUTLookup.java:
public class JBossJTAUTLookup implements ObjectFactory {
| public Object getObjectInstance(Object obj, Name name, Context nameCtx,
| Hashtable<?, ?> environment) throws Exception {
| return UserTransaction.userTransaction();
| }
| }
I still haven't figured it out with the DataSource configuration for JBoss Tx - for
now, I use the regular declaration without a factory (and it works) but maybe I simply
haven't run into any problems yet...
Oh yes, and the components.xml for all three looks like:
<core:init debug="true" />
| <core:manager conversation-timeout="120000"
concurrent-request-timeout="500"
| conversation-id-parameter="cid"
conversation-is-long-running-parameter="clr" />
| <core:entity-manager-factory name="unitName" />
| <core:managed-persistence-context name="entityManager"
auto-create="true"
| entity-manager-factory="#{unitName}" />
Note the lack of core:microcontainer declaration. jboss-beans.xml and jndi.properties from
the usual Seam-MC deploayment are not needed, either.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036408#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...