代码是:
public void showTask() throws Exception{
URL direccion = new URL("http://"+ip +":"+port+"/business-central");
RuntimeEngine engine=RemoteRuntimeEngineFactory.newRestBuilder()
.addUrl(direccion)
.addDeploymentId(deploymentID)
.addUserName(usuario)
.addPassword(pass)
.build();
KieSession ksession = engine.getKieSession();
TaskService taskService = engine.getTaskService();
AuditService a=engine.getAuditService();
System.out.println(taskService.getTaskById(158).getName());
POM是:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ApiRestJBPM</groupId>
<artifactId>ApiRestJBPM</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>ApiRestJBPM</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jbpm.version>6.2.0.Final-redhat-4</jbpm.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.4</version>
</dependency>
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-remote-naming</artifactId>
<version>2.0.4.Final</version>
</dependency>
<dependency>
<groupId>org.kie.remote</groupId>
<artifactId>kie-remote-client</artifactId>
<version>6.2.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie.remote</groupId>
<artifactId>kie-services-client</artifactId>
<version>6.1.0.Final</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jboss-public-repository</id>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>rh-repository</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
</repository>
</repositories>
</project>
错误是:
[main] ERROR org.kie.services.client.api.command.AbstractRemoteCommandObject - Unable to retrieve response content from request with status org.kie.services.client.serialization.jaxb.impl.JaxbRestRequestException cannot be cast to org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse: java.lang.ClassCastException: org.kie.services.client.serialization.jaxb.impl.JaxbRestRequestException cannot be cast to org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse
org.kie.remote.client.api.exception.RemoteCommunicationException: Unable to retrieve content from response!
at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:427)
at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeCommand(AbstractRemoteCommandObject.java:128)
at org.kie.services.client.api.command.TaskServiceClientCommandObject.getTaskById(TaskServiceClientCommandObject.java:314)
Caused by: java.lang.ClassCastException: org.kie.services.client.serialization.jaxb.impl.JaxbRestRequestException cannot be cast to org.kie.services.client.serialization.jaxb.rest.JaxbExceptionResponse
at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:411)
... 4 more
答案 0 :(得分:0)
I think it is the user/pass wrong error or the role of user for rest is not there - role is "rest-all"
Kind regards