1

I am trying to integrate with activiti-engine for my project. my parent pom uses spring 3.1.1

Here is my activiti config in my pom.xml:

<dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-engine</artifactId>
            <version>5.16.3</version>
            <exclusions>
            <exclusion>
                <artifactId>spring-beans</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>

        </exclusions>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>activiti-spring</artifactId>
            <version>5.16.3</version>
            <exclusions>
            <exclusion>
                <artifactId>spring-context</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            <exclusion>
                <artifactId>spring-jdbc</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            <exclusion>
                <artifactId>spring-orm</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            <exclusion>
                <artifactId>spring-core</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            <exclusion>
                <artifactId>spring-test</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            <exclusion>
                <artifactId>spring-tx</artifactId>
                <groupId>org.springframework</groupId>
            </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.2.132</version>
        </dependency>

Also here is my beans.xml

       <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
        <property name="driverClass" value="org.h2.Driver" />
        <property name="url" value="jdbc:h2:mem:activiti;DB_CLOSE_DELAY=1000" />
        <property name="username" value="sa" />
        <property name="password" value="" />
      </bean>

  <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" />
  </bean>

  <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
    <property name="dataSource" ref="dataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="true" />
    <property name="jobExecutorActivate" value="false" />
  </bean>

  <bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean">
    <property name="processEngineConfiguration" ref="processEngineConfiguration" />
  </bean>

  <bean id="repositoryService" factory-bean="processEngine" factory-method="getRepositoryService" />
  <bean id="runtimeService" factory-bean="processEngine" factory-method="getRuntimeService" />
  <bean id="taskService" factory-bean="processEngine" factory-method="getTaskService" />
  <bean id="historyService" factory-bean="processEngine" factory-method="getHistoryService" />
  <bean id="managementService" factory-bean="processEngine" factory-method="getManagementService" />

    <!-- Implementation class for pricingserv-->
    <bean id="pricingServBean" class="com.paypal.pricing.service.core.PricingServImpl">
    <property name="runtimeService" ref="runtimeService"/>
    </bean>

Following is where I am trying to access runtimeService

   public class PricingServImpl implements PricingServ {

    private static Logger mLogger = Logger.getInstance(PricingServImpl.class);

    private RuntimeService runtimeService;

    public void setRuntimeService(RuntimeService runtimeService) {
        this.runtimeService = runtimeService;
      }

But I run into following

Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property      value of type 'org.activiti.engine.impl.RuntimeServiceImpl' to required type 'org.activiti.engine.RuntimeService' for property 'runtimeService'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.activiti.engine.impl.RuntimeServiceImpl] to required type [org.activiti.engine.RuntimeService] for property 'runtimeService': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:485) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:516) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:510) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1406) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1365) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    ... 19 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.activiti.engine.impl.RuntimeServiceImpl] to required type [org.activiti.engine.RuntimeService] for property 'runtimeService': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:241) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:470) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
    ... 25 more

Has anybody seen a similar issue.

  • What are your initial thoughts about this exception ? Which line causes the exception ? – Erran Morad Oct 04 '14 at 22:51
  • Looks like injecting the bean is causing the issue. I see that getRuntimeService is returning RuntimeServiceImpl's object. Although theoretically it shouldnt create a problem since RuntimeServiceImpl implements RuntimeService – Farheen Noorie Oct 04 '14 at 23:17
  • I don't know if this is any use, but it seems similar to http://stackoverflow.com/q/25205324 - perhaps you can get some clues from the answer there. – Dawood ibn Kareem Oct 04 '14 at 23:28
  • I tried stackoverflow.com/q/25205324 but it didnt work since Activiti doesnt allow autowired fields, also the other workaround is to use aop:config which gives the exact error stated above – Farheen Noorie Oct 06 '14 at 17:20

1 Answers1

1

Cannot convert value of type [org.activiti.engine.impl.RuntimeServiceImpl] to required type [org.activiti.engine.RuntimeService]

It means either (a) your have incompatible required interface & provided implementation or (b) you you have some classloader issue, where required interface is loaded twice in different classloaders.

Also take a look on the last exception in the stacktrace - what is hidden by "... 25 more"

ursa
  • 4,404
  • 1
  • 24
  • 38
  • (a) I am not sure what do you mean by incompatible required interface. Here is the code [RuntimeServiceImpl](http://svn.codehaus.org/activiti/activiti/trunk/modules/activiti-engine/src/main/java/org/activiti/engine/impl/RuntimeServiceImpl.java) and [RuntimeService](http://svn.codehaus.org/activiti/activiti/trunk/modules/activiti-engine/src/main/java/org/activiti/engine/RuntimeService.java). Also for (b) is there a way I can debug that? – Farheen Noorie Oct 06 '14 at 17:24
  • (a) usually this happens when you load incompatible versions of api and runtime, e.g. slf4j-api-1.4.2.jar (instead of 1.7.6) + logback-classic-1.0.12.jar. check actually configured classpath in your IDE. (b) set a breakpoint in your favorite IDE? or I misunderstood your question? – ursa Oct 06 '14 at 20:14
  • Yes spring-beans being ported is 3.1.1 during runtime as well. – Farheen Noorie Oct 06 '14 at 21:07