Atomikos Forum |
|
I have been trying to setup a new Tomcat server on Linux but every time it tries to start my application I get the following error:
SEVERE: Exception sending context initialized event to listener instance of class uk.co.prodia.talkingcouch.ApplicationContextListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [config/applicationContext-db-sessionfactory.xml]: Cannot resolve reference to bean 'atomikosTransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'atomikosTransactionManager' defined in class path resource [config/applicationContext-db-sessionfactory.xml]: Invocation of init method failed; nested exception is javax.transaction.SystemException: Transaction service not running Tomcat version is 8.0.14 and I have tried with multiple SDK's. The current SDK is build 1.8.0_77-b03 and I have tried it as a package and as a stand-alone install. I have also tried tomcat-8.0.33 and instead got other problems that do not show when using tomcat 8.0.9. I have tested the setup on windows with the same verions of Tomcat and Java but the error did not show. I have the my app running in various versions on Windows and also on another Linux server. It seems to be something to do with the environment more than the app. Does anyone have any idea why this may be happening? This is part of my applicationContext-db-sessionfactory.xml: <bean id="atomikosTransactionManager" class="com.atomikos.icatch.jta.UserTransactionManager" init-method="init" destroy-method="close" depends-on="userTransactionService"> <property name="forceShutdown"> <value>false</value><!-- Spring should shut this down --> </property> <property name="startupTransactionService" value="false"/> </bean> <bean id="atomikosUserTransaction" class="com.atomikos.icatch.jta.J2eeUserTransaction" depends-on="userTransactionService"> <property name="transactionTimeout" value="300" /> </bean> <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager" depends-on="userTransactionService"> <property name="transactionManager" ref="atomikosTransactionManager" /> <property name="userTransaction" ref="atomikosUserTransaction" /> </bean> I'm pretty stuck after 12 hours of trying everything I can think of. Any suggestions would be appreciated. Thanks Gavin.
This seems to be due to the way in which Tomcat is starting.
1) Usining 'service tomcat8 start' fails with installation through package manager fails; 2)Using a standalone tomcat and starting using './startup.sh' works; 3) Using a standalone tomcat and starting with 'service tomcat8 start' (having modified /etc/init.d/tomcat8) fails. Maybe I can start without serverd (servcice tomcat8 start) and use a standard init script. Anyone have any other ideas?
The tmlog file is being created in $CATALINA_BASE (/var/lib/tomcat8) which is root writable only. I haven't managed to figure out why Atomikos is creating the log there as I have:
<bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownWait"> <constructor-arg> <props> tc <prop key="com.atomikos.icatch.output_dir">/storage/www/tc/data/atomikos</prop> <prop key="com.atomikos.icatch.log_base_dir">/storage/www/tc/data/atomikos</prop> ... </props> </constructor-arg> </bean> This works perfectly well on other Tomcat instances.
I did this:
1) Deleted the property 'com.atomikos.icatch.output_dir'; 2) Deleted the property 'com.atomikos.icatch.log_base_dir'. In my log4j.xml I needed this: <appender name="tc-core-atomikos" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="/stroage/www/tc/data/atomikos/tmout"/> <param name="MaxFileSize" value="1MB"/> <param name="MaxBackupIndex" value="5"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="tc-core-atomikos => [log level: %-5p] [thread: %t] [%d{dd MMM yyyy HH:mm:ss}]%n %c %M%n %m%n%n"/> </layout> </appender> <logger name="com.atomikos"> <level value="ERROR"/> <appender-ref ref="tc-core-atomikos"/> </logger> and hey presto, at last!
Thanks for sharing and sorry for the late response.
I would have suggested to look at https://www.atomikos.com/Documentation/ConfiguringTheLogs - do you think this page is wrong? Also, if you have any suggestions on what we can improve then please let me know. I will create an issue for the 4.0 then. Thanks! Guy
Hi Guy,
Thanks for responding. I actually still have a problem with this. I am finding that Atomikos is still wanting to write to $CATALINA_BASE which is only writable by root. My log4j.xml configuration is as follows: <appender name="tc-core-atomikos" class="org.apache.log4j.RollingFileAppender"> <param name="File" value="/storage/log/tomcat8/tc/atomikos/atomikos-log4j.log"/> <param name="MaxFileSize" value="1MB"/> <param name="MaxBackupIndex" value="5"/> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="tc-core-atomikos => [log level: %-5p] [thread: %t] [%d{dd MMM yyyy HH:mm:ss}]%n %c %M%n %m%n%n"/> </layout> </appender> <logger name="com.atomikos"> <level value="ERROR"/> <appender-ref ref="tc-core-atomikos"/> </logger> When running Tomcat as root the following two files are created in $CATALINA_BASE: 1) tmlog0.log; 2) tmlog.lck Additionally the log4j file is created. How do I stop Atomikos writing to $CATALINA_BASE? I have tried setting the following on the userTransactionService: <prop key="com.atomikos.icatch.log_base_name">tmlog</prop> <prop key="com.atomikos.icatch.log_base_dir">/storage/log/tomcat8/talkingcouch/atomikos/</prop> but I am not having any luck.
These look like the relevant bits and so it appears as if the properties are not being read in for some reason:
com.atomikos.icatch.provider.imp.AssemblerImp logInfo USING: com.atomikos.icatch.serial_jta_transactions = true com.atomikos.icatch.provider.imp.AssemblerImp logInfo USING: com.atomikos.icatch.log_base_dir = ./ com.atomikos.icatch.provider.imp.AssemblerImp logInfo USING: com.atomikos.icatch.enable_logging = true com.atomikos.icatch.provider.imp.AssemblerImp logInfo USING: com.atomikos.icatch.output_dir = ./ com.atomikos.icatch.provider.imp.AssemblerImp logInfo USING: com.atomikos.icatch.log_base_name = tmlog com.atomikos.persistence.imp.LogFileLock logWarning ERROR: the specified log seems to be in use already. Make sure that no other instance is running, or kill any pending process if needed. Running a 'find / -name tmlog.lck' does not return anything and so I am unsure why that last line is there. This is the current configuration for the userTransactionService: <bean id="userTransactionService" class="com.atomikos.icatch.config.UserTransactionServiceImp" init-method="init" destroy-method="shutdownWait"> <constructor-arg> <props> <prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop> <prop key="com.atomikos.icatch.console_file_name">tm.out</prop> <prop key="com.atomikos.icatch.log_base_name">tmlog</prop> <prop key="com.atomikos.icatch.tm_unique_name">com.atomikos.spring.jdbc.tm</prop> <prop key="com.atomikos.icatch.console_log_level">DEBUG</prop> <prop key="com.atomikos.icatch.output_dir">/storage/www/talkingcouch/data/atomikos</prop> <prop key="com.atomikos.icatch.log_base_dir">/storage/www/talkingcouch/data/atomikos</prop> <prop key="com.atomikos.icatch.console_file_count">5</prop> <prop key="com.atomikos.icatch.enable_logging">true</prop> </props> </constructor-arg> </bean>
OK, nearly there. If I use only the following:
<prop key="com.atomikos.icatch.service">com.atomikos.icatch.standalone.UserTransactionServiceFactory</prop> <prop key="com.atomikos.icatch.log_base_name">tc-atomikos-transaction-log</prop> <prop key="com.atomikos.icatch.output_dir">/storage/www/...</prop> <prop key="com.atomikos.icatch.log_base_dir">/storage/www/...</prop> then the only issue in the log is: com.atomikos.persistence.imp.LogFileLock error ERROR: the specified log seems to be in use already: tmlog in ./. Make sure that no other instance is running, or kill any pending process if needed. but the web app starts and is accessible. |