java - 与 Activiti 集成时出现 ConversionNotSupportedException

标签 java spring maven activiti

我正在尝试为我的项目与 activiti-engine 集成。我的父pom使用spring 3.1.1

这是我的 pom.xml 中的 activiti 配置:

<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>

这也是我的 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>

以下是我尝试访问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;
      }

但是我遇到了以下情况

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

有人见过类似的问题吗?

最佳答案

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

这意味着(a)您的所需接口(interface)和提供的实现不兼容,或者(b)您遇到一些类加载器问题,其中所需的接口(interface)在不同的类加载器中加载了两次。

还要查看堆栈跟踪中的最后一个异常 - “... 25 more”隐藏了什么

关于java - 与 Activiti 集成时出现 ConversionNotSupportedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26197790/

相关文章:

java - 构建文件夹紧凑树的最佳方法是什么?

spring - spring 请求映射和 url 映射有什么区别?

java - Jersey 和 spring 集成 - bean 注入(inject)在运行时为空

grails - Intellij使用 “mvn grails:exec”而不是原始grails命令

java - 如何为 request.getRequestDispatcher() 指定 .JSP 文件的路径?

java - Gradle 生成的 Scala JAR 出现 "Could not find or load main class"错误

maven - 使用 maven 程序集插件解压 tar 时如何保留符号链接(symbolic link)

java - 使用 Maven Spring 和 Hibernate 的 Java 问题

java - Java 8 lambda 和匿名内部类之间的性能差异

java - Spring 配置文件未正确应用于涉及 @Configurable 的测试