[rules-users] Drools Java and .Net

FrankVhh frank.vanhoenshoven at agserv.eu
Wed Feb 2 07:53:19 EST 2011


Hi all,

I figured out how to get it working. This might be interesting to some of
the forum visitors, so I will post the brief solution here.

1. Write your Drools application in java "as usual" (see documentation :-)
2. Export your java code as a runnable jar-file.
3. Using ikvmc from IKVM/bin, convert the .jar to a .dll and (very
important) ignore all warnings!
> ikvmc -target:library droolsapplication.jar
4. Reference this dll in your .net code.
5. Make sure System.dll and IKVM.OpenJDK.Core.dll are referenced as well
6. In your .net code, add a section to reference your drools libraries:
> System.Environment.SetEnvironmentVariable("CLASSPATH",
> ".;C:/Users/Frank/Documents/Drools
> runtime/drools-api.jar;C:/Users/Frank/Documents/Drools
> runtime/drools-core.jar;C:/Users/Frank/Documents/Drools
> runtime/drools-compiler.jar");
7. Call the (java-)class and invoke the method which calls upon the ruleset
to be executed

This way, it should work.

Any remarks to this brief overview are welcome, of course :-)

Regards,
Frank 

FrankVhh wrote:
> 
> Hi all,
> 
> Thanks again for your replies.
> 
> I converted drools-compiler.jar to drools-compiler.dll and imported this
> into .NET. Problem might be that this compiles with an incredibly long
> list of warnings. This might explain the malfunctioning.
> 
> There are 2 main questions that I am posing at this point.
> 
> 1) Is it necessary to convert those jars into dll or is it also possible
> to add the jar-files to some kind of path. (I will try to ask this to a
> IKVM community)
> 
> 2) If converting is necessary: Suppose I can remove all warnings by
> referencing other jar files during dll-conversion. Will this be enough to
> get to rule execution? Because drools-compiler is not the only file that
> converts with warnings.
> 
> Thanks & regards,
> Frank
> 
> 
> 
> salaboy wrote:
>> 
>> Are you including drools-compiler as a dependency?
>> Greetings! 
>> 
>> - CTO @ http://www.plugtree.com
>> - MyJourney @ http://salaboy.wordpress.com
>> - Co-Founder @ http://www.jbug.com.ar
>> - Mauricio "Salaboy" Salatino -
>> 
>> On 02/02/2011, at 05:40, FrankVhh <frank.vanhoenshoven at agserv.eu> wrote:
>> 
>>> 
>>> Hi all,
>>> 
>>> Thanks for your inputs. As you suggested, this week I tried to use IKVM
>>> to
>>> make Drools and .NET work together.
>>> 
>>> Converting the Java implementation of drools to dll, importing dll into
>>> .NET
>>> and calling the java functions isn't that hard, once you are a little
>>> bit
>>> familiar with ikvm. No syntax errors in Visual Studio when I do this.
>>> 
>>> However, there seems to be going something wrong on execution. It
>>> appears to
>>> me that the execution environment does not recognize the
>>> "drools-language".
>>> 
>>> The execution crashes on the first call of Drools code
>>> (knowledgebuilderfactory.new KnowledgeBuilder()) with the errors: 
>>>    - IllegalArgumentException : Unable to instantiate service for Class
>>> 'org.drools.builder.KnowledgeBuilderFactoryService"
>>>    - ClassNotFoundException:
>>> org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl
>>> 
>>> This means there are some dependancies missing, right? But should I be
>>> looking to add some jars to the IKVM-JVM? Or is this definitely a
>>> problem of
>>> wrong jar to dll conversion?
>>> 
>>> Corneil, could you tell me whether you ran into dependancy problems as
>>> well?
>>> 
>>> fyi I also tried to import the drools library as dll into .NET and then
>>> rewrite the entire wrapping code in .NET. This didn't return any syntax
>>> errors either, but got stuck in execution as well. (With same errors).
>>> 
>>> Regards,
>>> Frank
>>> 
>>> 
>>> Corneil du Plessis wrote:
>>>> 
>>>> We have successfully used IKVM to create a dlls for our Drools
>>>> application.
>>>> 
>>>> The performance was a bit slower on IKVM/.Net as in Sun Java 5.
>>>> We dynamically load a large number of rules and found the largest
>>>> impact 
>>>> is to the 'load time'
>>>> 
>>>> The performance impact was not such that it would make a network call 
>>>> viable; especially with 1000s of clients.
>>>> 
>>>> Apart from the performance impact the behaviour is exactly the same.
>>>> 
>>>> On 25/01/2011 17:04, FrankVhh wrote:
>>>>> Hi all,
>>>>> 
>>>>> Suppose that you have a rule engine that needs to be embedded on the
>>>>> machine
>>>>> and that there is no way to call the rules as a service from a
>>>>> centralized
>>>>> server, what approach would one have to choose to make Drools and .NET
>>>>> work?
>>>>> 
>>>>> The rulke engine will have to be cached to improve performance, so
>>>>> that
>>>>> part, until there is an up-to-date version of Drools.NET, has to be in
>>>>> Java
>>>>> anyway. Then you expose your JAVA code as a (local) service and let
>>>>> .NET
>>>>> call it? Or am I seeing things wrong here?
>>>>> 
>>>>> I must stipulate that I am not an expert in .NET at all, and I know
>>>>> only
>>>>> barely enough Java to get Drools working :-).
>>>>> 
>>>>> Thanks for your help.
>>>>> 
>>>>> Kind regards,
>>>>> Frank
>>>>> 
>>>>> 
>>>>> salaboy wrote:
>>>>>> Yes, and if you want to use the rule engine from .NET you can use the
>>>>>> Drools
>>>>>> Server that expose the Drools Runtime in REST and SOAP interfaces :)
>>>>>> Greetings.
>>>>>> 
>>>>>> 2011/1/19 Michael Anstis<michael.anstis at gmail.com>
>>>>>> 
>>>>>>> Hi,
>>>>>>> 
>>>>>>> I believe the .NET implementation of Drools is somewhat out dated.
>>>>>>> 
>>>>>>> However Drools ticks all your other requirements.
>>>>>>> 
>>>>>>> With kind regards,
>>>>>>> 
>>>>>>> Mike
>>>>>>> 
>>>>>>> 2011/1/19 Gorantla, Bhaskar (GE Capital)<bhaskar.gorantla at ge.com>
>>>>>>> 
>>>>>>>> We are looking for a rules engine that has the following
>>>>>>>> characteristics.
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 1.       Supports both Java and .net
>>>>>>>> 
>>>>>>>> 2.       Provides a business user friendly UI for creating/editing
>>>>>>>> rules
>>>>>>>> 
>>>>>>>> 3.       Supports versioning
>>>>>>>> 
>>>>>>>> 4.       The rues in the rules repository are accessible to both
>>>>>>>> Java
>>>>>>>> and
>>>>>>>> .net applications – Nice to have
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Do you know whether Drools supports all the above?
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> Thanks
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> _______________________________________________
>>>>>>>> rules-users mailing list
>>>>>>>> rules-users at lists.jboss.org
>>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>>> 
>>>>>>>> 
>>>>>>> _______________________________________________
>>>>>>> rules-users mailing list
>>>>>>> rules-users at lists.jboss.org
>>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> -- 
>>>>>>  - CTO @ http://www.plugtree.com
>>>>>>  - MyJourney @ http://salaboy.wordpress.com
>>>>>>  - Co-Founder @ http://www.jbug.com.ar
>>>>>> 
>>>>>>  - Salatino "Salaboy" Mauricio -
>>>>>> 
>>>>>> _______________________________________________
>>>>>> rules-users mailing list
>>>>>> rules-users at lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>>>> 
>>>>>> 
>>>> 
>>>> -- 
>>>> 
>>>> Corneil du Plessis - Software Architect
>>>> 
>>>> TSC Technologies (Pty) Ltd
>>>> (o) +27 11 431 1666
>>>> (f) +27 86 674 2962
>>>> (c) +27 82 530 9259
>>>> Email: corneil at tsctech.com <mailto:corneil at tsctech.com>
>>>> www.tsctech.com <http://www.tsctech.com>
>>>> 
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>> 
>>>> 
>>> 
>>> -- 
>>> View this message in context:
>>> http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Java-and-Net-tp2290536p2403895.html
>>> Sent from the Drools - User mailing list archive at Nabble.com.
>>> 
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>> 
> 
> 

-- 
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Java-and-Net-tp2290536p2405062.html
Sent from the Drools - User mailing list archive at Nabble.com.




More information about the rules-users mailing list