title: Drools issue at runtime
body: <p>I'm using spring 3.5 + drools 6.3.0</p>
  
  <p>I have a multi-module project, where module A contains the drools definitions as well as the drl resources, this module is used by module B which has the main class.</p>
  
  <p>in development mode every thing works fine, but when the package is built and deployed It keeps throwing this exception:</p>
  
  <blockquote>
    <p>java.lang.NoClassDefFoundError: Could not initialize class org.drools.compiler.kie.util.CDIHelper$BeanCreatorHolder
        at org.drools.compiler.kie.util.CDIHelper.wireListnersAndWIHs(CDIHelper.java:45) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
        at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:594) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
        at org.drools.compiler.kie.builder.impl.KieContainerImpl.newKieSession(KieContainerImpl.java:558) ~[drools-compiler-6.3.0.Final.jar:6.3.0.Final]
        at fr.cerner.jango.ui.bi.PostProcessItemsService.getKieSession(PostProcessItemsService.java:49) ~[fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
    at fr.cerner.fides.dashboard.questionnaire.p2p.handler.ItemsPersistenceProcessor.process(ItemsPersistenceProcessor.java:37) ~[fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at fr.cerner.fides.dashboard.questionnaire.p2p.handler.PersistenceQueue.flush(PersistenceQueue.java:44) ~[fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at fr.cerner.fides.dashboard.questionnaire.p2p.aop.ItemEventsAspect.modify(ItemEventsAspect.java:67) ~[fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at fr.cerner.jango.ui.AMOComposite.handleSaveChanges(AMOComposite.java:474) [fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at fr.cerner.jango.ui.AMOComposite.access$3(AMOComposite.java:446) [fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at fr.cerner.jango.ui.AMOComposite$5.widgetSelected(AMOComposite.java:320) [fr.cerner.questionnaire-1.7.0-20151116.111758-41.jar:na]
        at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]
        at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]
        at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4353) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]
        at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1061) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]
        at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4172) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3761) [org.eclipse.swt.win32.win32.x86-3.103.2-SDK-4.4.2.jar:na]</p>
  </blockquote>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:kie="http://drools.org/schema/kie-spring"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
      http://drools.org/schema/kie-spring http://drools.org/schema/kie-spring-2.0.0.xsd"&gt;
  &lt;kie:kmodule id="questionnaireBI" &gt;
  
      &lt;kie:kbase name="pre-process" packages="rules.preprocess"
          equalsBehavior="equality"&gt; 
          &lt;kie:ksession name="preProcessKSession"   type="stateful"
              scope="prototype"&gt;
              &lt;kie:consoleLogger /&gt;
          &lt;/kie:ksession&gt;
      &lt;/kie:kbase&gt;
     .... other kbase definition omitted 
  &lt;!--pour les @KSession etc .. annotation --&gt;
  &lt;bean id="kiePostProcessor"
      class="org.kie.spring.annotations.KModuleAnnotationPostProcessor" /&gt;
  
  &lt;bean id="handleChangeEventService" class="fr.cerner.jango.ui.bi.ExonerationService" /&gt;
  &lt;bean id="checkItemsService" class="fr.cerner.jango.ui.bi.CheckItemsService" /&gt;
  &lt;bean id="itemsValidationService" class="fr.cerner.jango.ui.bi.ItemsValidationService" /&gt;
  &lt;bean id="postProcessItemsService" class="fr.cerner.jango.ui.bi.PostProcessItemsService" /&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and this is my imports:</p>
  
  <pre><code>&lt;!-- drools engine --&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.kie&lt;/groupId&gt;
      &lt;artifactId&gt;kie-api&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.kie&lt;/groupId&gt;
      &lt;artifactId&gt;kie-spring&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.drools&lt;/groupId&gt;
      &lt;artifactId&gt;drools-core&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.drools&lt;/groupId&gt;
      &lt;artifactId&gt;drools-compiler&lt;/artifactId&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.drools&lt;/groupId&gt;
      &lt;artifactId&gt;drools-verifier&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p><strong>update</strong></p>
  
  <p>Here is how do I initialize the KSession ( tried injection as well )</p>
  
  <pre><code>// placed here to early initialize the engine
  @PostConstruct
  public void postConstruct() {
      factory = org.kie.api.KieServices.Factory.get();
      container = factory.getKieClasspathContainer();
      //
      // container = factory.getKieClasspathContainer(
      // ProjectClassLoader.getClassLoader(CDIHelper.class.getClassLoader(),
      // ExonerationService.class, true));
  
      Executors.newSingleThreadExecutor().execute(new Runnable() {
          @Override
          public void run() {
              KieSession kieSession = getKieSession();
              kieSession.dispose();
          }
      });
  }
  
  private KieSession getKieSession() {
      return container.newKieSession("preProcessKSession");// context.getBean("preProcessKSession",
                                                              // KieSession.class);
  }
  </code></pre>
  
  <p>any idea or leads are much appreciated.</p>