Strange Atomikos exception - Error in init(): Log already in use?

Ayelet picture Ayelet · Jan 9, 2014 · Viewed 9.3k times · Source

We're trying to run the same web application that uses Atomikos as transaction manager on several local envrionments (each of those uses the same versions of spring, atomikos, tomact etc with the same configuration files). Some of them work fine, but in one of them, when we try to to start tomcat we get the following exception:

Caused by: java.lang.IllegalStateException: Can't overwrite cause with java.lang.RuntimeException: Log already in use?
at java.lang.Throwable.initCause(Throwable.java:456)
at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:326)
at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:405)
at com.atomikos.icatch.config.UserTransactionServiceImp.init(UserTransactionServiceImp.java:569)
at com.atomikos.icatch.jta.UserTransactionManager.startupTransactionService(UserTransactionManager.java:89)
at com.atomikos.icatch.jta.UserTransactionManager.checkSetup(UserTransactionManager.java:77)
at com.atomikos.icatch.jta.UserTransactionManager.init(UserTransactionManager.java:142)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1638)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1579)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)
... 41 more
Caused by: com.atomikos.icatch.SysException: Error in init(): Log already in use?
... 54 more
Caused by: java.lang.RuntimeException: Log already in use?
at com.atomikos.icatch.standalone.UserTransactionServiceImp.createDefault(UserTransactionServiceImp.java:203)
at com.atomikos.icatch.standalone.UserTransactionServiceImp.init(UserTransactionServiceImp.java:258)

We can't figure out what's the log in question, and google wasn't much help either...Anyone know what the cause of this strange issues? Again, we have environments with the exact same configuration that work fine, and another that has another strange warning: https://stackoverflow.com/questions/20936253/atomikos-with-activemq-commit-heuristic-warnings

Thanks! :)

Answer

thiagocherubino picture thiagocherubino · Aug 12, 2014

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.