cancel
Showing results for 
Search instead for 
Did you mean: 

Hitting NoSuchMethodError in Spring Hibernate Integration

davidiamyou
Champ in-the-making
Champ in-the-making
Hello All,

I am new to Activiti with a project where I try to setup an environment which integrates Activiti, Spring and Hibernate.

The application is fine when I only register the processEngine bean, but it will hit the following error when I try to register runtimeService bean through:
<bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />

The error looks at the following:
07:58:05,102 ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-2) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'processEngine': FactoryBean threw exception on object creation; nested exception is java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.HibernateTransactionManager.determineTimeout(Lorg/springframework/transaction/TransactionDefinitionSmiley WinkI
   at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1442) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:248) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:353) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1015) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) [spring-context-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
   at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
   at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
   at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
   at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_07]
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_07]
   at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_07]
Caused by: java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.HibernateTransactionManager.determineTimeout(Lorg/springframework/transaction/TransactionDefinitionSmiley WinkI
   at
org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:389) [spring-orm-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:315) [spring-dao-2.0.jar:2.0]
   at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) [spring-dao-2.0.jar:2.0]
   at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:40) [activiti-spring-5.0.jar:]
   at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:33) [activiti-engine-5.0.jar:5.0]
   at org.activiti.engine.impl.ProcessEngineImpl.<init>(ProcessEngineImpl.java:83) [activiti-engine-5.0.jar:5.0]
   at org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:215) [activiti-engine-5.0.jar:5.0]
   at org.activiti.spring.SpringProcessEngineConfiguration.buildProcessEngine(SpringProcessEngineConfiguration.java:51) [activiti-spring-5.0.jar:]
   at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:50) [activiti-spring-5.0.jar:]
   at org.activiti.spring.ProcessEngineFactoryBean.getObject(ProcessEngineFactoryBean.java:31) [activiti-spring-5.0.jar:]
   at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
   … 27 more

If I remove this line, the deployment goes without error. The weird thing is when I try to access runtime service in unit tests through
processEngineFactory.getObject().getRunTimeService()
, there is no problem to that, seems like I just can't register it as a spring-managed bean.

My data source looks like this:

<bean id="dataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
    <property name="targetDataSource">
   <bean destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
      <property name="driverClassName" value="${jdbc.driverClassName}" />
      <property name="url" value="${jdbc.url}" />
      <property name="username" value="${jdbc.username}" />
      <property name="password" value="${jdbc.password}" />
      <property name="defaultAutoCommit" value="false" />
   </bean>
   </property>
</bean>

My Hibernate session bean looks like this:

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
      
      <property name="dataSource">
            <ref bean="dataSource"/>
       </property>
       
       <property name="hibernateProperties">
             <props>
               <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
               <prop key="hibernate.show_sql">true</prop>
               <prop key="hibernate.c3p0.timeout">1800</prop>
               <prop key="hibernate.c3p0.min_size">5</prop>
               <prop key="hibernate.c3p0.max_size">20</prop>
               <prop key="hibernate.c3p0.max_statements">50</prop>
               <!–
               <prop key="hibernate.connection.autocommit">false</prop>
                –>
             </props>
       </property>
       
       <property name="annotatedClasses">
         <list>
            <value>com.jyh.its.model.account.Account</value>
            <value>com.jyh.its.model.file.UploadedContent</value>
            <value>com.jyh.its.model.group.Group</value>
            <value>com.jyh.its.model.project.Project</value>
            <value>com.jyh.its.model.prop.LogItem</value>
            <value>com.jyh.its.model.prop.Address</value>
            <value>com.jyh.its.model.ticket.Ticket</value>
         </list>
       </property>
   </bean>

My transaction manager looks like this

<bean id="txManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <property name="dataSource" ref="dataSource" />
</bean>

<tx:annotation-driven transaction-manager="txManager"/>

My Activiti configuration looks like this

<bean id="initProcessEngines" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
       <property name="staticMethod" value="org.activiti.engine.ProcessEngines.init"/>
   </bean>

   <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean" depends-on="initProcessEngines">
       <property name="processEngineConfiguration">
           <bean class="org.activiti.spring.SpringProcessEngineConfiguration">
               <property name="databaseType" value="mysql" />
               <property name="dataSource" ref="dataSource" />
               <property name="transactionManager" ref="txManager" />
               <property name="databaseSchemaUpdate" value="none" />
               <property name="jobExecutorActivate" value="false" />
               <property name="deploymentResources" value="classpath*:diagram/Ticketing.bpmn20.xml" />
              <property name="transactionsExternallyManaged" value="true" />
           </bean>
       </property>
   </bean>

I am using Activiti 5.9 with Spring 3.1.1.Final and Hibernate 4.1.7.Final.
Here are the related dependencies from POM

     <dependency>
      <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-expression</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-tx</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-jdbc</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${org.springframework.version}</version>
   </dependency>
   
   <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-support</artifactId>
      <version>2.0</version>
   </dependency>

   <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.1.7.Final</version>
   </dependency>
   
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-ehcache</artifactId>
      <version>4.1.7.Final</version>
   </dependency>
           
   <dependency>
      <groupId>org.hibernate.common</groupId>
      <artifactId>hibernate-commons-annotations</artifactId>
      <version>4.0.1.Final</version>
   </dependency>
   
   <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
   </dependency>
   
   <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.7</version>
   </dependency>

     <dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-engine</artifactId>
   <version>${activiti-version}</version>
  </dependency>
  <dependency>
   <groupId>org.activiti</groupId>
   <artifactId>activiti-spring</artifactId>
   <version>${activiti-version}</version>
  </dependency>
  <dependency>
   <groupId>hsqldb</groupId>
   <artifactId>hsqldb</artifactId>
   <version>1.8.0.7</version>
  </dependency>
  <dependency>
   <groupId>com.h2database</groupId>
   <artifactId>h2</artifactId>
   <version>1.2.132</version>
  </dependency>
  <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>1.7.5</version>
  </dependency>
     
     
     <dependency>
   <groupId>javassist</groupId>
   <artifactId>javassist</artifactId>
   <version>3.12.1.GA</version>

I would appreciate if anyone can help me find the cause of this problem. It's really giving me a headache.
3 REPLIES 3

davidiamyou
Champ in-the-making
Champ in-the-making
And I just tried to access the processEngine in the web app instead of unit tests. I put a little segment of code inside controller and try to access the page in the browser which will in turn trigger the controller.

It now gives me the same error of NoSuchMethodError.

davidiamyou
Champ in-the-making
Champ in-the-making
Hello All,

After spending some time this morning with the problem, I believe I have resolved the issue.

Apparently, I have an unnecessary dependency

<dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-support</artifactId>
      <version>2.0</version>
   </dependency>
in my POM and it caused conflict with some other packages. Essentially, the executing code was no longer following the expected path anymore.

I removed this dependency and upgraded to Activiti 5.10 and Spring 3.1.2.Final as they are perfectly compatible with each other.

Activiti 5.9 seems to be depending on Spring 3.0.3.Final and I didn't want to take chances.

This solved the issue. Thank you for your time!

jbarrez
Star Contributor
Star Contributor
Thanks for posting back the solution. I would have guessed it was a library issue, but I would have looked for it in Hibernate, not in Spring!