deprecating old core/compiler apis
by Mark Proctor
We've attempted to keep the main core/compiler api compatabile in our
codebase for our existing users, while providing the new drools-api.
However this leaves a lot of messy code and we think it's time to start
cleaning up. So anyone think it'll be a problem if stuff in core and
compiler starts to change?
Mark
15 years, 3 months
Drools - Doing Complex Stuff inside a Rule Condition or Consequence
by Miguel Fernando Cabrera
Hello everyone
In my company we are planning to use Drools for couple of projects and we
having some questions about the best way to use it
My question is what should be and shouldn't be done inside a Rule
Condition/Consequence. Given that we can write Java directly or call methods
(for example From a Global object in the Working Memory).
Example. Given a Rule that evaluates a generic Object (e.g. Person) have
property set to true. Now, that specific propertie can only be defined for
that Object going to the database (or going to a web service) and fetching
that info. So we have two ways of implementing that:
*Alternative A:*
- Go to the database and fetch the object property (true/false, a code)
- Insert the Object in the working memory
- Evaluate the rule
*Alternative B:*
- Insert a Global Object that has a method that connects to the database
and check for the property for the given object.
- Insert the Object to eval in Working Memory
- In the rule, call the Global Object and perform the access to the
database
Which of those is considered better? I really like A, but sometimes B is
more straightforward, however what would happen if something like a
Exception from the Database is raised?* *I have seen the alternative B
implemented in the Drools 5.0 Book from Packt Publishing,however they are
doing a mocking and they don't talk about the actual implications of going
to the database at all.
Thank you in advance,
--
Miguel Fernando Cabrera Granados
http://mfcabrera.com
"A los hombres fuertes les pasa lo que a los barriletes; se elevan cuando es
mayor el viento que se opone a su ascenso." - José Ingenieros
15 years, 3 months
Eclipse tools ClassNotFoundException
by paulB
Hi,
I just updated the tooling in Eclipse from 5.0 to 5.1.1. Now, anytime I try
to create a Flow, I get the following exception:
java.lang.NoClassDefFoundError: org/drools/xml/ProcessBuildData
at org.drools.bpmn2.xml.ProcessHandler.start(ProcessHandler.java:84)
at
org.drools.xml.ExtensibleXmlParser.startElement(ExtensibleXmlParser.java:384)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
at
com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:688)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
at
com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at
com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:295)
at org.drools.xml.ExtensibleXmlParser.read(ExtensibleXmlParser.java:174)
at org.drools.compiler.xml.XmlProcessReader.read(XmlProcessReader.java:44)
at
org.drools.eclipse.flow.bpmn2.editor.BPMNModelEditor.createModel(BPMNModelEditor.java:190)
at
org.drools.eclipse.flow.common.editor.GenericModelEditor.setInput(GenericModelEditor.java:285)
at
org.drools.eclipse.flow.bpmn2.editor.BPMNModelEditor.setInput(BPMNModelEditor.java:93)
at org.eclipse.gef.ui.parts.GraphicalEditor.init(GraphicalEditor.java:318)
at org.eclipse.ui.internal.EditorManager.createSite(EditorManager.java:798)
at
org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:644)
at
org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:462)
at
org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at
org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:286)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2857)
at
org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2762)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2754)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2705)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2701)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2685)
at
org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2676)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
at
org.drools.eclipse.flow.ruleflow.NewRuleFlowFilePage.finish(NewRuleFlowFilePage.java:72)
at
org.drools.eclipse.flow.ruleflow.NewRuleFlowFileWizard.performFinish(NewRuleFlowFileWizard.java:50)
at
org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:752)
at
org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:373)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at
org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:228)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at
org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:135)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at
org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at
org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3910)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3503)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
Caused by: java.lang.ClassNotFoundException: org.drools.xml.ProcessBuildData
at
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 78 more
I made sure that the Drools Runtime is pointing to v5.1.1 jars. Any other
thoughts?
Thanks!
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Eclipse-tools-ClassNo...
Sent from the Drools - User mailing list archive at Nabble.com.
15 years, 3 months
Validate/View Source or new rule (Decision table- web guided editor) - SerializationException - Guvnor 5.1.1
by Achyutha, Venkata
Hi,
Till few days ago we use to deploy 5.1.1 war from drools and site and work on it, it use to work perfectly
Recently we got guvnor 5.1.1 source code, did maven build locally and started using war after deploying in weblogic.
When I try to create rule of type "Decision table- web guided editor" and view source its giving SerializationException exception in UI an in server log it says
<Nov 22, 2010 6:03:01 PM IST> <Error> <ServletContext-/drools-guvnor> <BEA-000000> <guvnorService: An IncompatibleRemoteServiceException was thrown while processing this call.
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: com.google.gwt.user.client.rpc.SerializationException: Invalid type signature for org.drools.ide.common.client.modeldriven.dt.ActionSetFieldCol
at com.google.gwt.user.server.rpc.RPC.decodeRequest(RPC.java:308)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:186)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:224)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
Truncated. see log file for complete stacktrace
com.google.gwt.user.client.rpc.SerializationException: com.google.gwt.user.client.rpc.SerializationException: Invalid type signature for org.drools.ide.common.client.modeldriven.dt.ActionSetFieldCol
Any idea what is happening here (I know some issue would be with gwt components), any work around needed in source code?. Help would be greatly appreciated.
Do we have stable working version of source code releases in 5.1.1 ( I need to use 5.1.1 only as we already have rule agent code working in production which is compatible with 5.1.1 only).
Many Thanks in advance.
[cid:image001.png@01CB8A6F.EC686A60]
Thanks
Kumar
15 years, 3 months
Question about Drools
by Mashael Alduwais
Deal All,
I'm a graduate students, and I want to develop a fuzzy expert system using
the great Drools Expert
Is it support fuzzy logic or not?
Thank you in advance
15 years, 3 months
Drools logging to console.
by Nadav Hashimshony
my drools application write debug and info message to the console.
i currently do the follwoing
in the main thread i i have:
private static KnowledgeBase m_droolsKbase= createKnowledgeBase();
private static KnowledgeBase createKnowledgeBase()
{
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();
Properties droolsConf = new Properties();
droolsConf.setProperty("drools.dialect.java.compiler", "JANINO");
KnowledgeBuilderConfiguration config =
KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(droolsConf, null);
KnowledgeBuilder builder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);
builder.add(ResourceFactory.newFileResource(m_properties.getProperty("drools.pkg")),
ResourceType.PKG);
if (builder.hasErrors())
{
throw new RuntimeException(builder.getErrors().toString());
}
KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase();
knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages());
m_droolsKagent=
KnowledgeAgentFactory.newKnowledgeAgent("DroolsAgent",knowledgeBase);
m_droolsKagent.applyChangeSet(ResourceFactory.newFileResource(m_properties.getProperty("drools.pkg.xml")));
return m_droolsKagent.getKnowledgeBase();
}
each worker thread does the following:
StatefulKnowledgeSession droolsSession =
m_droolsKagent.getKnowledgeBase().newStatefulKnowledgeSession();
//KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newConsoleLogger(droolsSession);
//KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(droolsSession,
"var/log/ctch/ctDefender/ctDefenderDrools.log");
.
.
.
Even if the logger lines are commented i still get log prints to console
(STDOUT)
how can i control them? stop them?
Thanks.
Nadav.
15 years, 3 months
What should I insert into the working memory?
by Chris Selwyn
I am working on a project that is using Drools to perform validation of
hierarchical XML messages.
So I have passed the XSDs through JAXB and have a set of interrelated
Java objects.
One of these objects (naturally) represents the root of the messages and
the others represent the intermediate and leaf nodes of the message.
My question is: Should I traverse the tree and insert each object into
the working memory or should I just insert the root object into the
working memory?
If I insert each object into the memory then I have a lot of flexibility
about how I write my rules... I can start by focussing on the particular
part of the message that I want to detect an error in.
However, I then have to perform a whole bunch of "joining" clauses to
correctly "connect up" to the other objects in the working memory.
(This is how I am doing it at the moment... I have a mechanism that uses
the Java Introspector. It identifies by package name which parts of the
data model get inserted into the WM)
On the other hand, I could just insert the root object into the WM. This
means that I would have to write really complicated where clauses on the
root object but very much simplifies the WM loading process.
All of the examples that I have seen have a very simple flat
(non-hierarchical) structure that don't really give a hint as to what a
"best practice" might be.
Any suggestions/insights welcome :-)
Chris Selwyn
15 years, 3 months