Click here to Skip to main content
15,896,111 members

Getting Exception while using Drools 3.0

Shyam Dixit asked:

Open original thread
I am trying to implement Drools in .Net. I am new to .Net as well as Drools.I've read the following document for implementation of Drools:

http://www.codeproject.com/Articles/29165/Getting-Started-with-Drools-NET

I've downloaded this project and it was working fine. Here is my code which I have implemented:-


C#
requirementBusinessRules = this;
            PackageBuilder builder = new PackageBuilder();
            Stream stream = new FileStream(@"C:\Users\Sdixit\Desktop\LatesetVersion\ReadMails\SimpleRulesExt.drl", FileMode.Open);           
            builder.AddPackageFromDrl("SimpleRules.drl", stream);   // Exception
            Package pkg = builder.GetPackage();
            ruleBase = RuleBaseFactory.NewRuleBase();
            ruleBase.AddPackage(pkg);           
            workingMemory = ruleBase.NewWorkingMemory();           
            if (_currentRawMail == null)            {
                _currentRawMail = requirementBusinessRules.workingMemory.assertObject(em); 
            }
            else
            {
                requirementBusinessRules.workingMemory.modifyObject(_currentRawMail, em);
            }
            requirementBusinessRules.workingMemory.fireAllRules();
            EmailProperties mails = (EmailProperties)requirementBusinessRules.workingMemory.getObject(_currentRawMail);


C#
drools.dotnet.dll!org.drools.dotnet.semantics.DotnetBaseClassFieldExtractor.DotnetBaseClassFieldExtractor(java.lang.Class clazz, string fieldName) Line 61 + 0x13 bytes C#
drools.dotnet.dll!org.drools.dotnet.semantics.DotnetClassFieldExtractorFactory.getClassFieldExtractor(java.lang.Class clazz, string fieldName) Line 50 + 0x1b bytes C#
[External Code] 
drools-3.0.dll!org.drools.base.ClassFieldExtractor.init() Line 73 + 0x58 bytes  Unknown
drools-3.0.dll!org.drools.base.ClassFieldExtractor.ClassFieldExtractor(java.lang.Class clazz, string fieldName) Line 53 Unknown
drools-3.0.dll!org.drools.base.ClassFieldExtractorCache.getExtractor(java.lang.Class clazz, string fieldName) Line 27 + 0x1d bytes  Unknown
drools-3.0.dll!org.drools.semantics.java.RuleBuilder.getFieldExtractor(org.drools.lang.descr.PatternDescr descr, java.lang.Class clazz, string fieldName) Line 998 + 0x1b bytes Unknown
drools-3.0.dll!org.drools.semantics.java.RuleBuilder.build(org.drools.rule.Column column, org.drools.lang.descr.LiteralDescr literalDescr) Line 527 + 0x36 bytes    Unknown
drools-3.0.dll!org.drools.semantics.java.RuleBuilder.build(org.drools.lang.descr.ColumnDescr columnDescr) Line 431 + 0x36 bytes Unknown
drools-3.0.dll!org.drools.semantics.java.RuleBuilder.build(org.drools.lang.descr.RuleDescr ruleDescr) Line 303 + 0x3e bytes Unknown
drools-3.0.dll!org.drools.semantics.java.RuleBuilder.build(org.drools.rule.Package pkg, org.drools.lang.descr.RuleDescr ruleDescr) Line 203 Unknown
drools-3.0.dll!org.drools.compiler.PackageBuilder.addRule(org.drools.lang.descr.RuleDescr ruleDescr) Line 337 + 0x1b bytes  Unknown
drools-3.0.dll!org.drools.compiler.PackageBuilder.addPackage(org.drools.lang.descr.PackageDescr packageDescr) Line 204 + 0x4a bytes Unknown
drools-3.0.dll!org.drools.compiler.PackageBuilder.addPackageFromDrl(string fileName, java.io.Reader reader) Line 129    Unknown
drools.dotnet.dll!org.drools.dotnet.compiler.PackageBuilder.AddPackageFromDrl(string fileName, System.IO.Stream drlStream) Line 78 + 0x2b bytes C#


But I am getting an Exception "NullReferenceException unhandled by user code .object reference not set to an instance of an object." What to do Now?? What am I missing here?? I went through Drools: NullPointerException when addPackageFromDrl(source) is called

I am using Drools 3.0 and Visual Studio 2012 Thanks
I have found that Drools 6 is the latest version but when i installed it in my pc i found that it contains only .jar file no .dll files . Thanks Please Help!
Tags: C#, Visual Studio

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900