Multiple BTM Instances

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiple BTM Instances

greenbean
Is it possible to run multiple instances of Bitronix 2.1.1 in a single JVM?  I have a couple of EARs each containing WARs.  I attempted to create multiple Bitronix instances using the Spring configuration.  However, I get the following error:  “Cannot change the configuration while the transaction manager is running”
 
I am using a universal classloader in JBoss, so the two ears do share the same classloader.  When I comment out the btmConfig2 and remove it as a dependency for the transactionManagerImpl, then things load ok.
 
 
EAR1:
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="lantern-btm" />
        <property name="logPart1Filename" value="btm3.tlog" />
        <property name="logPart2Filename" value="btm4.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
        depends-on="btmConfig" destroy-method="shutdown" />
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EAR2:
    <!-- Only create one instance shared between two ears -->
    <!--<bean id="btmConfig2" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="testa-btm" />
        <property name="logPart1Filename" value="btm1.tlog" />
        <property name="logPart2Filename" value="btm2.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>-->
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
         destroy-method="shutdown" />
 
Reply | Threaded
Open this post in threaded view
|

Re: Multiple BTM Instances

Brett Wooldridge-2
Ludovic can give you a definitive answer, but basically Bitronix has classes that have static members so it is not possible to run more than one Bitronix instance *per classloader*.  So, as long as you are using the Universal classloader, I do not think it will be possible.  If each EAR has it's own classloader, there should be no problem.

I haven't used JBoss in several years, but it may be possible through some clever configuration to create a single Bitronix instance in the universal classloader and then have each EAR reference that same BTM instance.

Brett

On Fri, Apr 22, 2011 at 4:06 AM, Urciolo, Kevin J (IS) <[hidden email]> wrote:
Is it possible to run multiple instances of Bitronix 2.1.1 in a single JVM?  I have a couple of EARs each containing WARs.  I attempted to create multiple Bitronix instances using the Spring configuration.  However, I get the following error:  “Cannot change the configuration while the transaction manager is running”
 
I am using a universal classloader in JBoss, so the two ears do share the same classloader.  When I comment out the btmConfig2 and remove it as a dependency for the transactionManagerImpl, then things load ok.
 
 
EAR1:
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="lantern-btm" />
        <property name="logPart1Filename" value="btm3.tlog" />
        <property name="logPart2Filename" value="btm4.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
        depends-on="btmConfig" destroy-method="shutdown" />
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EAR2:
    <!-- Only create one instance shared between two ears -->
    <!--<bean id="btmConfig2" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="testa-btm" />
        <property name="logPart1Filename" value="btm1.tlog" />
        <property name="logPart2Filename" value="btm2.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>-->
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
         destroy-method="shutdown" />
 

Reply | Threaded
Open this post in threaded view
|

Re: Multiple BTM Instances

Keith Johnston-3
Class loader isolation is indeed possible, see the following: http://community.jboss.org/wiki/classloadingconfiguration


On 22 Apr 2011, at 00:56, Brett Wooldridge <[hidden email]> wrote:

Ludovic can give you a definitive answer, but basically Bitronix has classes that have static members so it is not possible to run more than one Bitronix instance *per classloader*.  So, as long as you are using the Universal classloader, I do not think it will be possible.  If each EAR has it's own classloader, there should be no problem.

I haven't used JBoss in several years, but it may be possible through some clever configuration to create a single Bitronix instance in the universal classloader and then have each EAR reference that same BTM instance.

Brett

On Fri, Apr 22, 2011 at 4:06 AM, Urciolo, Kevin J (IS) <[hidden email]> wrote:
Is it possible to run multiple instances of Bitronix 2.1.1 in a single JVM?  I have a couple of EARs each containing WARs.  I attempted to create multiple Bitronix instances using the Spring configuration.  However, I get the following error:  “Cannot change the configuration while the transaction manager is running”
 
I am using a universal classloader in JBoss, so the two ears do share the same classloader.  When I comment out the btmConfig2 and remove it as a dependency for the transactionManagerImpl, then things load ok.
 
 
EAR1:
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="lantern-btm" />
        <property name="logPart1Filename" value="btm3.tlog" />
        <property name="logPart2Filename" value="btm4.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
        depends-on="btmConfig" destroy-method="shutdown" />
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EAR2:
    <!-- Only create one instance shared between two ears -->
    <!--<bean id="btmConfig2" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="testa-btm" />
        <property name="logPart1Filename" value="btm1.tlog" />
        <property name="logPart2Filename" value="btm2.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>-->
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
         destroy-method="shutdown" />
 

Reply | Threaded
Open this post in threaded view
|

Re: Multiple BTM Instances

Ludovic Orban-2
Brett is right on spot: you can only have a single instance of a transaction manager per classloader so to have two transaction managers with two different configs, you need to compartmentalize your EARs in different classloaders.

An alternative would be to initialize BTM only from a single EAR. Both EARs would then share everything: the transaction manager and the connection pools which may or may not be desirable but as long as you pay attention that everything is only initialized once, BTM is completely thread-safe and can be used from two completely unrelated applications.

In the end, it's up to you: share it between your two EARs and make sure it is initialized once, or separate your EARs in different classloaders.


2011/4/22 Keith Johnston <[hidden email]>
Class loader isolation is indeed possible, see the following: http://community.jboss.org/wiki/classloadingconfiguration


On 22 Apr 2011, at 00:56, Brett Wooldridge <[hidden email]> wrote:

Ludovic can give you a definitive answer, but basically Bitronix has classes that have static members so it is not possible to run more than one Bitronix instance *per classloader*.  So, as long as you are using the Universal classloader, I do not think it will be possible.  If each EAR has it's own classloader, there should be no problem.

I haven't used JBoss in several years, but it may be possible through some clever configuration to create a single Bitronix instance in the universal classloader and then have each EAR reference that same BTM instance.

Brett

On Fri, Apr 22, 2011 at 4:06 AM, Urciolo, Kevin J (IS) <[hidden email][hidden email]> wrote:
Is it possible to run multiple instances of Bitronix 2.1.1 in a single JVM?  I have a couple of EARs each containing WARs.  I attempted to create multiple Bitronix instances using the Spring configuration.  However, I get the following error:  “Cannot change the configuration while the transaction manager is running”
 
I am using a universal classloader in JBoss, so the two ears do share the same classloader.  When I comment out the btmConfig2 and remove it as a dependency for the transactionManagerImpl, then things load ok.
 
 
EAR1:
    <bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="lantern-btm" />
        <property name="logPart1Filename" value="btm3.tlog" />
        <property name="logPart2Filename" value="btm4.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
        depends-on="btmConfig" destroy-method="shutdown" />
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
EAR2:
    <!-- Only create one instance shared between two ears -->
    <!--<bean id="btmConfig2" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
        <property name="serverId" value="testa-btm" />
        <property name="logPart1Filename" value="btm1.tlog" />
        <property name="logPart2Filename" value="btm2.tlog" />
        <property name="defaultTransactionTimeout" value="15000" />
    </bean>-->
    <bean id="transactionManagerImpl" factory-method="getTransactionManager" class="bitronix.tm.TransactionManagerServices"
         destroy-method="shutdown" />