[rules-dev] Proxy classes and setGlobal

ljnelson ljnelson at gmail.com
Thu Mar 31 14:30:45 EDT 2011


Ah, seems to be a classloader issue (surprise).

Hmm, not sure how to work around this.

So I have my Drools resource adapter (http://code.google.com/p/drools-jca/),
and I have the KnowledgeBase that it produces injected as a @Resource into a
stateless session bean:

  @Resource
  private KnowledgeBase kb;

So the resource adapter, under whatever classloader it's under, reads in my
rules file and compiles the KnowledgeBase.  Let's say this is classloader A.

Then, at bean invocation time, I ask this kb to give me a new
StatefulKnowledgeSession.  It's here that I call setGlobal(), and pass it a
reference to another EJB.  This is all happening under the auspices of
classloader B.

Now, Drools takes this global and evaluates it against the declared type--in
the rules file--of the global "slot" it's supposed to fill.  I can only
assume that classloader A is loading up the global type declaration and
classloader B is supplying the global itself.  Consequently, the supplied
global is NOT an instance of classloader A's version of the interface.

Rats; this will take some work.

best,
Laird

--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Proxy-classes-and-setGlobal-tp2759729p2759859.html
Sent from the Drools - Dev mailing list archive at Nabble.com.


More information about the rules-dev mailing list