I updated my post.
Exception in thread "main" java.lang.NoSuchMethodError:
org.drools.util.CompositeClassLoader.clone()Lorg/drools/util/CompositeClassLoader;
at
org.drools.RuleBaseConfiguration.getClassLoader(RuleBaseConfiguration.java:886)
at org.drools.common.AbstractRuleBase.<init>(AbstractRuleBase.java:164)
at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:151)
at org.drools.reteoo.ReteooRuleBase.<init>(ReteooRuleBase.java:128)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:86)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:74)
at org.drools.RuleBaseFactory.newRuleBase(RuleBaseFactory.java:37)
at
org.drools.impl.KnowledgeBaseFactoryServiceImpl.newKnowledgeBase(KnowledgeBaseFactoryServiceImpl.java:49)
at
org.drools.KnowledgeBaseFactory.newKnowledgeBase(KnowledgeBaseFactory.java:63)
at
org.drools.agent.KnowledgeAgentFactory.newKnowledgeAgent(KnowledgeAgentFactory.java:138)
at
org.drools.guvnor.examples.mortgage.client.MortgageClientExample.readKnowledgeBase(MortgageClientExample.java:89)
at
org.drools.guvnor.examples.mortgage.client.MortgageClientExample.main(MortgageClientExample.java:49)
________________________________
From: Michael Anstis <[email protected]>
To: Rules Users List <[email protected]>
Sent: Friday, September 14, 2012 11:48 AM
Subject: Re: [rules-users] Guvnor example how to access rules in database
instead sample.drl file?
I assume:-
1) You changed the URL in the change-set to suit where your Guvnor is running?
The stack trace suggests
http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
could not be found.
2) You built the mortgages package in Guvnor?
I've been running this very same example numerous times in the past few days,
both on Tomcat and JBoss AS7.1.1 so am confident it works.
On 14 September 2012 16:56, richard <[email protected]> wrote:
Guvnor - Version 5.4.0.Final
>\drools-examples\drools-examples-brms\mortgage-example
>
>I get this error.
>
>java.lang.RuntimeException: KnowledgeAgent exception while trying to
>deserialize KnowledgeDefinitionsPackage
> at
>org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:776)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1071)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:824)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:673)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:203)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:182)
> at
>org.drools.guvnor.examples.mortgage.client.MortgageClientExample.readKnowledgeBase(MortgageClientExample.java:92)
> at
>org.drools.guvnor.examples.mortgage.client.MortgageClientExample.main(MortgageClientExample.java:49)
>Caused by: java.io.FileNotFoundException:
>http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/mortgages/LATEST
> at
>sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1434)
> at org.drools.io.impl.UrlResource.grabStream(UrlResource.java:210)
> at org.drools.io.impl.UrlResource.getInputStream(UrlResource.java:146)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(KnowledgeAgentImpl.java:748)
> ... 7 more
>
>Exception in thread "main" java.lang.NullPointerException
> at java.util.AbstractCollection.addAll(AbstractCollection.java:303)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(KnowledgeAgentImpl.java:1077)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(KnowledgeAgentImpl.java:824)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(KnowledgeAgentImpl.java:673)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:203)
> at
>org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(KnowledgeAgentImpl.java:182)
> at
>org.drools.guvnor.examples.mortgage.client.MortgageClientExample.readKnowledgeBase(MortgageClientExample.java:92)
> at
>org.drools.guvnor.examples.mortgage.client.MortgageClientExample.main(MortgageClientExample.java:49)
>
>/*
> * Copyright 2011 JBoss Inc
> *
> * Licensed under the Apache License, Version 2.0 (the "License");
> * you may not use this file except in compliance with the License.
> * You may obtain a copy of the License at
> *
> * http://www.apache.org/licenses/LICENSE-2.0
> *
> * Unless required by applicable law or agreed to in writing, software
> * distributed under the License is distributed on an "AS IS" BASIS,
> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> * See the License for the specific language governing permissions and
> * limitations under the License.
> */
>
>package org.drools.guvnor.examples.mortgage.client;
>
>import javax.swing.JOptionPane;
>
>import org.drools.KnowledgeBase;
>import org.drools.agent.KnowledgeAgent;
>import org.drools.agent.KnowledgeAgentFactory;
>import org.drools.definition.type.FactType;
>import org.drools.io.Resource;
>import org.drools.io.ResourceFactory;
>import org.drools.runtime.StatefulKnowledgeSession;
>
>public class MortgageClientExample {
>
> /**
> * Entry point demonstrating use of KnowledgeAgent and changesets
>retrieving
> * a rule package from a running instance of Guvnor.
> * @param args
> */
> public static void main(String[] args) {
>
> JOptionPane.showMessageDialog(null, "This example makes a few
>assumptions:\n" +
> "- Start the app server on localhost on port 8080.\n" +
> "- Rename the guvnor war to guvnor.war and deploy it to the
>app server.\n" +
> "- Surf to Guvnor and log in.\n" +
> "- In the menu Administration, Import/Export, import
>/exported-repositories/mortgage-sample-repository.xml\n" +
> "- Refresh the browser, open menu Package, click Rebuild all
>packages.\n" +
> "Click OK when this is done.", "Preparation",
>JOptionPane.INFORMATION_MESSAGE);
>
> StatefulKnowledgeSession ksession = null;
> try {
> // load up the knowledge base
> KnowledgeBase kbase = readKnowledgeBase();
>
> // Dynamic fact creation as the model was declared in the DRL
> FactType appType = kbase.getFactType("mortgages",
>"LoanApplication");
> Object application = appType.newInstance();
> appType.set(application, "amount", 25000);
> appType.set(application, "deposit", 1500);
> appType.set(application, "lengthYears", 20);
>
> FactType incomeType = kbase.getFactType("mortgages",
>"IncomeSource");
> Object income = incomeType.newInstance();
> incomeType.set(income, "type", "Job");
> incomeType.set(income, "amount", 65000);
>
> // Invoke the magic
> ksession = kbase.newStatefulKnowledgeSession();
> ksession.insert(application);
> ksession.insert(income);
> ksession.fireAllRules();
>
> // Voila!
> String message = "The loan application is now:\n" + application;
> System.out.println(message);
> JOptionPane.showMessageDialog(null, message, "Result",
>JOptionPane.INFORMATION_MESSAGE);
> } catch (InstantiationException e) {
> e.printStackTrace();
> } catch (IllegalAccessException e) {
> e.printStackTrace();
> } finally {
> if (ksession != null) {
> ksession.dispose();
> }
> }
> }
>
> /**
> * Load KnowledgeBase using KnowledgeAgent configured with accompanying
>changeset xml
> * @return A KnowledgeBase
> */
> private static KnowledgeBase readKnowledgeBase() {
> KnowledgeAgent kagent =
>KnowledgeAgentFactory.newKnowledgeAgent("MortgageAgent");
> Resource changeset = ResourceFactory.newClassPathResource(
>
>"org/drools/guvnor/examples/mortgage/mortgage-changeset.xml");
> kagent.applyChangeSet(changeset);
> KnowledgeBase kbase = kagent.getKnowledgeBase();
> kagent.dispose();
> return kbase;
> }
>
>}
>
>
>
>
>--
>View this message in context:
>http://drools.46999.n3.nabble.com/Guvnor-example-how-to-access-rules-in-database-instead-sample-drl-file-tp4019713p4019795.html
>
>Sent from the Drools: User forum mailing list archive at Nabble.com.
>_______________________________________________
>rules-users mailing list
>[email protected]
>https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users