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.<init>(AbstractWorkingMemory.java:367)
15:39:05,884 ERROR [STDERR] at
org.drools.common.AbstractWorkingMemory.<init>(AbstractWorkingMemory.java:295)
15:39:05,884 ERROR [STDERR] at
org.drools.common.AbstractWorkingMemory.<init>(AbstractWorkingMemory.java:259)
15:39:05,884 ERROR [STDERR] at
org.drools.reteoo.ReteooWorkingMemory.<init>(ReteooWorkingMemory.java:96)
15:39:05,885 ERROR [STDERR] at
org.drools.reteoo.ReteooStatefulSession.<init>(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.<init>(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<ProcessInstanceManagerFactory> cls =
(Class<ProcessInstanceManagerFactory>)
Class.forName("org.drools.persistence.processinstance.JPAProcessInstanceManagerFactory");
// this one is OK
ProcessInstanceManagerFactory pimf =
(ProcessInstanceManagerFactory)cls.newInstance();
System.out.println(pimf.getClass().getCanonicalName());
cls =
(Class<ProcessInstanceManagerFactory>)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.
--
View this message in context:
http://drools-java-rules-engine.46999.n3.nabble.com/ClassCastException-in...
Sent from the Drools - User mailing list archive at
Nabble.com.