AtomikosDataSourceBean.getMaxLifetime() 中的 AbstractMethodError

AbstractMethodError in AtomikosDataSourceBean.getMaxLifetime()

我在我的项目中使用 atomikos essentials 来管理事务。部署我的项目后出现以下异常。我陷入其中,无法解决。谁能帮我解决这个问题。

Exception in thread "Atomikos:0" java.lang.AbstractMethodError: com.atomikos.jdbc.AtomikosDataSourceBean.getMaxLifetime()I at com.atomikos.datasource.pool.ConnectionPool.removeConnectionsThatExceededMaxLifetime(ConnectionPool.java:286) at com.atomikos.datasource.pool.ConnectionPool.access[=12=]0(ConnectionPool.java:47) at com.atomikos.datasource.pool.ConnectionPool.alarm(ConnectionPool.java:92) at com.atomikos.timing.PooledAlarmTimer.notifyListeners(PooledAlarmTimer.java:112) at com.atomikos.timing.PooledAlarmTimer.run(PooledAlarmTimer.java:99) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at 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>

使用atomikos-jdbc v3.7及之前,没有maxLifeTime方法。 以后版本有方法。因此,这看起来是 2 个不同版本的 atomikos 库 jar 造成了您的问题。

尝试使用最新版本更新您的 Atomikos 库。