Are you inserting the instance of the dynamically loaded class into the KnowledgeBase?<br>i.e. session.insert(dynamicInstance);<br><br>If not the rule won&#39;t get fired.<br><br><br>Cheers,<br><br>Swapnil<br><br><div class="gmail_quote">
2009/11/3 Hemanth kumar <span dir="ltr">&lt;<a href="mailto:hemanth@saha.in">hemanth@saha.in</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
hi,<br>
Im working on a sample test project.<br>
In that im dynamically creating a class ( fact) and compiling it.<br>
<br>
here is my test project<br>
--------------------------------------------------------------------------------------<br>
mainJavaclass<br>
<br>
<br>
public void runRule()<br>
         {<br>
                 try {<br>
                            System.out.println(&quot;\nRunning rule\n&quot;);<br>
<br>
                                // go !<br>
<br>
                                URL[] urls = new URL[]{ new<br>
URL(&quot;file://&quot;+path) };<br>
<br>
                                URLClassLoader ucl =  new<br>
URLClassLoader(urls);<br>
                                Class&lt;?&gt; clazz  =<br>
ucl.loadClass(&quot;test.Message&quot;);<br>
                                Object classObj = clazz.newInstance();<br>
<br>
<br>
                                Method method =<br>
clazz.getDeclaredMethod(&quot;setMessage&quot;, new Class[]{String.class});<br>
<br>
                                //System.out.println(&quot;facts loaded\n&quot;);<br>
<br>
                                method.invoke(classObj, new<br>
Object[]{&quot;Hello&quot;});<br>
<br>
<br>
                                <a href="http://log.info" target="_blank">log.info</a>(&quot;==== Calling Rule Runner ======&quot;);<br>
<br>
                                Collection facts = new ArrayList();<br>
                                facts.add(classObj);<br>
<br>
<br>
                                // Load and fire our rules files against the<br>
data<br>
                                new<br>
RuleRunner().runStatelessRules(RULES_FILES, null, facts, null, null,<br>
logger);<br>
<br>
                        }<br>
                  catch (Throwable t) {<br>
                                t.printStackTrace();<br>
                        }<br>
<br>
         }<br>
<br>
----------------------------------------------------------------------<br>
Fact<br>
<br>
package test;<br>
public class Message{<br>
private String message;<br>
public String getMessage(){<br>
return this.message;<br>
}<br>
<br>
public void setMessage(String message) {<br>
this.message = message;<br>
}<br>
<br>
}<br>
<br>
<br>
------------------------------------------------------------------------<br>
sample rule<br>
<br>
package test<br>
import test.Message;<br>
<br>
rule &quot;Your First Rule&quot;<br>
     dialect &quot;mvel&quot;<br>
     when<br>
          m:Message(message != &quot;Good Bye&quot;  )<br>
     then<br>
          System.out.println(&quot;First Rule fired    &quot;+m.message );<br>
          modify(m){ message = &quot;Good Bye&quot;};<br>
end<br>
-----------------------------------------------------------------<br>
<a href="http://old.nabble.com/file/p26160051/console.PNG" target="_blank">http://old.nabble.com/file/p26160051/console.PNG</a> console.PNG<br>
<br>
what happens is when i was running the project inside eclipse IDE it works<br>
fine but when i hosted in tomcat and calling from outside ide the rule is<br>
not getting fired.<br>
I think the dyanamically loaded class is not recognised by the rule engine.<br>
<br>
suggest me any ideas or post an working example<br>
<br>
Hemanth<br>
<font color="#888888">--<br>
View this message in context: <a href="http://old.nabble.com/Class-loader-problem-tp26160051p26160051.html" target="_blank">http://old.nabble.com/Class-loader-problem-tp26160051p26160051.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<br>
<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>