<br> Julien, <br><br> Thanks for reporting back!<br><br> Edson<br><br><div><span class="gmail_quote">2007/11/15, Julien Cassignol <<a href="mailto:julien.cassignol@imelios.com">julien.cassignol@imelios.com</a>>:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br><br>Following Mark's advice, I decided to mail about a problem I experienced
<br>and managed to fix, with Mark's and Edson Tirelli's help.<br><br>I was trying to build a RuleBase with the following code :<br><br> final SpreadsheetCompiler converter = new SpreadsheetCompiler();
<br> FileInputStream file = new FileInputStream(decTable);<br> final String drl = converter.compile(file, InputType.XLS);<br> System.out.println(drl);<br> Properties properties = new Properties();
<br> properties.setProperty( "drools.dialect.default",<br> "java" );<br> properties.setProperty("drools.compiler","JANINO");
<br> PackageBuilderConfiguration conf = new<br>PackageBuilderConfiguration(properties);<br> PackageBuilder builder = new PackageBuilder( conf );<br> builder.addPackageFromDrl(new StringReader(drl));
<br> Package pkg = builder.getPackage();<br> RuleBase ruleBase = RuleBaseFactory.newRuleBase();<br> ruleBase.addPackage(pkg);<br><br>Nothing difficult, but it was failing on the construction of
<br>PackageBuilderConfiguration :<br><br> No ClassLoaders found for:<br>org.drools.rule.builder.dialect.java.JavaDialect<br><br>Followed by an unhelpful stack.<br><br>Debugging my webapp (which sources I didn't have), I noticed that my
<br>class ClassLoader was different from the thread one. The thread<br>classloader was the JBoss ClassLoader, and my class classloader was the<br>one of the webapp.<br><br>Setting the classloader of the thread manually to the classloader of my
<br>webapp failed to cope with the problem, as the drools jars were<br>installed on Jboss, and drools instantiated object couldn't find core<br>objects within the classpath with the classloader of the webapp. To fix<br>
the problem, I had to use the following code :<br><br> PackageBuilderConfiguration conf = new PackageBuilderConfiguration(<br> properties);<br> conf.setClassLoader
(MyClass.class.getClassLoader());<br> RuleBaseConfiguration ruleBaseConf = new RuleBaseConfiguration();<br> ruleBaseConf.setClassLoader(MyClass.class.getClassLoader());<br><br>Setting the classloader property of the drools configuration objects
<br>allowed me to use imports of local classes (I mean local to the webapp)<br>within rule packages, and solved my problem (or so it seems).<br><br>I hope this short explanation will help someone !<br>_______________________________________________
<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users
</a><br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> Software Engineer - JBoss Rules Core Developer<br> Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @
<a href="http://www.jboss.com">www.jboss.com</a>