[rules-users] Re: (interesting) migration problem from Drools 3.0.6 to Drools 4.0.7

Maxim Veksler maxim.veksler at gmail.com
Mon Nov 17 14:15:33 EST 2008


On Mon, Nov 17, 2008 at 7:17 PM, Maxim Veksler <maxim.veksler at gmail.com>wrote:

> Hello Everyone,
>
> Here's a fun stuff to debug:
>
>
> In our application we are using the concept of "Dynamic Beans", Drools is
> running in a webapp. The servlet container is tomcat6.
>
> Dynamic beans are beans we compile from java code and then load with a
> custom class loader. This happens in the following method :
>
> The class that implements ServletContextListener has in his
> contextInitialized(...) method a code to do the following: (simplification)
>
> ClassLoader cl = Janino.JavaSourceClassLoader(...)
> originalCl = Thread.currentThread().getContextClassLoader();
> Thread.currentThread().setContextClassLoader(cl);
>
> The above code allowed drools3 to find the Dynamic Classes (which didn't
> even existed, not to be mention were available to ANY classloader).
>
>
> Now, inside the .drl files we use properties from these dynamic beans -
> This allows us to be dynamic on the properties we can filter by.
>
> All good, but now comes the new Drools4 code. The application is no longer
> able to find the mentioned classes.
> The only changes the I've done was change Drools version from 3 to 4.
>
> The errors I'm getting are of the form :
>
> Rule Compilation error : [Rule name=X Status, agendaGroup=MAIN, salience=0,
> no-loop=false]
>     com/X/ruleEngine/filtering/Rule_X_Status_0.java (2:267) : Only a type
> can be imported. com.X.common.dataModel.facts.dynamic.X resolves to a
> package
>     com/X/ruleEngine/filtering/Rule_X_Status_0.java (2:334) : Only a type
> can be imported. com.X.common.dataModel.facts.dynamic.X resolves to a
> package
>     com/X/ruleEngine/filtering/Rule_X_Status_0.java (2:1111) : Only a type
> can be imported. com.X.common.dataModel.facts.banner.X resolves to a package
>     com/X/ruleEngine/filtering/Rule_X_Status_0.java (2:1379) : The import
> com.X.common.dataModel.facts.X.X cannot be resolved
> ...
>
> Anyone has ideas how to over come this?
>
> I'm currently searching for alternatives, I'm thinking about Configuring my
> custom class loader at the webapp level or something like that...
> Help would be appreciated as I'm not getting much success.
>

Hello,

This seems like it should have been the solver of my problem, but for some
reason this does not work:

        PackageBuilderConfiguration pbc = new PackageBuilderConfiguration();
//        pbc.setCompiler(PackageBuilderConfiguration.JANINO);
        pbc.setClassLoader(DynamicBeanManager.getInstance().getCl());

Any one got (any) idea about what I'm doing wrong?


Also (a bit off topic), In the old version we used the commented line
(setting drl compiler to janino).
Does 4.0.7 version uses JANINO as default?


Thank you,
Maxim.

-- 
Cheers,
Maxim Veksler

"Free as in Freedom" - Do u GNU ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081117/8edd6eda/attachment.html 


More information about the rules-users mailing list