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

天涯浪子 提交于 2019-12-10 12:38:07

问题


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! :)


回答1:


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.




回答2:


This is a permission question. I add 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/



回答3:


Turns out it was a permission issue. Atomikos was trying to create the lck files in the eclipse folder, and once we moved eclipse to another location everything worked fine.




回答4:


Go to the destination where atomikos logs are getting generated. Over there you will observe various 0 byte lock files which need to be deleted. This issue is observed when the last time the application was run it was shut down incorrectly. Once you delete the lck files and then try deploying the application the issue would be resolved




回答5:


By default, atomikos creates its log file and lock file in the home directory of the user running the JVM.

In the case of Tomcat8, this would be:

/usr/share/tomcat8

You should check the permissions on this folder. On mine, it was:

drwxr_xr-x  3 root   tomcat 4096 Feb  7 10:28 .

Which meant the tomcat user couldn't write to it.

I changed it to:

drwxrwxr-x  3 root   tomcat 4096 Feb  7 10:28 .

And all worked fine.




回答6:


In my case the issue was that my JBoss stopped in an unexpected way within Eclipse. I tried to start it again and received this error, but actually it was because there was a JBoss process still running in my machine, although Eclipse showed it as terminated. So I just killed the existent JBoss processes.




回答7:


If it helps some lost soul, this problem occurred to me when I installed the Eclipse Memory Analyzer (MAT) plugin from Eclipse.

The problem went away as soon as I uninstalled the plugin (instructions here).

MAT plugin Developers, please take note of this issue!



来源:https://stackoverflow.com/questions/21014964/strange-atomikos-exception-error-in-init-log-already-in-use

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