使用Drools 5.5.0. Using和Guvnos5.5.0.最后用样本抵押贷款包。
当使用以下批处理执行命令提交REST请求时:
{
"batch-execution": {
"lookup":"ksession1",
"commands":[
{
"insert":{
"out-identifier":"outApplicant",
"return-object":"true",
"object": {
"Applicant":{
"age":17
}
}
}
},
{
"fire-all-rules":""
}
]
}
} 返回: 500内部服务器错误
com.thoughtworks.xstream.converters.ConversionException: Applicant : Applicant
---- Debugging information ----
message : Applicant
cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException
cause-message : Applicant
class : org.drools.command.runtime.rule.InsertObjectCommand
required-type : org.drools.command.runtime.rule.InsertObjectCommand
converter-type : org.drools.runtime.help.impl.XStreamJson$JsonInsertConverter
line number : -1
class[1] : org.drools.command.runtime.BatchExecutionCommandImpl
converter-type[1] : org.drools.runtime.help..XSt...$JsonBatchExecutionCommandConverter
version : null申请人类在XSD中的抵押贷款包中定义如下:
age:Whole number (integer)
applicationDate:Date
creditRating:Text
name:Text
approved:True or False如何告诉drools在哪里找到申请者类?(在抵押贷款示例中定义为XSD文件)
knowledge-services.xml目前看起来如下所示:
<drools:grid-node id="node1"/>
<drools:kbase id="kbase1" node="node1">
<drools:resources>
<drools:resource type="PKG" source="http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/packages/mortgages"/>
</drools:resources>
</drools:kbase>我怀疑将REST json请求更改为完全指定申请者类的包名可能有效。
...
"object": {
"something.somethingelse.Applicant":{
"age":17
}
}
...但似乎找不到申请人的完全限定包名是在哪里声明的?
可接受的答案必须显示一个无需编写java代码的示例,因为REST接口的全部目的是通过web服务接口访问drools。
是否有一种spring配置,或者编写json请求的其他方式可以工作?
发布于 2013-05-24 15:16:44
因为没有人回答,所以我发布了对我有用的答案,以及我用来调试问题的根本原因和逐步过程。如果有更好的方法,请发表意见。
首先,这里是REST请求使用drools-server将申请者实例插入到规则引擎的完整和正确的格式,当模型在界面中定义,而不是上传为POJO模型时。
{
"batch-execution": {
"lookup":"ksession1",
"commands":[
{
"insert":{
"out-identifier":"outApplicant",
"return-object":"true",
"object": {
"mortgages.Applicant":{
"age":17
}
}
}
},
{
"fire-all-rules":""
}
]
}
} $TOMCAT_HOME/webapps/drools-server/WEB-INF/classes/knowledge-services.xml 的根本原因:的资源不正确。
我更正的知识的相关部分-services.xml:
<drools:grid-node id="node1"/>
<drools:kbase id="kbase1" node="node1">
<drools:resources>
<drools:resource
type="PKG"
source="http://localhost:8080/drools-guvnor/rest/packages/mortgages/binary"
basic-authentication="enabled"
username="admin"
password="admin"
/>
</drools:resources>
</drools:kbase>次要问题:在Knowl-services.xml中没有指定身份验证凭据,这导致了这个错误:
Exception: java.io.IOException: Servier returned HTTP response code: 401 for URL: http://localhost:8080/drools-guvnor/rest/packages/mortgages/binary第三期:示例抵押程序包不是作为二进制包在Guvnor中构建的。
ERROR: java.io.lang.RunTimeException: jav.io.StreamCorruptionException: Invalid Stream Header修复:在古沃..。包裹..。mortgages..Edit..build包
附加注意:默认情况下,drools-server中不启用INFO级别日志记录。为了启用额外的日志记录,您可以在$TOMCAT_HOME/log/catalina.log中看到详细的调试消息,请执行以下步骤:
HTH
https://stackoverflow.com/questions/16695954
复制相似问题