Details

    • Type: Bug
    • Status: Verified (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 6.x.x
    • Fix Version/s: 7.0.0.GA
    • Component/s: BRE
    • Labels:
    • Environment:
      • kie-server without business-central
    • Target Release:
    • Steps to Reproduce:
      Hide
      • Unzip date-test.zip
      • cd date-test
      • mvn clean install
      • Set up kie-server.war on EAP (without business-central)
      • Start the EAP
      • Create a container with groupId "example", artifactId "date-test", version "1.0"
      • Insert a fact to the container.

      for example)
      POST request to 'http://localhost:8080/kie-server/services/rest/server/containers/instances/example:date-test:1.0' with payload

      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <batch-execution>
          <insert out-identifier="fact-1" return-object="true" entry-point="DEFAULT" disconnected="false">
              <object xsi:type="person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <name>John</name>
              </object>
          </insert>
          <fire-all-rules max="-1" out-identifier="fire-result"/>
      </batch-execution>
      
      • Server will throw the ERROR
      Show
      Unzip date-test.zip cd date-test mvn clean install Set up kie-server.war on EAP (without business-central) Start the EAP Create a container with groupId "example", artifactId "date-test", version "1.0" Insert a fact to the container. for example) POST request to 'http://localhost:8080/kie-server/services/rest/server/containers/instances/example:date-test:1.0' with payload <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <batch-execution> <insert out-identifier="fact-1" return-object="true" entry-point="DEFAULT" disconnected="false"> <object xsi:type="person" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <name>John</name> </object> </insert> <fire-all-rules max="-1" out-identifier="fire-result"/> </batch-execution> Server will throw the ERROR
    • Workaround:
      Workaround Exists
    • Workaround Description:
      • Set system property "drools.dateformat" with "dd-MMM-yyyy"

      Description

      When your GDST's RHS contains Date (e.g. set a Date value to a fact), the code below is automatically generated during package build.

        then
          java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MMM-yyyy");
          ...
      

      https://github.com/kiegroup/drools/blob/6.5.0.Final/drools-workbench-models/drools-workbench-models-commons/src/main/java/org/drools/workbench/models/commons/backend/rule/RuleModelDRLPersistenceImpl.java#L369

      If system property "drools.dateformat" is not set (e.g. kie-server), it becomes "null":

        then
          java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("null");
          ...
      

      So results in the following ERROR.

      16:41:06,755 ERROR [org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl] (http-127.0.0.1:8080-2) Error calling container 'example:date-test:1.0': Exception executing consequence for rule "Row 1 BirthDayDT" in example: [Error: could not create constructor: null]
      [Near : {... ateFormat sdf = new java.text.SimpleDateFormat("nu ....}]
                                       ^
      [Line: 1, Column: 38]
      	at org.drools.core.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1065) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.phreak.RuleExecutor.fire(RuleExecutor.java:121) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.phreak.RuleExecutor.evaluateNetworkAndFire(RuleExecutor.java:74) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:972) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.common.DefaultAgenda.fireLoop(DefaultAgenda.java:1315) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1254) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.internalFireAllRules(StatefulKnowledgeSessionImpl.java:1365) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1356) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:1337) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:111) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.command.runtime.rule.FireAllRulesCommand.execute(FireAllRulesCommand.java:36) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:138) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.command.runtime.BatchExecutionCommandImpl.execute(BatchExecutionCommandImpl.java:51) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:747) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.impl.StatefulKnowledgeSessionImpl.execute(StatefulKnowledgeSessionImpl.java:721) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.kie.server.services.drools.RulesExecutionService.call(RulesExecutionService.java:52) [kie-server-services-drools-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.kie.server.services.drools.DroolsKieContainerCommandServiceImpl.callContainer(DroolsKieContainerCommandServiceImpl.java:69) [kie-server-services-drools-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	...
      Caused by: [Error: could not create constructor: null]
      [Near : {... ateFormat sdf = new java.text.SimpleDateFormat("nu ....}]
                                       ^
      [Line: 1, Column: 38]
      	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeObjectCreation(ReflectiveAccessorOptimizer.java:1245) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.ast.NewObjectNode.getReducedValueAccelerated(NewObjectNode.java:218) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.compiler.ExecutableAccessor.getValue(ExecutableAccessor.java:38) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.ast.TypedVarNode.getReducedValueAccelerated(TypedVarNode.java:70) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.MVELRuntime.execute(MVELRuntime.java:85) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.compiler.CompiledExpression.getDirectValue(CompiledExpression.java:123) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:119) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.compiler.CompiledExpression.getValue(CompiledExpression.java:113) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.MVEL.executeExpression(MVEL.java:929) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.drools.core.base.mvel.MVELConsequence.evaluate(MVELConsequence.java:110) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	at org.drools.core.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1054) [drools-core-6.5.0.Final-redhat-17.jar:6.5.0.Final-redhat-17]
      	... 46 more
      Caused by: java.lang.reflect.InvocationTargetException
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [rt.jar:1.8.0_66]
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [rt.jar:1.8.0_66]
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [rt.jar:1.8.0_66]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:422) [rt.jar:1.8.0_66]
      	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.compileConstructor(ReflectiveAccessorOptimizer.java:1306) [mvel2-2.2.8.Final-redhat-1.jar:]
      	at org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.optimizeObjectCreation(ReflectiveAccessorOptimizer.java:1236) [mvel2-2.2.8.Final-redhat-1.jar:]
      	... 56 more
      Caused by: java.lang.IllegalArgumentException: Illegal pattern character 'n'
      	at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:826) [rt.jar:1.8.0_66]
      	at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:634) [rt.jar:1.8.0_66]
      	at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:605) [rt.jar:1.8.0_66]
      	at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:580) [rt.jar:1.8.0_66]
      	... 62 more
      

      Although setting the system property is a valid solution, I think the code should have a good default.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Rikkola Toni Rikkola
                Reporter:
                tkobayashi Toshiya Kobayashi
                Tester:
                Tibor Zimanyi
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: