Multiple Spring/Hibernate web applications in same Tomcat6

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Multiple Spring/Hibernate web applications in same Tomcat6

Igor N
This post has NOT been accepted by the mailing list yet.
Hi,

I have two web apps running with spring/hibernate/btm. Versions are:
Spring 3.0.6,
Tomcat 6,
Hibernate 4.2.1

Each one runs great when running alone, but when start both of them at same time then application which starts second in start order fail with an error.

How I can rid of this fail?

Here is a content of my tomcat/conf/btm-config.properties(one app has tomcat-btm-node0 and other has tomcat-btm-node1 in their "serverId" property of btMconfig bean):

bitronix.tm.serverId=tomcat-btm-node0
bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1-0.tlog
bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2-0.tlog
bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties

bitronix.tm1.serverId=tomcat-btm-node1
bitronix.tm1.journal.disk.logPart1Filename=${btm.root}/work/btm1-1.tlog
bitronix.tm1.journal.disk.logPart2Filename=${btm.root}/work/btm2-1.tlog
bitronix.tm1.resource.configuration=${btm.root}/conf/resources2.properties.


Here is the error:

Caused by: bitronix.tm.utils.InitializationException: cannot open disk journal
        at bitronix.tm.BitronixTransactionManager.<init>(BitronixTransactionManager.java:98)
        at bitronix.tm.TransactionManagerServices.getTransactionManager(TransactionManagerServices.java:75)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:145)
        ... 41 more
Caused by: java.io.IOException: The process cannot access the file because another process has locked a portion of the file
        at sun.nio.ch.FileDispatcher.read0(Native Method)
        at sun.nio.ch.FileDispatcher.read(FileDispatcher.java:28)

Igor
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple Spring/Hibernate web applications in same Tomcat6

Igor N
This post has NOT been accepted by the mailing list yet.
Forgot to mention: BTM version is 2.1.4.
And other issue this error occurs when I put btm.jar inro WEB-INF/lib of each application. If I place btm.jar in Tomcat/lib folder instead of WEB-INF/lib then another error appears :

Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'serverId' threw exception; nested exception is java.lang.IllegalStateException: cannot change the configuration while the transaction manager is running
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
        at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1360)


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Multiple Spring/Hibernate web applications in same Tomcat6

Igor N
This post has NOT been accepted by the mailing list yet.
In reply to this post by Igor N
Here is my Spring beans configuration of each application:

----First application spring config start -------------

<bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
    <property name="serverId" value="tomcat-btm-node0"/>
</bean>

<bean id="BitronixTransactionManager" factory-method="getTransactionManager"
      class="bitronix.tm.TransactionManagerServices" destroy-method="shutdown" depends-on="btmConfig"  /> 
     
<bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager" depends-on="btmConfig">
        <property name="transactionManager" ref="BitronixTransactionManager" />
        <property name="userTransaction" ref="BitronixTransactionManager" />
</bean>

<bean id="entityManagerFactory1" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        depends-on="btmConfig">
        <property name="persistenceUnitName" value="PU1" />
        <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                        <property name="database" value="ORACLE" />
                        <property name="showSql" value="true" />
                        <property name="generateDdl" value="false" />
                </bean>
        </property>
</bean>

<bean id="entityManagerFactory2" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        depends-on="btmConfig">
        <property name="persistenceUnitName" value="PU2" />
        <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                        <property name="database" value="ORACLE" />
                        <property name="showSql" value="true" />
                        <property name="generateDdl" value="false" />
                </bean>
        </property>
</bean>

----First application spring config end -------------

----Second application spring config start ---------

<bean id="btmConfig" factory-method="getConfiguration" class="bitronix.tm.TransactionManagerServices">
    <property name="serverId" value="tomcat-btm-node1"/>
</bean>

...<rest of this spring config is skipped due to its same as for first application above>...

----Second application spring config end ---------
Loading...