jbpm 6远程休息api与spring boot集成

时间:2015-08-02 05:42:59

标签: rest spring-boot jbpm

我正在尝试创建一个jbpm + angular + springboot应用程序。

api文档的想法在这里:

https://developer.jboss.org/people/bpmn2user/blog/2014/01/11/jbpm6--angular-js-web-example

远程集成文档:

http://docs.jboss.org/jbpm/v6.0/userguide/jBPMRemoteAPI.html

我的春季启动控制器:

 package org.jbpm.spring.boot;

import java.net.URL;

import org.jbpm.services.api.model.UserTaskInstanceDesc;
import org.kie.api.runtime.KieSession;
import org.kie.api.runtime.manager.RuntimeEngine;
import org.kie.api.runtime.process.ProcessInstance;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/task")
public class RestController {


    @RequestMapping(value = "/show", method = RequestMethod.GET)
    public UserTaskInstanceDesc getTask(@RequestParam String id) {
        String deploymentId="id";
        URL deploymentUrl=new URL("http://localhost:8080/jbpm-console/");
        String user="user";
        String password="password";


         RemoteRestSessionFactory restSessionFactory 

            = new RemoteRestSessionFactory(deploymentId, deploymentUrl, user, password);

          RuntimeEngine engine = restSessionFactory.newRuntimeEngine();

          KieSession ksession = engine.getKieSession();

          ProcessInstance processInstance = ksession.startProcess("org.jbpm.humantask");


    }

}

由于某种原因" RemoteRestSessionFactory"不能解决类型我的pom看起来像这样:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.jbpm.spring</groupId>
  <artifactId>spring-boot-jbpm</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>spring-boot-jbpm</name>
  <description>jBPM with spring boot</description>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.1.9.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
  </parent>


  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <start-class>org.jbpm.spring.boot.Application</start-class>
    <java.version>1.7</java.version>
    <drools.version>6.2.0.Final</drools.version>
    <jbpm.version>6.2.0.Final</jbpm.version>
    <app.version>0.0.1-SNAPSHOT</app.version>

    <hibernate.version>4.2.0.Final</hibernate.version>
    <hibernate.core.version>4.2.0.Final</hibernate.core.version>
    <slf4j.version>1.6.4</slf4j.version>
    <jboss.javaee.version>1.0.0.Final</jboss.javaee.version>
    <logback.version>1.0.9</logback.version>
    <h2.version>1.3.161</h2.version>
    <btm.version>2.1.4</btm.version>
  </properties>


  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
      <exclusions>
        <exclusion>
          <artifactId>jul-to-slf4j</artifactId>
          <groupId>org.slf4j</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-api</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-internal</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-core</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-compiler</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.drools</groupId>
      <artifactId>drools-persistence-jpa</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-flow</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-flow-builder</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-bpmn2</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-audit</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-persistence-jpa</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-human-task-core</artifactId>
      <version>${jbpm.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>jboss-annotations-api_1.1_spec</artifactId>
          <groupId>org.jboss.spec.javax.annotation</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-human-task-jpa</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-human-task-workitems</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-human-task-audit</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-runtime-manager</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-services-api</artifactId>
      <version>${jbpm.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-kie-services</artifactId>
      <version>${jbpm.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>freemarker</artifactId>
          <groupId>org.freemarker</groupId>
        </exclusion>
        <exclusion>
          <artifactId>javassist</artifactId>
          <groupId>javassist</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.jbpm</groupId>
      <artifactId>jbpm-workitems</artifactId>
      <version>${jbpm.version}</version>
    </dependency>

    <dependency>
      <groupId>org.kie</groupId>
      <artifactId>kie-spring</artifactId>
      <version>${jbpm.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>drools-decisiontables</artifactId>
          <groupId>org.drools</groupId>
        </exclusion>
        <exclusion>
          <artifactId>drools-templates</artifactId>
          <groupId>org.drools</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
    </dependency>

    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-entitymanager</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>${hibernate.version}</version>
    </dependency>
    <dependency>
      <groupId>com.h2database</groupId>
      <artifactId>h2</artifactId>
    </dependency>
    <dependency>
      <groupId>org.codehaus.btm</groupId>
      <artifactId>btm</artifactId>
      <version>${btm.version}</version>
      <exclusions>
        <exclusion>
          <artifactId>jta</artifactId>
          <groupId>javax.transaction</groupId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- test dependencies -->
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <exclusions>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.5</version>
        </dependency>
            <dependency>
    <groupId>org.kie</groupId>
    <artifactId>kie-server-client</artifactId>
    <version>6.2.0.Final</version>
</dependency>
<dependency>
    <groupId>org.kie.workbench.services</groupId>
    <artifactId>kie-wb-common-services-api</artifactId>
    <version>6.2.0.Final</version>
</dependency>
      </dependencies>


  <build>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

</project>

我该如何解决这个问题?

2 个答案:

答案 0 :(得分:2)

kie-services-client中缺少pom.xml个库。

<dependency>
    <groupId>org.kie.remote</groupId>
    <artifactId>kie-services-client</artifactId>
    <version>6.1.0.Final</version>
</dependency>

在最新版本中,班级RemoteRestSessionFactory已替换为RemoteRestRuntimeFactory。如果您仍想使用RemoteRestSessionFactory,则应使用<version>6.0.0.CR5</version>。但不建议这样做。

答案 1 :(得分:1)

  1. 您没有在RestController中导入org.kie.services.client.api.RemoteRestSessionFactory
  2. 您没有在pom文件中导入org.kie:kie-server-client:6.2.0.Final