1 Reply Latest reply on May 31, 2017 4:40 AM by senlog80

    drools on wildfly is not working

    senlog80

      Hi,

       

       

      I am new to drools.

      I am using drools 6.5.0 and wildfly 10.

      My drools rules are executed in eclipse perfectly.

       

       

      I am developing a REST application with drools rules and executing through REST url.

       

       

      My REST application is deployed successfully on wildfly.

      But, If I call the url, it throws the below exception in wildfly console.

       

       

      Is it mandatory to deploy KIE server for the rule execution?  Because in tomcat the same application is working fine without KIE server.

       

       

      I have the following code :

       

       

      droolsTest.java

       

       

       

       

       

          KieServices ks = KieServices.Factory.get();  // working fine

          KieContainer kContainer = ks.getKieClasspathContainer();  // Error thrown in this statement

          KieSession kSession = kContainer.newKieSession("ksession-rules");

        

          Message message = new Message();

          message.setMessage("Hello World Testing");

          message.setStatus(Message.HELLO);

          kSession.insert(message);

          kSession.fireAllRules();

          System.out.println("Drools Rules execution is Completed");

       

       

      16:32:45,757 INFO  [stdout] (default task-3) Error caught :java.lang.NoClassDefF

      oundError: Could not initialize class org.drools.compiler.kie.builder.impl.KieCo

      ntainerImpl

      16:32:45,758 ERROR [stderr] (default task-3) java.lang.NoClassDefFoundError: Cou

      ld not initialize class org.drools.compiler.kie.builder.impl.KieContainerImpl

      16:32:45,760 ERROR [stderr] (default task-3)    at org.drools.compiler.kie.build

      er.impl.KieServicesImpl.newKieClasspathContainer(KieServicesImpl.java:135)

      16:32:45,761 ERROR [stderr] (default task-3)    at org.drools.compiler.kie.build

      er.impl.KieServicesImpl.getKieClasspathContainer(KieServicesImpl.java:101)

      16:32:45,762 ERROR [stderr] (default task-3)    at org.drools.compiler.kie.build

      er.impl.KieServicesImpl.getKieClasspathContainer(KieServicesImpl.java:79)

      16:32:45,762 ERROR [stderr] (default task-3)    at com.sample.DroolsTest.drools(

      DroolsTest.java:40)

       

       

      Could any one provide your help.

       

       

      Thanks

      Senthil

        • 1. Re: drools on wildfly is not working
          senlog80

          Hi,

           

           

          I solved the issue.

          I have removed the below modules and added javax.api and org.slf4j as dependencies in my module.xml.  It is because wildfly already having these modules and loaded as part of core class loading.  Thats why there is a conflict when it is reloaded.

           

           

          Module.xml

          ----------

          Removed content :

          ------------------

          <resource-root path="xml-apis-<version>.jar">

          <resource-root path="slf4j-api-<version>.jar"/>

           

           

          Added content :

          ---------------

          <dependencies>

                   <module name="javax.api"/>

            <module name="org.slf4j"/>

            </dependencies>

           

           

          Thanks

          Senthil