URL[] urls = new URL[]{ new URL("file://"+path)

Are you using relative or absolute paths for classLoaders?

Did you check that the paths are valid when you deploy your application in Tomcat container?


Cheers,

Swapnil

2009/11/4 Hemanth kumar <hemanth@saha.in>

swapnil thanx for the reply,
this is my modified code

try{

           System.out.println("Initializing Fact....");


           URL[] urls = new URL[]{ new URL("file://"+path) };
            ClassLoader loader =  new URLClassLoader(urls);
            Class clazz  = loader.loadClass("test.Message");
                             //Class.forName("test.Message", false, ucl);
            Object factObj = clazz.newInstance();
            String ruleFile = "test/Sample.drl";

            Method method = clazz.getMethod("setMessage", new
Class[]{String.class});
            Method method1 = clazz.getMethod("getMessage");

            //System.out.println("facts loaded\n");

            method.invoke(factObj, new Object[]{"Hello"});

            System.out.println("initializing packageBuilder");

            PackageBuilderConfiguration config = new
PackageBuilderConfiguration();
            config.setClassLoader(loader);

           KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(config);

           System.out.println("finding Rule");

kbuilder.add(ResourceFactory.newClassPathResource("test/Sample.drl"),ResourceType.DRL);

           if (kbuilder.hasErrors())
                 throw new RuntimeException("Unable to compile rules. " +
                           kbuilder.getErrors().toString());


           KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(new
RuleBaseConfiguration(loader));

           kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());

           StatelessKnowledgeSession session =
kbase.newStatelessKnowledgeSession();

           System.out.println("running rule....... \n");
            session.execute(factObj);

            System.out.println("\nend...\n");
            System.out.println(method1.invoke(factObj).toString());

       }
       catch (Throwable t) {
           t.printStackTrace();
       }

------------------------------------------------------------
Added the following JARS in WEB-INF\lib

antlr-runtime-3.1.1.jar
core-3.4.2.v_883_R34x.jar
drools-api-5.0.1.jar
drools-core-5.0.1.jar
drools-decisiontables-5.0.1.jar
mvel2-2.0.10.jar
drools-compiler-5.0.1.jar
xstream-1.3.1.jar



thanx and regards
Hemanth
--
View this message in context: http://old.nabble.com/Class-loader-problem-tp26160051p26191859.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users