init()中的Atomikos错误:无法获取/var/lib/tomcat6/./tm.out的锁定

时间:2013-07-20 15:34:50

标签: java spring ubuntu tomcat6 atomikos

我需要帮助处理我正在进行的项目。它是使用Java spring构建的Web服务器。我使用Tomcat 6作为Web服务器。 我从MyEclipse For Spring切换到Eclipse EE,我无法在我的Ubuntu 12.10 64位机器上部署我的Web服务器。

我得到的例外情况如下:

SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomikosTransactionManager' defined in class path resource [GestioneOneriServlet-dao-context.xml]: Error setting property values; nested exception is     org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'transactionTimeout' threw exception; nested exception is com.atomikos.icatch.SysException: Error in init(): Couldn't get lock for /var/lib/tomcat6/./tm.out
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1361)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3972)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4467)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1251)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:612)
at org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:136)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:558)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested    PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'transactionTimeout' threw exception; nested exception is com.atomikos.icatch.SysException: Error in init(): Couldn't get lock for /var/lib/tomcat6/./tm.out
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:102)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:58)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1358)
... 33 more

我的JTA.properties如下:

com.atomikos.icatch.service=com.atomikos.icatch.standalone.UserTransactionServiceFactory
com.atomikos.icatch.console_file_name = tm.out
com.atomikos.icatch.log_base_name = tmlog
com.atomikos.icatch.tm_unique_name = myeclipseforspring
com.atomikos.icatch.serial_jta_transactions=false
com.atomikos.icatch.automatic_resource_registration=true
com.atomikos.icatch.max_actives=15000
com.atomikos.icatch.max_timeout=3600000
com.atomikos.icatch.enable_logging=false
com.atomikos.icatch.console_log_level=WARN
#com.atomikos.icatch.output_dir=/home/atomikos-sw-tmp/
#com.atomikos.icatch.log_base_dir=/home/atomikos-sw-tmp/

最后两个属性被评为我为解决此错误而进行的众多试验之一。

我的servlet-dao-context.xml是:

<!-- Using Atomikos Transaction Manager -->
    <bean class="com.atomikos.icatch.jta.UserTransactionManager" destroy-method="close" id="atomikosTransactionManager" init-method="init">
        <property name="forceShutdown" value="true"/>
        <property name="startupTransactionService" value="true"/>
        <property name="transactionTimeout" value="60"/>
    </bean>
    <bean class="com.atomikos.icatch.jta.UserTransactionImp" id="atomikosUserTransaction"/>
    <!-- Configure the Spring framework to use JTA transactions from Atomikos -->
    <bean class="org.springframework.transaction.jta.JtaTransactionManager" id="transactionManager">
        <property name="transactionManager" ref="atomikosTransactionManager"/>
        <property name="userTransaction" ref="atomikosUserTransaction"/>
        <property name="transactionSynchronizationName" value="SYNCHRONIZATION_ON_ACTUAL_TRANSACTION"/>
    </bean>

我不知道如何使这项工作。我不明白为什么它在路径/var/lib/tomcat6/./tm.out中搜索文件tm.out。 “/./”代表什么?

请帮忙。 安德烈

1 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。似乎tomcat没有使用正确的权限进行安装,或者我在atomikos配置中遗漏了一些内容。

在我的安装上,/ var / lib / tomcat6被许可为'root',而所有其他子目录都是'tomcat6'。由于tomcat以用户tomcat6的身份运行,因此无法创建文件。

我将/ var / lib / tomcat6目录的所有者更改为tomcat6,一切正常,没有问题。 我假设atomikos期望给它一个tomcat目录的子目录,但这被设置为'。' (这意味着当前目录本身或当前目录,如果它构成路径的一部分,如'..'表示父目录)。 因此它实际上是$ TOMCAT_HOME / {atomikos-dir} /tm.out

如果你能找到改变的地方'。'为了更好的东西,那么这将避免目录权限问题(如果你这样做,我会建议在以后更改它!)