【问题标题】:XStream error using Optaplanner with groovy使用带有 groovy 的 Optaplanner 的 XStream 错误
【发布时间】:2014-05-15 16:20:48
【问题描述】:

我正在尝试将Drool's Cookbook 第 8 章中的一个简单 Drools Planner 示例改编为 OptaPlanner 6.0.1.Final 使用 groovy(已经有一个带有 maven 的工作 java 版本),类和测试在一个 groovy 中脚本和solverConfig.xml和solverRules.drl在同一个文件夹下,XmlSolverFactory应该如何配置才能避免:

groovy technicianAssignationScript.groovy
Caught: com.thoughtworks.xstream.io.StreamException: Cannot create XmlPullParser
com.thoughtworks.xstream.io.StreamException: Cannot create XmlPullParser
        at com.thoughtworks.xstream.io.xml.AbstractXppDriver.createReader(AbstractXppDriver.java:56)
        at com.thoughtworks.xstream.XStream.fromXML(XStream.java:1040)
        at org.optaplanner.core.config.solver.XmlSolverFactory.configure(XmlSolverFactory.java:84)
        at org.optaplanner.core.config.solver.XmlSolverFactory.configure(XmlSolverFactory.java:74)
        at org.optaplanner.core.config.solver.XmlSolverFactory.configure(XmlSolverFactory.java:67)
        at org.optaplanner.core.config.solver.XmlSolverFactory$configure.call(Unknown Source)
        at BestAvailableTechnicianTest.findBestTechnician(technicianAssignationScript.groovy:294)
        at BestAvailableTechnicianTest$findBestTechnician.call(Unknown Source)
        at technicianAssignationScript.run(technicianAssignationScript.groovy:379)

我正在使用

groovy -v
Groovy Version: 2.3.0 JVM: 1.7.0_55 Vendor: Oracle Corporation OS: Linux

在脚本中使用此依赖项:

@Grapes([
          @Grab("org.optaplanner:optaplanner-core:6.0.1.Final"),
          @Grab("junit:junit:4.4"),
          @Grab("org.optaplanner:optaplanner-benchmark:6.0.1.Final"),
          // @Grab("commons-lang:commons-lang-2.6"),
          @Grab("org.slf4j:slf4j-api:1.7.2"),
          @Grab("ch.qos.logback:logback-classic:1.0.9"),
          @Grab("com.thoughtworks.xstream:xstream:1.4.3"),
          @Grab("org.jdom:jdom:1.1.3"),
          @Grab("xpp3:xpp3_min:1.1.4c"),
          @Grab("xmlpull:xmlpull:1.1.3.1")
        ])

【问题讨论】:

    标签: groovy xstream optaplanner


    【解决方案1】:

    我在 optaplanner master (6.1.0.Beta4) 上使用 xstream 1.4.7 和 xpp3_min 1.1.4c 和 xmlpull 1.1.3.1。但是 IIRC,optaplanner 6.0.1 使用 xstream 1.4.3,它也应该可以完美运行。

    尝试在 xstream 用户列表上问这个问题:他们在那里回答了很多。

    【讨论】:

    • 我最近有时间创建一个常规的 maven 项目来读取文件并且使用上述依赖项没有错误,所以我怀疑问题是我无法通过 groovy 解决依赖项我的本地 Maven 存储库。
    猜你喜欢
    • 2015-06-18
    • 1970-01-01
    • 2014-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多