swapnil thanx for the reply,<br>this is my modified code<br><br>try{<br>            <br>            System.out.println(&quot;Initializing Fact....&quot;);<br>            <br>            URL[] urls = new URL[]{ new URL(&quot;file://&quot;+path) };<br>

             ClassLoader loader =  new URLClassLoader(urls);<br>             Class clazz  = loader.loadClass(&quot;test.Message&quot;);<br>                              //Class.forName(&quot;test.Message&quot;, false, ucl);<br>

             Object factObj = clazz.newInstance();<br>             String ruleFile = &quot;test/Sample.drl&quot;;<br>             <br>             Method method = clazz.getMethod(&quot;setMessage&quot;, new Class[]{String.class});<br>

             Method method1 = clazz.getMethod(&quot;getMessage&quot;);<br>             //System.out.println(&quot;facts loaded\n&quot;);<br>    <br>             method.invoke(factObj, new Object[]{&quot;Hello&quot;});<br>

                         <br>             System.out.println(&quot;initializing packageBuilder&quot;);<br>             <br>             PackageBuilderConfiguration config = new PackageBuilderConfiguration();<br>             config.setClassLoader(loader);<br>

             <br>            KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(config);<br>            <br>            System.out.println(&quot;finding Rule&quot;);<br>            kbuilder.add(ResourceFactory.newClassPathResource(&quot;test/Sample.drl&quot;),ResourceType.DRL);<br>

    <br>            if (kbuilder.hasErrors())<br>                  throw new RuntimeException(&quot;Unable to compile rules. &quot; + <br>                            kbuilder.getErrors().toString());<br><br>    <br>            KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(new RuleBaseConfiguration(loader));<br>

    <br>            kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());<br><br>            StatelessKnowledgeSession session = kbase.newStatelessKnowledgeSession();<br><br>            System.out.println(&quot;running rule....... \n&quot;);<br>

             session.execute(factObj);<br>            <br>             System.out.println(&quot;\nend...\n&quot;);<br>             System.out.println(method1.invoke(factObj).toString());<br>        }<br>        catch (Throwable t) {<br>

            t.printStackTrace();                <br>        }<br><br>thanx and regards<br>Hemanth<br><br><br><br><div class="gmail_quote">2009/11/3 Swapnil Raverkar <span dir="ltr">&lt;<a href="mailto:swapnil.raverkar@gmail.com">swapnil.raverkar@gmail.com</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;">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" target="_blank">hemanth@saha.in</a>&gt;</span><div><div></div><div class="h5"><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" target="_blank">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></div></div><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>
<br></blockquote></div><br><br clear="all"><br>-- <br>regards<br>Hemanth kumar <br><br>