OptaPlanner执行服务器无法将string()转换为type(java.time.LocalDateTime)

时间:2018-01-10 03:20:28

标签: rest optaplanner

尝试设置员工排班"试用样品"来自Workbench并尝试通过REST API访问解决方案。 我在使用POST上传我的数据集时遇到了一个问题,我在下面详细列出了我尝试和面对的内容。

在此之前,当我注册(PUT)我的求解器config.xml时,我将NOT_SOLVING作为状态。这是我们将获得的实际状态吗?

错误是解析日期格式。

<startTime>2017-01-01T00:00</startTime>

并尝试了不同的格式,如下所示,但它没有帮助。

 <startTime>2017-01-01 00:00</startTime>

环境详情:

wildfly-10.0.0.Final
kie-server(Execution Server) - 7.5.0.Final 
Workbenck(for WildFly10)

PUT:http://localhost:8080/kie-server/services/rest/server/containers/employeerostering/solvers/employeerosteringSolver

RequestBody:

<solver-instance>
  <solver-config-file>employeerostering/employeerostering/EmployeeRosteringSolverConfig.solver.xml</solver-config-file>
</solver-instance>

获取:http://localhost:8080/kie-server/services/rest/server/containers/employeerostering/solvers/employeerosteringSolver/bestsolution

收到回复:

<solver-instance>
  <container-id>employeerostering</container-id>
  <solver-id>employeerosteringSolver</solver-id>
  <solver-config-file>employeerostering/employeerostering/EmployeeRosteringSolverConfig.solver.xml</solver-config-file>
  <status>NOT_SOLVING</status>
  <score />
</solver-instance>

POST:http://localhost:8080/kie-server/services/rest/server/containers/employeerostering/solvers/employeerosteringSolver/state/solving

RequestBody:

<planning-problem class="employeerostering.employeerostering.EmployeeRoster">
  <employeeList>
    <employeerostering.employeerostering.Employee>
      <name>John</name>
      <skills>
        <employeerostering.employeerostering.Skill>
          <name>consulting</name>
        </employeerostering.employeerostering.Skill>
        <employeerostering.employeerostering.Skill>
          <name>translation</name>
        </employeerostering.employeerostering.Skill>
      </skills>
    </employeerostering.employeerostering.Employee>
    <employeerostering.employeerostering.Employee>
      <name>Ann</name>
      <skills>
        <employeerostering.employeerostering.Skill reference="../../../employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
      </skills>
    </employeerostering.employeerostering.Employee>
    <employeerostering.employeerostering.Employee>
      <name>Paul</name>
      <skills>
        <employeerostering.employeerostering.Skill>
          <name>maintenance</name>
        </employeerostering.employeerostering.Skill>
      </skills>
    </employeerostering.employeerostering.Employee>
    <employeerostering.employeerostering.Employee>
      <name>Carla</name>
      <skills>
        <employeerostering.employeerostering.Skill reference="../../../employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
        <employeerostering.employeerostering.Skill reference="../../../employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
      </skills>
    </employeerostering.employeerostering.Employee>
    <employeerostering.employeerostering.Employee>
      <name>Brian</name>
      <skills>
        <employeerostering.employeerostering.Skill reference="../../../employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
      </skills>
    </employeerostering.employeerostering.Employee>
    <employeerostering.employeerostering.Employee>
      <name>Unskilled</name>
      <skills class="empty-list"/>
    </employeerostering.employeerostering.Employee>
  </employeeList>
  <shiftList>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-01T00:00</startTime>
        <endTime>2017-01-01T07:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-01T08:00</startTime>
        <endTime>2017-01-01T15:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-01T16:00</startTime>
        <endTime>2017-01-01T23:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-02T00:00</startTime>
        <endTime>2017-01-02T07:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-02T08:00</startTime>
        <endTime>2017-01-02T15:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-02T16:00</startTime>
        <endTime>2017-01-02T23:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-03T00:00</startTime>
        <endTime>2017-01-03T07:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-03T08:00</startTime>
        <endTime>2017-01-03T15:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-03T16:00</startTime>
        <endTime>2017-01-03T23:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-04T00:00</startTime>
        <endTime>2017-01-04T07:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-04T08:00</startTime>
        <endTime>2017-01-04T15:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-04T16:00</startTime>
        <endTime>2017-01-04T23:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-05T00:00</startTime>
        <endTime>2017-01-05T07:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-05T08:00</startTime>
        <endTime>2017-01-05T15:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
    <employeerostering.employeerostering.Shift>
      <timeslot>
        <startTime>2017-01-05T16:00</startTime>
        <endTime>2017-01-05T23:59</endTime>
      </timeslot>
      <requiredSkill reference="../../../employeeList/employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
    </employeerostering.employeerostering.Shift>
  </shiftList>
  <skillList>
    <employeerostering.employeerostering.Skill reference="../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill"/>
    <employeerostering.employeerostering.Skill reference="../../employeeList/employeerostering.employeerostering.Employee/skills/employeerostering.employeerostering.Skill[2]"/>
    <employeerostering.employeerostering.Skill reference="../../employeeList/employeerostering.employeerostering.Employee[3]/skills/employeerostering.employeerostering.Skill"/>
  </skillList>
  <timeslotList>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[2]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[3]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[4]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[5]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[6]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[7]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[8]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[9]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[10]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[11]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[12]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[13]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[14]/timeslot"/>
    <employeerostering.employeerostering.Timeslot reference="../../shiftList/employeerostering.employeerostering.Shift[15]/timeslot"/>
  </timeslotList>
  <shiftAssignmentList>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[2]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[3]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[4]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[5]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[6]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[7]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[8]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[9]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[10]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[11]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[12]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[13]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[14]"/>
    </employeerostering.employeerostering.ShiftAssignment>
    <employeerostering.employeerostering.ShiftAssignment>
      <shift reference="../../../shiftList/employeerostering.employeerostering.Shift[15]"/>
    </employeerostering.employeerostering.ShiftAssignment>
  </shiftAssignmentList>
  <dayOffRequestList>
    <employeerostering.employeerostering.DayOffRequest>
      <employee reference="../../../employeeList/employeerostering.employeerostering.Employee"/>
      <date>2017-01-01</date>
    </employeerostering.employeerostering.DayOffRequest>
    <employeerostering.employeerostering.DayOffRequest>
      <employee reference="../../../employeeList/employeerostering.employeerostering.Employee[2]"/>
      <date>2017-01-02</date>
    </employeerostering.employeerostering.DayOffRequest>
  </dayOffRequestList>
</planning-problem>

收到响应:500内部服务器错误

以下是从控制台捕获的日志。

 -------------------------------: com.thoughtworks.xstream.converters.ConversionException: 
---- Debugging information ----
cause-exception     : java.lang.IllegalStateException
cause-message       : Failed to convert string (2017-01-01 00:00) to type (java.time.LocalDateTime).
class               : java.time.LocalDateTime
required-type       : java.time.LocalDateTime
converter-type      : org.kie.soup.commons.xstream.LocalDateTimeXStreamConverter
path                : /planning-problem/shiftList/employeerostering.employeerostering.Shift/timeslot/startTime
line number         : 49
class[1]            : employeerostering.employeerostering.Timeslot
converter-type[1]   : com.thoughtworks.xstream.converters.reflection.ReflectionConverter
class[2]            : employeerostering.employeerostering.Shift
class[3]            : java.util.ArrayList
converter-type[2]   : com.thoughtworks.xstream.converters.collections.CollectionConverter
class[4]            : employeerostering.employeerostering.EmployeeRoster
version             : 7.5.0.Final

2 个答案:

答案 0 :(得分:0)

问题在于给出了dateformat。我通过反编译导致问题的罐子来完成。

实际上它所期望的日期格式是:

<startTime>2017-01-01T16:00:01.001</startTime>

但我在许多例子中看到的是:

<startTime>2017-01-01T00:00</startTime>

答案 1 :(得分:0)

在Optaplanner 7.9.0上,此示例存在相同的问题,但错误有所不同

  

“处理期间发生意外错误:无法解组输入字符串”

提交的解决方案xml是从这篇jboss文章中复制的(如果使用上述xml,则会出现相同的错误)。