<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:View>Normal</w:View>
  <w:Zoom>0</w:Zoom>
  <w:PunctuationKerning/>
  <w:ValidateAgainstSchemas/>
  <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
  <w:IgnoreMixedContent>false</w:IgnoreMixedContent>
  <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:DontGrowAutofit/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:LatentStyles DefLockedState="false" LatentStyleCount="156">
 </w:LatentStyles>
</xml><![endif]--><!--[if gte mso 10]>
<style>
 /* Style Definitions */
 table.MsoNormalTable
        {mso-style-name:"Обычная таблица";
        mso-tstyle-rowband-size:0;
        mso-tstyle-colband-size:0;
        mso-style-noshow:yes;
        mso-style-parent:"";
        mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
        mso-para-margin:0cm;
        mso-para-margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.0pt;
        font-family:"Times New Roman";
        mso-ansi-language:#0400;
        mso-fareast-language:#0400;
        mso-bidi-language:#0400;}
</style>
<![endif]--><span style="font-size: 12pt; font-family: &quot;Times New
      Roman&quot;;" lang="EN-US">I have solved the
      problem. The problem arises because of drool-core.jar files
      duplication – I’ve
      got one in jboss lib and another one in webapp lib. </span><br>
    <br>
    <blockquote cite="mid:1293440471110-2150934.post@n3.nabble.com"
      type="cite">
      <pre wrap="">
I’m trying to create StatefulKnowledgeSession:

StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(
                    kbase, null, env);

Here is the problem as it seen in the log:

15:39:05,884 ERROR [STDERR] Caused by: java.lang.IllegalArgumentException:
Unable to instantiate process instance manager factory
'org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory'
15:39:05,884 ERROR [STDERR]         at
org.drools.SessionConfiguration.initProcessInstanceManagerFactory(SessionConfiguration.java:317)
15:39:05,884 ERROR [STDERR]         at
org.drools.SessionConfiguration.getProcessInstanceManagerFactory(SessionConfiguration.java:291)
15:39:05,884 ERROR [STDERR]         at
org.drools.common.AbstractWorkingMemory.&lt;init&gt;(AbstractWorkingMemory.java:367)
15:39:05,884 ERROR [STDERR]         at
org.drools.common.AbstractWorkingMemory.&lt;init&gt;(AbstractWorkingMemory.java:295)
15:39:05,884 ERROR [STDERR]         at
org.drools.common.AbstractWorkingMemory.&lt;init&gt;(AbstractWorkingMemory.java:259)
15:39:05,884 ERROR [STDERR]         at
org.drools.reteoo.ReteooWorkingMemory.&lt;init&gt;(ReteooWorkingMemory.java:96)
15:39:05,885 ERROR [STDERR]         at
org.drools.reteoo.ReteooStatefulSession.&lt;init&gt;(ReteooStatefulSession.java:80)
15:39:05,885 ERROR [STDERR]         at
org.drools.reteoo.ReteooRuleBase.newStatefulSession(ReteooRuleBase.java:386)
15:39:05,885 ERROR [STDERR]         at
org.drools.reteoo.ReteooRuleBase.newStatefulSession(ReteooRuleBase.java:371)
15:39:05,885 ERROR [STDERR]         at
org.drools.persistence.session.SingleSessionCommandService.&lt;init&gt;(SingleSessionCommandService.java:97)

Exception is thrown from here:

private void initProcessInstanceManagerFactory() {

...

        if ( clazz != null ) {
            try {
                this.processInstanceManagerFactory = clazz.newInstance();
            } catch ( Exception e ) {
                throw new IllegalArgumentException( "Unable to instantiate
process instance manager factory '" + className + "'" );
            }

...

 }

And the actual Exception type is ClassCastException
java.lang.ClassCastException:
org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory
cannot be cast to org.drools.process.instance.ProcessInstanceManagerFactory

I’ve created the following snippet to illustrate the problem:

…running inside JTA transaction

Class&lt;ProcessInstanceManagerFactory&gt; cls =
(Class&lt;ProcessInstanceManagerFactory&gt;)
Class.forName("org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory");
            
// this one is OK

ProcessInstanceManagerFactory pimf =
(ProcessInstanceManagerFactory)cls.newInstance();
            
System.out.println(pimf.getClass().getCanonicalName());
            
cls =
(Class&lt;ProcessInstanceManagerFactory&gt;)Thread.currentThread().getContextClassLoader().loadClass("org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory"
); 
            
// here will be ClassCastException

pimf = (ProcessInstanceManagerFactory)cls.newInstance();
            
System.out.println(pimf.getClass().getCanonicalName());

It seems that ProcessInstanceManagerFactory interface and
JPAProcessInstanceManagerFactory are loaded by different class loaders. 

How can I avoid that problem? 

I'm using Drool Flow 5.1.1, JBoss 6.0, Hibernate 3.6.0.

</pre>
    </blockquote>
    <br>
  </body>
</html>