jBPM - 启动流程时无法将 ArrayList 作为参数传递

jBPM - unable to pass ArrayList as parameter while starting process

我们在尝试从 Java 启动 jBPM 工作流时遇到以下错误。

Exception in thread "main" org.kie.remote.client.api.exception.RemoteApiException: IllegalStateException thrown with message 'Could not unmarshall user-defined class instance parameter of type 'jaxbListWrapper'':
java.lang.IllegalStateException: Could not unmarshall user-defined class instance parameter of type 'jaxbListWrapper'
    at org.kie.remote.services.cdi.ProcessRequestBean.verifyObjectHasBeenUnmarshalled(ProcessRequestBean.java:219)
    at org.kie.remote.services.cdi.ProcessRequestBean.checkThatUserDefinedClassesWereUnmarshalled(ProcessRequestBean.java:208)
    at org.kie.remote.services.cdi.ProcessRequestBean.preprocessCommand(ProcessRequestBean.java:183)
    at org.kie.remote.services.cdi.ProcessRequestBean.processCommand(ProcessRequestBean.java:133)
    at org.kie.remote.services.cdi.ProcessRequestBean$Proxy$_$$_WeldClientProxy.processCommand(Unknown Source)
    at org.kie.remote.services.rest.ResourceBase.restProcessJaxbCommandsRequest(ResourceBase.java:153)
    at org.kie.remote.services.rest.ExecuteResourceImpl.execute(ExecuteResourceImpl.java:30)
    at org.kie.remote.services.rest.ExecuteResourceImpl$Proxy$_$$_WeldClientProxy.execute(Unknown Source)
    at sun.reflect.GeneratedMethodAccessor236.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:137)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:296)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:250)
    at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:237)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:356)
    at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
    at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
    at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:130)
    at org.kie.remote.services.rest.jaxb.DynamicJaxbContextFilter.doFilter(DynamicJaxbContextFilter.java:45)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at org.uberfire.ext.security.server.BasicAuthSecurityFilter.doFilter(BasicAuthSecurityFilter.java:53)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at org.uberfire.ext.security.server.SecureHeadersFilter.doFilter(SecureHeadersFilter.java:53)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at org.uberfire.ext.security.server.SecurityIntegrationFilter.doFilter(SecurityIntegrationFilter.java:64)
    at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60)
    at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
    at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
    at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
    at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
    at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
    at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
    at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
    at io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
    at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
    at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
    at io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
    at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
    at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
    at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
    at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
    at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
    at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
    at io.undertow.servlet.handlers.ServletInitialHandler.access[=10=]0(ServletInitialHandler.java:73)
    at io.undertow.servlet.handlers.ServletInitialHandler.handleRequest(ServletInitialHandler.java:146)
    at io.undertow.server.Connectors.executeRootHandler(Connectors.java:177)
    at io.undertow.server.HttpServerExchange.run(HttpServerExchange.java:727)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)

    at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeRestCommand(AbstractRemoteCommandObject.java:457)
    at org.kie.services.client.api.command.AbstractRemoteCommandObject.executeCommand(AbstractRemoteCommandObject.java:128)
    at org.kie.services.client.api.command.KieSessionClientCommandObject.startProcess(KieSessionClientCommandObject.java:257)
    at com.aia.poc.jbpmclient.App.startProcess(App.java:62)
    at com.aia.poc.jbpmclient.App.main(App.java:27)

流程接受类型为java.util.List的参数,在bpmn文件的流程变量中定义相同。

正在使用以下代码启动进程。

public static void startProcess() throws MalformedURLException {
        KieSession kSession = connManager.getKieSession(DEPLOYMENT_ID, USER_ID,
                PASSWORD);

        Map<String, Object> params = new HashMap<String, Object>();

        List<String> listOfUsers = new ArrayList<String>();
        listOfUsers.add("admin");
        listOfUsers.add("pavan");

        params.put("list_of_users", listOfUsers);

        kSession.startProcess("com.sample.bpmn", params);

    }

正在正确建立连接,我们可以使用 null 作为参数触发进程。

这似乎是一个已知问题。以下链接提供了两种解决方案。

https://developer.jboss.org/thread/250636

https://developer.jboss.org/thread/249814

我正在使用 jBPM 6.2 并使用启动事件向流程发送信号(请注意,我不调用 startProcess,但我调用 signalEvent)在提供​​ ArrayList 作为参数时工作正常。

    KieHelper kieHelper = new KieHelper();
    KieBase kieBase = kieHelper.addResource(ResourceFactory.newClassPathResource("workflow.bpmn2")).build();

    KieSession ksession = kieBase.newKieSession();

    // Added some service task listeners etc...

    ArrayList<CustomObject> signalData = new ArrayList<CustomObject>();
    CustomObject argument1 = new CustomObject();
    CustomObject argument2 = new CustomObject();
    signalData.add(argument1);
    signalData.add(argument2);

    ksession.signalEvent("EventName", signalData);

实际上,发信号通知进程启动与调用 start 方法没有太大区别。不过在这种情况下可能会有所不同...

希望我有所帮助!