过去1天我一直试图解决这个问题,但我无法解决。
Iam从游戏模型中触发了drools(规则)。它在我当地的环境中工作得非常好。
但是,当iam在solaris盒上部署相同的应用程序时,会出现以下错误
Error = Unable to resolve ObjectType 'Tracker' : [Rule name='PM APPROVAL']
Unable to resolve ObjectType 'User' : [Rule name='SEND MAILS']
Unable to resolve ObjectType 'Tracker' : [Rule name='SEND MAILS']
Error importing : 'models.Tracker'Error importing : 'notifications.TrackerMails'Error importing : 'models.User'Rule Compilation error : [Rule name='SEND MAILS']
drools/Rule_SEND_MAILS_0.java (2:23) : Only a type can be imported. notifications.TrackerMails resolves to a package
drools/Rule_SEND_MAILS_0.java (2:57) : Only a type can be imported. models.Tracker resolves to a package
drools/Rule_SEND_MAILS_0.java (2:95) : Only a type can be imported. models.User resolves to a package
drools/Rule_SEND_MAILS_0.java (8:422) : TrackerMails cannot be resolved
drools/Rule_SEND_MAILS_0.java (8:455) : $user cannot be resolved to a variable
drools/Rule_SEND_MAILS_0.java (8:461) : $tracker cannot be resolved to a variable
获取drooolssession的示例代码。我通过查看某些论坛添加了变量classLoader,但仍然没有解决问题。
StatefulKnowledgeSession dsession = null;
ClassLoader classLoader = TrackerUtil.class.getClassLoader();
KnowledgeBuilderConfiguration kBuilderConfiguration = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null, classLoader);
KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(kBuilderConfiguration);
KnowledgeBaseConfiguration kbaseConfig = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(null, classLoader);
'''''
builder.add(ResourceFactory.newFileResource(new File(uri)),ResourceType.DRL);
''''
builder.add(ResourceFactory.newFileResource(new File(uri)),ResourceType.DRF);
.......
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConfig);
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
dsession = knowledgeBase.newStatefulKnowledgeSession();
return dsession;
任何人都可以请求帮助我如何解决这个问题?
答案 0 :(得分:1)
最后我在两天的努力后解决了问题!!
问题来自于Drools无法解决播放模型。在eclipse中,它可以正常工作,因为它将类别路径添加到类路径中。但是每当你运行“播放运行”时,drools就无法找到播放。为了克服这个问题,我们需要在类路径中添加“tmp / classes”。
以下是我们添加
的方法在方法中找到行 classpath.append(os.path.normpath(os.path.join(self.path,'conf')))行下面添加以下内容行
classpath.append(os.path.normpath(os.path.join(os.path.join(self.path, 'tmp'),'classes')))
现在drools可以找到游戏模型。一切都很好。
解决方案2
你可以调用下面的播放服务器
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -Dplay.debug=yes -Dplay.id= -Dapplication.path=/home/przemek/pn -Djava.endorsed.dirs=/opt/play/framework/endorsed -javaagent:/opt/play/framework/play-1.2.4.jar -Dfile.encoding=UTF-8 -classpath "Play computed classpath" and path to tmp classes Play.server.Server
即使上面的工作也很好。你可以通过运行命令play classpath获得play计算类路径。对于classpath,linux中的分隔符是“:”而在windows中它是“;”
以上解决方案有效但我真的不明白为什么这部分? 游戏是如何解决模型的,因为drools无法解析相同的模型?
如果您知道上述答案,请告诉我。