solve error : log already in use with atomikos with multiple instances

坚强是说给别人听的谎言 提交于 2019-12-05 07:40:36

there is a lock file that must be removed in order to startup your container again. Its name is tmlog.lck. At Apache 7 it is located at APACHE_HOME/bin/

Good luck.

When you have more than one project (that uses Atomikos) deployed, this problem occurs due to concurrency on writing atomikos' log files (Error message: 'Log already in use').

To solve this problem you must customize the log file name, setting the property 'com.atomikos.icatch.log_base_name' in atomikos configuration as exemplified below:

<bean id="atomikosUserTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp"
      init-method="init" destroy-method="shutdownForce">
    <constructor-arg>
        <props>
            <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop>
            <prop key="com.atomikos.icatch.log_base_name">your_project_name_log</prop>
            <prop key="com.atomikos.icatch.output_dir">../standalone/log/</prop>
            <prop key="com.atomikos.icatch.log_base_dir">../standalone/log/</prop>
        </props>
    </constructor-arg>
</bean>

P.S.: Note that I've changed the properties 'com.atomikos.icatch.output_dir' and 'com.atomikos.icatch.log_base_dir' just to keep the things organized, creating atomikos' log files in the same directory of JBoss log files.

charley

This is a permission issue. I added this two line in my jta.properties.(confirm the dir is exist).

com.atomikos.icatch.output_dir = /data/logs/XXX/
com.atomikos.icatch.log_base_dir = /data/logs/XXX/

In our case the reason was completely different:

We configured our tomcat8 instance to contain all needed Atomikos .jars. That was mainly as described here: Atomikos Tomcat 7 Configuration

In our Spring application configuration we needed to define the J2eeTransactionManager (due to the "transaction suspension not available" problem already described here):

@Bean
public TransactionManager atomikosTransactionManager() {
    return new J2eeTransactionManager();
}

@Bean
public PlatformTransactionManager txManager() throws Throwable {
    JtaTransactionManager jtaTransactionManager = new JtaTransactionManager();
    jtaTransactionManager.setAllowCustomIsolationLevels(true);
    jtaTransactionManager.setTransactionManager(atomikosTransactionManager());
    UserTransaction ut = userTransaction();
    jtaTransactionManager.setUserTransaction(ut);
    return  jtaTransactionManager;
}

So you need a reference to the pom.xml in your application, but this reference has to have the "provided" scope:

    <dependency>
        <groupId>com.atomikos</groupId>
        <artifactId>transactions-jta</artifactId>
        <version>3.9.3</version>
        <scope>provided</scope>
    </dependency>

In our case, we omitted the scope and therefore tomcat and our application created it's own instance of the transaction manager and that resulted to the "log already in use" error message.

So deleting the .lock-file helped here, too. After deleting the lock-file the application specific transaction manager could obtain the lock and was running fine; but after a tomcat restart, you would get the same error message again.

Since I found this cause nowhere else, maybe this is helpful to others...

Are you sure there isn't any other JVM running on your production server that could lock the atomikos transaction log ?

A little late maybe, but this typically happens if you have multiple transaction manager instances (JVMs) using the same logs. Just try not to do that :-)

HTH

I also got the same error, but the scenario was different. Atomikos creates a different java process, and in my case that java process was running in infinite loop in unix box, although I stopped the tomcat container.

So I found out that java process using below command.

ps -ef | grep java | grep -v grep 

And killed using this command

kill -9 pid

Started the tomcat again, and it worked fine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!