我在项目中使用atomikos essentials来管理交易。部署项目后,我收到以下异常。我陷入了困境,无法解决它。任何人都可以帮我解决这个问题。
线程中的异常" Atomikos:0" java.lang.AbstractMethodError: com.atomikos.jdbc.AtomikosDataSourceBean.getMaxLifetime()我 在com.atomikos.datasource.pool.ConnectionPool.removeConnectionsThatExceededMaxLifetime(ConnectionPool.java:286) 在com.atomikos.datasource.pool.ConnectionPool.access $ 000(ConnectionPool.java:47) 在com.atomikos.datasource.pool.ConnectionPool $ 1.alarm(ConnectionPool.java:92) 在com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:112) 在com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:99) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745)
这是我的atomikos配置,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-3.0.xsd">
<!-- Optional: add a log administrator - To view Active Transaction-->
<!-- <bean id="localLogAdministrator"
class="com.atomikos.icatch.admin.imp.LocalLogAdministrator"/> -->
<bean id="userTransactionService"
class="com.atomikos.icatch.config.UserTransactionServiceImp"
init-method="init" destroy-method="shutdownForce">
<constructor-arg>
<!-- IMPORTANT: specify all Atomikos properties here -->
<props>
<prop key="com.atomikos.icatch.service">
com.atomikos.icatch.standalone.UserTransactionServiceFactory
</prop>
</props>
</constructor-arg>
<!-- Uncomment to see the java Applet Program to view the active transaction -->
<!-- <property name="initialLogAdministrators">
<list>
<ref bean="localLogAdministrator"/>
</list>
</property> -->
</bean>
<!--
Construct Atomikos UserTransactionManager to manage XA datasources
-->
<bean id="AtomikosTransactionManager"
class="com.atomikos.icatch.jta.UserTransactionManager"
init-method="init" destroy-method="close"
depends-on="userTransactionService">
<!-- IMPORTANT: disable startup because the userTransactionService above does this -->
<property name="startupTransactionService" value="false"/>
<!--
Decide when close is called,
should we force transactions to terminate or not?
-->
<property name="forceShutdown" value="false" />
</bean>
<!--
Atomikos User transaction to set transactionTimeout
-->
<bean id="AtomikosUserTransaction"
class="com.atomikos.icatch.jta.UserTransactionImp"
depends-on="userTransactionService">
<property name="transactionTimeout" value="1000" />
</bean>
<!-- To fetch datasource properties from JNDI -->
<bean id="xadatasourceprops" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="properties">
<bean class="java.util.Properties">
<constructor-arg>
<map>
<entry key="xaDataSourceClassName">
<jee:jndi-lookup jndi-name="java:comp/env/xaDataSourceClassName"/>
</entry>
<entry key="user">
<jee:jndi-lookup jndi-name="java:comp/env/user"/>
</entry>
<entry key="password">
<jee:jndi-lookup jndi-name="java:comp/env/password"/>
</entry>
<entry key="url">
<jee:jndi-lookup jndi-name="java:comp/env/url"/>
</entry>
<entry key="poolsize">
<jee:jndi-lookup jndi-name="java:comp/env/poolsize"/>
</entry>
</map>
</constructor-arg>
</bean>
</property>
</bean>
<!-- Configuring Atomikos DataSource Bean for Database-->
<bean id="atomikosDataSourceBean" class="com.atomikos.jdbc.AtomikosDataSourceBean" init-method="init" destroy-method="close">
<!-- set an arbitrary but unique name for the datasource -->
<property name="uniqueResourceName"><value>XADBResource</value></property>
<!-- set the underlying driver class to use -->
<property name="xaDataSourceClassName">
<value>${xaDataSourceClassName}</value>
</property>
<property name="xaProperties">
<!-- set the driver-specific XADataSource properties -->
<props>
<prop key="user">${user}</prop>
<prop key="password">${password}</prop>
<prop key="URL">${url}</prop>
</props>
</property>
<!-- how many connections in the pool? -->
<property name="poolSize" value="${poolsize}"/>
</bean>
<!-- Configuring Atomikos Connection Factory for JMS - ActiveMQ -->
<bean id="connectionFactory"
class="org.apache.activemq.spring.ActiveMQXAConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<property name="objectMessageSerializationDefered">
<value>true</value>
</property>
</bean>
<bean id="jmsListenerContainerFactory"
class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
<!--
Configure the JMS connector;
call init to register for recovery!
-->
<bean id="atomikosConnectionFactoryBean"
class="com.atomikos.jms.AtomikosConnectionFactoryBean"
init-method="init" destroy-method="close">
<property name="uniqueResourceName" value="amq_jms" />
<property name="xaConnectionFactory" ref="connectionFactory" />
<property name="poolSize" value="5" />
</bean>
<bean id="listenerContainerFactory"
class="org.springframework.jms.config.DefaultJmsListenerContainerFactory">
<property name="connectionFactory" ref="connectionFactory" />
</bean>
</beans>
答案 0 :(得分:1)
使用atomikos-jdbc v3.7及之前,没有maxLifeTime
方法。
后来的版本有方法。因此,它看起来是2个atomikos库jar的问题,这些库不是创建问题的相同版本。
尝试使用最新版本更新Atomikos库。