[rules-users] Embedding Drools in Eclipse

Edson Tirelli tirelli at post.com
Wed Dec 3 11:26:45 EST 2008


   Ok, you got me hooked by my curiosity now. :)

   I know Drools internals, but I unfortunately know nothing about Eclipse
internals (maybe I can learn something today). So, we will need to work
together on this, ok?

   First things first, can you please update to M3? Besides possible bug
fixes, it way will be easier to debug things since line numbers will match.

   Drools works AFAIK pretty well in App Servers. Yes, it creates custom
classloaders internally because it needs to generate classes, but it does
respect classloader hierarchy as much as I know it is possible.

   The two ways to tell Drools about facts being in a different classloader
hierarchy are:

* Either set the fact classloaders explicitly on *both*
PackageBuilderConfiguration and RuleBaseConfiguration for compile-time and
runtime respectivelly. This is my preferred approach.
* Or, if a classloader is not set in the configuration objects, Drools will
look for the ThreadContext set classloader.

   The above covers the use cases for JEE containers and I am not aware of
any problems.

   Now, how Eclipse differs from that? What does it means to set a plugin as
"buddy" of another? Sorry if the question is too basic, but never played
with Eclipse plugins before.

   []s
   Edson

2008/12/3 keithnielsen <keithnielsen at discover.com>

>
> Since my last post was so nicely hijacked I have started a new thread in
> the
> hopes that the Drools team can shed some light on this.
>
> My setup is as follows:
>
> 1) 2 plug-ins, one containing the drools libraries, and a second plugin
> containing the facts and the rule file.
> 2) The rules engine plugin has a buddy-policy of "registered" and the facts
> plugin has the rules engine plugin as a registered buddy.
>
>
> Here is the rule(although any fact that has field assignments fails)
>
> rule "Retrieve CID Presentation Model"
>        ruleflow-group "RetrieveCID"
>
>        when
>
> CIDPresentationModel($cidValue:cidValue,$cidExpirationDate:expirationDate)
>        then
>                boolean cidResult =
> cidService.verifyCIDIsValid($cidValue,$cidExpirationDate);
>                CIDResult result = new CIDResult(cidResult);
>                insert(result);
>                System.out.println("Executing: Retrieve CID Presentation
> Model");
> end
>
> Deep in the bowels of drools there is a call to
> ClassFieldAccessorFactory.getClassFieldReader where it attempts to create a
> class using the byte array classloader, i.e. final Class<?> newClass =
> byteArrayClassLoader.defineClass(className, bytes,PROTECTION_DOMAIN). Its
> at
> this point that a NoClassDefFoundError on the BaseObjectClassFieldReader. I
> am a little concerned when I see what appears to be a custom classloader
> since if you are going to embed the rules engine it should respect the
> classloader hierachy from the container, whether that be an app server like
> Websphere or client side container like Eclipse.
>
> I am wondering if the team has had success with this particular setup (the
> examples for Drools work cause they are all in the same plugin). I have
> made
> the example as simple as possible but still no luck. Seems like this is
> pretty basic functionality so I can't imagine this hasn't been tested.
> --
> View this message in context:
> http://www.nabble.com/Embedding-Drools-in-Eclipse-tp20814423p20814423.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
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081203/aa9ecfb9/attachment.html 


More information about the rules-users mailing list