从 BRMS 动态加载规则

发布于 2024-09-07 09:45:03 字数 4934 浏览 6 评论 0原文

我正在尝试将我的规则从 jboss-brms 上传到我的 eclipse,以便针对工作内存运行它。 以下是我的代码和change-set.xml 文件,我收到以下错误堆栈。 我已经启动了jboss-server并且它连接正确。 但我无法弄清楚我收到的错误,我的更改集和代码是否正确? 该错误表明它无法解析change-set.xml并且无法连接到服务器。我刚刚在更改集文件中指定了 url 路径以及它应该查找的文件类型。 我还需要添加什么才能连接到服务器???我在文档中找不到太多帮助。

请帮我。我对 Drools 还比较陌生。

我的 Runner 类中的代码:

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();

// creating a knowledge agent
KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();

KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent", kbase,aconf );
kagent.applyChangeSet( ResourceFactory.newUrlResource("http://localhost:8280/jboss-brms/org.drools.guvnor.Guvnor/Guvnor.html"));
StatefulKnowledgeSession ksession = kagent.getKnowledgeBase().newStatefulKnowledgeSession();

//      StatelessSession workingMemory = ruleBase.newStatelessSession();
ArrayList<Ip> ipList = new ArrayList<Ip>();

ksession.setGlobal("ipList", ipList);
ksession.insert(al);
ksession.fireAllRules();
ksession.dispose();

我的change-set.xml 文件:

<change-set xmlns='http://drools.org/drools-5.0/change-set'
         xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
         xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd' >
<add>
    <!-- Add for specifying URLs-->
    <resource source='http://localhost:8280/jboss-brms' type='DRL' />
    <resource source='http://localhost:8280/jboss-brms' type='DSLR' />
    <resource source='http://localhost:8280/jboss-brmss/sample-dsl.dsl' type='DSL' />";
    <resource source='http://localhost:8280/jboss-brms' type='BRL' />
</add>
</change-set>

错误堆栈:

java.lang.RuntimeException: Unable to parse ChangeSet
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:223)
    at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:109)
    at com.org.RuleRunner.runStatelessRules(RuleRunner.java:156)
    at com.org.RulesTest.main(RulesTest.java:38) Caused by: java.net.SocketException: Network is unreachable: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.Socket.connect(Socket.java:524)
    at java.net.Socket.connect(Socket.java:474)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
    at sun.net.www.http.HttpClient.New(HttpClient.java:304)
    at sun.net.www.http.HttpClient.New(HttpClient.java:321)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:839)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:791)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:716)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:960)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:255)
    at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:170)
    at org.drools.xml.XmlChangeSetReader.read(XmlChangeSetReader.java:48)
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:221)
    ... 3 more

请帮助我。

谢谢

I am trying to upload my rules from jboss-brms to my eclipse in order to run it against the working memory.
The following is my code and change-set.xml file and I am getting the following error stack.
I have started the jboss-server and it is connected correctly.
But I am not able to figure out the error I am getting and is my change-set and code proper?
The error says that it is unable to parse change-set.xml and unable to connect to the server. I have just specified the url path in my change-set file and the types of files it should be looking out for.
What else do I need to incorporate for it to connect to the server??? I could not find much help in the documentation.

Please help me. I am relatively new to Drools.

Code in my Runner class:

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
ResourceFactory.getResourceChangeScannerService().start();
ResourceFactory.getResourceChangeNotifierService().start();

// creating a knowledge agent
KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();

KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent( "MyAgent", kbase,aconf );
kagent.applyChangeSet( ResourceFactory.newUrlResource("http://localhost:8280/jboss-brms/org.drools.guvnor.Guvnor/Guvnor.html"));
StatefulKnowledgeSession ksession = kagent.getKnowledgeBase().newStatefulKnowledgeSession();

//      StatelessSession workingMemory = ruleBase.newStatelessSession();
ArrayList<Ip> ipList = new ArrayList<Ip>();

ksession.setGlobal("ipList", ipList);
ksession.insert(al);
ksession.fireAllRules();
ksession.dispose();

my change-set.xml file:

<change-set xmlns='http://drools.org/drools-5.0/change-set'
         xmlns:xs='http://www.w3.org/2001/XMLSchema-instance'
         xs:schemaLocation='http://drools.org/drools-5.0/change-set.xsd' >
<add>
    <!-- Add for specifying URLs-->
    <resource source='http://localhost:8280/jboss-brms' type='DRL' />
    <resource source='http://localhost:8280/jboss-brms' type='DSLR' />
    <resource source='http://localhost:8280/jboss-brmss/sample-dsl.dsl' type='DSL' />";
    <resource source='http://localhost:8280/jboss-brms' type='BRL' />
</add>
</change-set>

error stack:

java.lang.RuntimeException: Unable to parse ChangeSet
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:223)
    at org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:109)
    at com.org.RuleRunner.runStatelessRules(RuleRunner.java:156)
    at com.org.RulesTest.main(RulesTest.java:38) Caused by: java.net.SocketException: Network is unreachable: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.Socket.connect(Socket.java:524)
    at java.net.Socket.connect(Socket.java:474)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:523)
    at sun.net.www.http.HttpClient.<init>(HttpClient.java:231)
    at sun.net.www.http.HttpClient.New(HttpClient.java:304)
    at sun.net.www.http.HttpClient.New(HttpClient.java:321)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:839)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:791)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:716)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:960)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:973)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872)
    at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
    at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
    at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:255)
    at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:170)
    at org.drools.xml.XmlChangeSetReader.read(XmlChangeSetReader.java:48)
    at org.drools.agent.impl.KnowledgeAgentImpl.getChangeSet(KnowledgeAgentImpl.java:221)
    ... 3 more

Please help me.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拥有 2024-09-14 09:45:03

您不应该引用一般的 Guvnor URL,而应该引用构建的包。
类似于包“defaultPackage”:
http://localhost:8080/drools-guvnor/ org.drools.guvnor.Guvnor/package/defaultPackage/LATEST

请注意,Guvnor 可以管理多个知识库。因此,请确保将您的资源添加到您想要的包中,并确保它已构建。

You shouldn't be referring to the general Guvnor URL but to a built package.
Something like for package "defaultPackage":
http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package/defaultPackage/LATEST

Note that Guvnor can manage multiple knowledge bases. So make sure to add your resources to the package you want and make sure it is built.

幸福不弃 2024-09-14 09:45:03

正如克里斯所说。如果您转到 BRMS 中的包视图并检查底部的“信息和重要 URL”部分,则可以获得最新包的正确 URL。

如果您希望代理下载快照,请转到“包快照”,您可以从“部署 URL:单击此处下载二进制文件(或复制部署代理的 URL)”行中获取 URL。

Like Kris said. You can get the correct URL for the latest package if you go to the package view in BRMS and check the section on the bottom "Information and important URLs".

If you want the agent to download snapshot go to "Package snapshots" and you can get the URL from the line that says "Deployment URL: click here to download binary (or copy URL for deployment agent)".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文