Hemanth, I had a similar issue, here is a blog post... http://www.ilyasterin.com/blog/2009/10/java-multiple-class-loaders-issue.html
Hope this helps. On Tue, Nov 3, 2009 at 5:27 AM, Hemanth kumar <[email protected]> wrote: > > hi, > Im working on a sample test project. > In that im dynamically creating a class ( fact) and compiling it. > > here is my test project > -------------------------------------------------------------------------------------- > mainJavaclass > > > public void runRule() > { > try { > System.out.println("\nRunning rule\n"); > > // go ! > > URL[] urls = new URL[]{ new > URL("file://"+path) }; > > URLClassLoader ucl = new > URLClassLoader(urls); > Class<?> clazz = > ucl.loadClass("test.Message"); > Object classObj = clazz.newInstance(); > > > Method method = > clazz.getDeclaredMethod("setMessage", new Class[]{String.class}); > > //System.out.println("facts loaded\n"); > > method.invoke(classObj, new > Object[]{"Hello"}); > > > log.info("==== Calling Rule Runner ======"); > > Collection facts = new ArrayList(); > facts.add(classObj); > > > // Load and fire our rules files against the > data > new > RuleRunner().runStatelessRules(RULES_FILES, null, facts, null, null, > logger); > > } > catch (Throwable t) { > t.printStackTrace(); > } > > } > > ---------------------------------------------------------------------- > Fact > > package test; > public class Message{ > private String message; > public String getMessage(){ > return this.message; > } > > public void setMessage(String message) { > this.message = message; > } > > } > > > ------------------------------------------------------------------------ > sample rule > > package test > import test.Message; > > rule "Your First Rule" > dialect "mvel" > when > m:Message(message != "Good Bye" ) > then > System.out.println("First Rule fired "+m.message ); > modify(m){ message = "Good Bye"}; > end > ----------------------------------------------------------------- > http://old.nabble.com/file/p26160051/console.PNG console.PNG > > what happens is when i was running the project inside eclipse IDE it works > fine but when i hosted in tomcat and calling from outside ide the rule is > not getting fired. > I think the dyanamically loaded class is not recognised by the rule engine. > > suggest me any ideas or post an working example > > Hemanth > -- > View this message in context: > http://old.nabble.com/Class-loader-problem-tp26160051p26160051.html > Sent from the drools - user mailing list archive at Nabble.com. > > _______________________________________________ > rules-users mailing list > [email protected] > https://lists.jboss.org/mailman/listinfo/rules-users > _______________________________________________ rules-users mailing list [email protected] https://lists.jboss.org/mailman/listinfo/rules-users
