Playframework 只能导入类型。models.XYZ解析为一个包

Playframework 只能导入类型。models.XYZ解析为一个包,playframework,drools,drools-flow,Playframework,Drools,Drools Flow,在过去的一天里,我一直试图解决这个问题,但我无法解决 我从游戏模型中触发口水(规则)。它在我的本地环境中工作得非常好 但是,当iam在solaris机箱上的生产环境中部署相同的应用程序时,iam会遇到以下错误 Error = Unable to resolve ObjectType 'Tracker' : [Rule name='PM APPROVAL'] Unable to resolve ObjectType 'User' : [Rule name='SEND MAILS'] Unable

在过去的一天里,我一直试图解决这个问题,但我无法解决

我从游戏模型中触发口水(规则)。它在我的本地环境中工作得非常好

但是,当iam在solaris机箱上的生产环境中部署相同的应用程序时,iam会遇到以下错误

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
获取DroolSSession的示例代码。我通过查看一些论坛添加了变量类加载器,但仍然没有解决这个问题

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;

有谁能帮我解决这个问题吗?

经过两天的努力,我终于解决了这个问题

问题在于Drools无法解析播放模型。在eclipse中,它可以很好地将eclipse/类添加到类路径中。但无论何时运行“播放-运行”,Drools都无法找到播放模型。因此,为了克服这一问题,我们需要将“tmp/类”添加到类路径中

下面是我们可以添加的方法

  • 转到播放安装目录转到内部文件夹>>框架>>pym>>播放
  • openapplication.py
  • 转到def getClasspath(self)方法:
  • 在方法中,在行下面找到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是

    您可以像下面这样调用play server

    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计算的类路径。对于类路径,linux中的分隔符是“:”而在windows中它是“;”

    以上解决方案都有效,但我真的不明白为什么? play如何能够解析as drools无法解析相同模型的模型


    如果您知道以上问题的答案,请告诉我。

    经过两天的努力,我终于解决了这个问题

    问题在于Drools无法解析播放模型。在eclipse中,它可以很好地将eclipse/类添加到类路径中。但无论何时运行“播放-运行”,Drools都无法找到播放模型。因此,为了克服这一问题,我们需要将“tmp/类”添加到类路径中

    下面是我们可以添加的方法

  • 转到播放安装目录转到内部文件夹>>框架>>pym>>播放
  • openapplication.py
  • 转到def getClasspath(self)方法:
  • 在方法中,在行下面找到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是

    您可以像下面这样调用play server

    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计算的类路径。对于类路径,linux中的分隔符是“:”而在windows中它是“;”

    以上解决方案都有效,但我真的不明白为什么? play如何能够解析as drools无法解析相同模型的模型


    如果您知道上述问题的答案,请告诉我。

    甚至尝试从类加载器加载类。它能够正确加载类,但仍然能够解析Bean您是否尝试在kbase和KSession中使用相同的类加载器?是的,我仍然无法解析。甚至尝试从类加载器加载类。它能够加载类正确但仍然能够解析beans您是否尝试在kbase和ksession中使用相同的类加载器是的,我仍然无法解析。