【问题标题】:Strange Atomikos exception - Error in init(): Log already in use?奇怪的 Atomikos 异常 - init() 中的错误:日志已在使用中?
【发布时间】:2014-01-27 16:38:44
【问题描述】:

我们正在尝试在多个本地环境中运行使用 Atomikos 作为事务管理器的相同 Web 应用程序(每个环境都使用相同版本的 spring、atomikos、tomact 等,并具有相同的配置文件)。其中一些工作正常,但在其中一个中,当我们尝试启动 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)

我们无法弄清楚有问题的日志是什么,谷歌也没有太多帮助......有人知道这个奇怪问题的原因是什么吗?同样,我们的环境具有完全相同的配置,可以正常工作,而另一个环境有另一个奇怪的警告:https://stackoverflow.com/questions/20936253/atomikos-with-activemq-commit-heuristic-warnings

谢谢! :)

【问题讨论】:

    标签: java tomcat jta atomikos


    【解决方案1】:

    如果它可以帮助一些迷失的灵魂,那么当我从 Eclipse 安装 Eclipse Memory Analyzer (MAT) 插件时,我就遇到了这个问题。

    我卸载插件后问题就消失了(说明here)。

    MAT插件开发者,请注意这个问题!

    【讨论】:

      【解决方案2】:

      默认情况下,atomikos 在运行 JVM 的用户的主目录中创建其日志文件和锁定文件。

      对于 Tomcat8,这将是:

      /usr/share/tomcat8

      您应该检查此文件夹的权限。在我的身上,它是:

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

      这意味着 tomcat 用户无法写入。

      我改成:

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

      一切正常。

      【讨论】:

      • /usr/share/tomcat8 可能不是放置应用程序日志文件的最佳位置。
      【解决方案3】:

      这是一个权限问题。我在我的 jta.properties 中添加了这两行。(确认目录存在)。

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

      【讨论】:

        【解决方案4】:

        就我而言,问题是我的 JBoss 在 Eclipse 中以一种意想不到的方式停止了。我尝试再次启动它并收到此错误,但实际上是因为我的机器中仍在运行一个 JBoss 进程,尽管 Eclipse 显示它已终止。所以我只是杀死了现有的 JBoss 进程。

        【讨论】:

          【解决方案5】:

          当您部署了多个项目(使用 Atomikos)时,由于同时写入 atomikos 的日志文件会出现此问题(错误消息:'Log already in use')。 p>

          要解决这个问题你必须自定义日志文件名设置属性 'com.atomikos.icatch.log_base_name' 在 atomikos 配置中如下所示:

          <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:请注意,我更改了属性 'com.atomikos.icatch.output_dir' 和 'com.atomikos.icatch.log_base_dir' 只是为了保留事情有条理,在 JBoss 日志文件的同一目录中创建 atomikos 的日志文件。

          【讨论】:

            【解决方案6】:

            原来是权限问题。 Atomikos 试图在 eclipse 文件夹中创建 lck 文件,一旦我们将 eclipse 移动到另一个位置,一切正常。

            【讨论】:

            • 确保同时删除 .epoch 文件(如果存在)。
            【解决方案7】:

            转到生成 atomikos 日志的目的地。在那里你会看到各种需要删除的 0 字节锁定文件。当应用程序最后一次运行时被错误地关闭时,会观察到此问题。删除 lck 文件然后尝试部署应用程序后,问题将得到解决

            【讨论】:

              猜你喜欢
              • 2018-08-27
              • 1970-01-01
              • 2012-01-02
              • 2012-11-30
              • 2012-08-08
              • 1970-01-01
              • 1970-01-01
              • 2011-04-25
              • 2023-03-29
              相关资源
              最近更新 更多