从BR​​MS动态加载规则

时间:2010-06-27 22:02:18

标签: java jboss drools jboss-tools

我正在尝试将我的规则从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

请帮帮我。

谢谢

2 个答案:

答案 0 :(得分:4)

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

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

答案 1 :(得分:1)

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

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