简体   繁体   English

奇怪的Atomikos异常 - init()出错:Log已在使用中?

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

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). 我们试图在几个本地环境中运行使用Atomikos作为事务管理器的相同Web应用程序(每个环境使用相同版本的spring,atomikos,tomact等,使用相同的配置文件)。 Some of them work fine, but in one of them, when we try to to start tomcat we get the following exception: 其中一些工作正常,但在其中一个中,当我们尝试启动tomcat时,我们得到以下异常:

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 同样,我们的环境具有完全相同的配置,可以正常工作,另一个环境有另一个奇怪的警告: https//stackoverflow.com/questions/20936253/atomikos-with-activemq-commit-heuristic-warnings

Thanks! 谢谢! :) :)

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' ). 如果部署了多个项目(使用Atomikos),则会出现此问题,原因是编写atomikos的日志文件时出现并发( 错误消息:'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: 要解决此问题, 您必须自定义日志文件名在atomikos配置中 设置属性 “com.atomikos.icatch.log_base_name” 如下所示:

<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>

PS: 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. PS:请注意,我已经更改了属性' com.atomikos.icatch.output_dir '和' com.atomikos.icatch.log_base_dir ',只是为了保持组织有序,在同一JBoss日志文件目录中创建atomikos的日志文件。

This is a permission question. 这是一个许可问题。 I add this two line in my jta.properties.(confirm the dir is exist). 我在我的jta.properties中添加了这两行。(确认目录存在)。

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

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. Atomikos试图在eclipse文件夹中创建lck文件,一旦我们将eclipse移动到另一个位置,一切正常。

Go to the destination where atomikos logs are getting generated. 转到生成atomikos日志的目标位置。 Over there you will observe various 0 byte lock files which need to be deleted. 在那里,您将观察需要删除的各种0字节锁定文件。 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 删除lck文件然后尝试部署应用程序后,问题就会得到解决

By default, atomikos creates its log file and lock file in the home directory of the user running the JVM. 默认情况下,atomikos在运行JVM的用户的主目录中创建其日志文件和锁定文件。

In the case of Tomcat8, this would be: 在Tomcat8的情况下,这将是:

/usr/share/tomcat8 的/ usr /共享/ 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. 这意味着tomcat用户无法写入它。

I changed it to: 我改成了:

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

And all worked fine. 一切正常。

In my case the issue was that my JBoss stopped in an unexpected way within Eclipse. 就我而言,问题是我的JBoss在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. 我试图再次启动并收到此错误,但实际上是因为我的机器中仍然运行了一个JBoss进程,尽管Eclipse将其显示为已终止。 So I just killed the existent JBoss processes. 所以我刚刚杀死了现有的JBoss进程。

If it helps some lost soul, this problem occurred to me when I installed the Eclipse Memory Analyzer (MAT) plugin from Eclipse. 如果它有助于一些失去的灵魂,当我从Eclipse安装Eclipse Memory Analyzer (MAT)插件时,我就会遇到这个问题。

The problem went away as soon as I uninstalled the plugin (instructions here ). 卸载插件后,问题就消失了( 此处的说明)。

MAT plugin Developers, please take note of this issue! MAT插件开发者,请注意这个问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM