0

我在本地服务器上安装了新版本的 Drools 规则引擎(7.36)我已经在本地主机 Tomcat 8 上部署了 KIE Workbench 和 KIE Server(我目前正在使用 Workbench 7.11,因为较新的版本没有webc版本用于 Tomcat 部署)

我设法配置了服务器,并部署了一个规则项目。它的运行时策略设置为PER REQUEST ,因为它的 KieSessions在kmodule.xml 中设置为无状态

然后我写了一个客户端来调用这个服务器,它工作了几分钟。在那之后(我认为,他们将是 10 分钟)每隔一个请求,无论如何都会抛出一个 ClassCastException。如果我重新启动部署单元,它会再工作 10 分钟。

这是例外:

20-Apr-2020 17:29:49.205 GRAVE [http-nio-8080-exec-2] org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl.callContainer Error calling container 'PruebaDrools'
    java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to org.kie.api.command.Command
            at org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl.callContainer(DroolsKieContainerCommandServiceImpl.java:60)
            at org.kie.server.remote.rest.drools.CommandResource.manageContainer(CommandResource.java:91)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.lang.reflect.Method.invoke(Method.java:498)
            at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
            at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:509)
            at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:399)
            at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$0(ResourceMethodInvoker.java:363)
            at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
            at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:365)
            at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:337)
            at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:310)
            at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:443)
            at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:233)
            at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:139)
            at org.jboss.resteasy.core.interception.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:358)
            at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:142)
            at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:219)
            at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:227)
            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:741)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.kie.server.services.impl.security.web.CaptureHttpRequestFilter.doFilter(CaptureHttpRequestFilter.java:42)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:668)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
            at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
            at org.kie.integration.tomcat.JACCValve.invoke(JACCValve.java:113)
            at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
            at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
            at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
            at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
            at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
            at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
            at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
            at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
            at java.lang.Thread.run(Thread.java:748)

这是我的客户:

public class MyConfigurationObject {

private static final String URL = "http://localhost:8080/kie-server/services/rest/server";
private static final String USER = "kieserver";
private static final String PASSWORD = "kieserver1!";

private static final String CONTAINER_ID = "PruebaDrools";
private static final String SESSION_ID = "ksession-dtables";

private static Marshaller xStreamXml;
private static KieServicesConfiguration conf;
private static KieServicesClient client;
private static RuleServicesClient ruleClient;


public static void initialize() {

    conf = KieServicesFactory.newRestConfiguration(URL, USER, PASSWORD);
    conf.setMarshallingFormat(MarshallingFormat.JSON);

    Set<Class<?>> allClasses = new HashSet<Class<?>>();
    allClasses.add(MyClass.class);
    conf.addExtraClasses(allClasses);

    xStreamXml = MarshallerFactory.getMarshaller(allClasses, MarshallingFormat.JSON, MyConfigurationObject.class.getClassLoader());


    client  = KieServicesFactory.newKieServicesClient(conf);
    ruleClient = client.getServicesClient(RuleServicesClient.class);
}

//Para la version 7.36
public static void sendCommands() {
    BatchExecutionCommandImpl command = new BatchExecutionCommandImpl(new ArrayList<Command>());
    command.setLookup(SESSION_ID);

    InsertObjectCommand insertObjectCommand = new InsertObjectCommand("banana");
    FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();

    command.getCommands().add(insertObjectCommand);
    command.getCommands().add(fireAllRulesCommand);

    ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID,command);
    System.out.println(response.getResult());
}

//Para la version 7.36
public static void sendCommands(Object[] args) {

    InsertObjectCommand insertObjectCommand = new InsertObjectCommand("enviar");

    InsertElementsCommand insertElementsCommand = new InsertElementsCommand(Arrays.asList(args));
    insertElementsCommand.setOutIdentifier("denuncia");

    FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
    GetObjectsCommand getObjectsCommand = new GetObjectsCommand();
    getObjectsCommand.setOutIdentifier("denuncia");

    //Dispose session
    DisposeCommand disposeCommand = new DisposeCommand();

    KieCommands commandsFactory = KieServices.Factory.get().getCommands();
    List<Command<?>> commands = new ArrayList<Command<?>>();
    BatchExecutionCommand executionCommand = commandsFactory.newBatchExecution(commands, SESSION_ID);

    commands.add(insertObjectCommand);
    commands.add(insertElementsCommand);
    commands.add(fireAllRulesCommand);
    commands.add(getObjectsCommand);
    commands.add(disposeCommand);



    ServiceResponse<ExecutionResults> response = ruleClient.executeCommandsWithResults(CONTAINER_ID, xStreamXml.marshall(executionCommand));
    System.out.println(xStreamXml.marshall(response.getResult().getValue("denuncia")));
}

MyConfigurationObject在一个类中使用,首先调用它的静态方法,initialize()然后sendCommands()用我的对象作为参数

我发现这个异常很笼统,可能是由很多原因引起的,但是日志不会提供任何关于发生了什么的额外信息

我错过了什么吗?

4

0 回答 0