Pergunta

I need help with a project I'm working on. It's a web server built with Java spring. I use Tomcat 6 as web server. I switched from MyEclipse For Spring to Eclipse EE and I cannot deploy my web server anymore on my Ubuntu 12.10 64 bit machine.

The exception I'm getting is the following:

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

My JTA.properties is as following:

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/

Last two properties are commented as one of the many trials I've done to resolve this error.

My servlet-dao-context.xml is:

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

I have no idea on how to make this work. I don't understand why it searches for the file tm.out in the path /var/lib/tomcat6/./tm.out. What does that "/./" stand for?

Please help. Andrea

Foi útil?

Solução

I have had the same issue. It seems like tomcat is not installing with the correct permissions or I have missed something in the atomikos configuration.

On my installation /var/lib/tomcat6 is permissioned as 'root' whereas all of the other sub-directories are 'tomcat6'. As tomcat runs as user tomcat6, it cannot create the file.

I changed the owner of /var/lib/tomcat6 directory to tomcat6 and all works fine with no issue. I assume that atomikos is expecting something to give it a sub directory of the tomcat directory, but this is set to '.' (which means the current directory on its own or the present directory if it forms part of a path, like '..' means the parent directory). Hence it is actually $TOMCAT_HOME/{atomikos-dir}/tm.out

If you can find out where to change '.' to something better, then this would avoid the directory permissions issue (and if you do I would suggest changing it back at a later stage!)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top