Search code examples
javajpadroolsjtadrools-flow

Drools flow persistence - Named query not found: ProcessInstancesWaitingForEvent


I have a problem with drools flow persistence (MySQL), I get the following exception:

2011-04-15 14:38:27,244 INFO  [STDOUT] (http-0.0.0.0-8000-5) Hibernate: insert into ProcessInstanceInfo (externalVariables, lastModificationDate, lastReadDate, processId, processInstanceByteArray, startDate, state, OPTLOCK) values (?, ?, ?, ?, ?, ?, ?, ?)

2011-04-15 14:38:27,244 INFO  [STDOUT] (http-0.0.0.0-8000-5) Hello World

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5) java.lang.RuntimeException: Could not commit session

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:292)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:193)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.command.impl.CommandBasedStatefulKnowledgeSession.startProcess(CommandBasedStatefulKnowledgeSession.java:184)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at com.servlet.Servlet.doGet(Servlet.java:101)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:324)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:242)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:181)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.event(CatalinaContext.java:285)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.modcluster.catalina.CatalinaContext$RequestListenerValve.invoke(CatalinaContext.java:261)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:88)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:100)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.jboss.web.tomcat.service.request.ActiveRequestResponseCacheValve.invoke(ActiveRequestResponseCacheValve.java:53)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:654)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at java.lang.Thread.run(Thread.java:619)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5) Caused by: java.lang.IllegalArgumentException: Named query not found: ProcessInstancesWaitingForEvent

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.hibernate.ejb.AbstractEntityManagerImpl.createNamedQuery(AbstractEntityManagerImpl.java:455)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.persistence.processinstance.JPASignalManager.getProcessInstancesForEvent(JPASignalManager.java:32)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.persistence.processinstance.JPASignalManager.signalEvent(JPASignalManager.java:21)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.setState(WorkflowProcessInstanceImpl.java:270)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.nodeInstanceCompleted(WorkflowProcessInstanceImpl.java:421)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.node.EndNodeInstance.internalTrigger(EndNodeInstance.java:62)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:117)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:178)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:144)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.node.ActionNodeInstance.triggerCompleted(ActionNodeInstance.java:62)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.node.ActionNodeInstance.internalTrigger(ActionNodeInstance.java:58)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:117)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerConnection(NodeInstanceImpl.java:178)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.triggerCompleted(NodeInstanceImpl.java:144)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.node.StartNodeInstance.triggerCompleted(StartNodeInstance.java:49)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.node.StartNodeInstance.internalTrigger(StartNodeInstance.java:41)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.NodeInstanceImpl.trigger(NodeInstanceImpl.java:117)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.ruleflow.instance.RuleFlowProcessInstance.internalStart(RuleFlowProcessInstance.java:32)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.process.instance.impl.ProcessInstanceImpl.start(ProcessInstanceImpl.java:192)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.workflow.instance.impl.WorkflowProcessInstanceImpl.start(WorkflowProcessInstanceImpl.java:309)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.common.AbstractWorkingMemory.startProcess(AbstractWorkingMemory.java:1644)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.impl.StatefulKnowledgeSessionImpl.startProcess(StatefulKnowledgeSessionImpl.java:306)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:99)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.command.runtime.process.StartProcessCommand.execute(StartProcessCommand.java:38)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    at org.drools.persistence.session.SingleSessionCommandService.execute(SingleSessionCommandService.java:279)

2011-04-15 14:38:27,244 ERROR [STDERR] (http-0.0.0.0-8000-5)    ... 24 more

I've read everywhere that a orm.xml file must be placed in my META-INF folder (which I've done) with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
               version="1.0">
      <named-query name="ProcessInstancesWaitingForEvent">
          <query>
select
    processInstanceInfo.processInstanceId
from
    ProcessInstanceInfo processInstanceInfo
where
    :type in elements(processInstanceInfo.eventTypes)
          </query>
      </named-query>
</entity-mappings>

But it still throws that exception, you can have a look at my configuration files in a previous question I asked yesterday, HERE

This is driving me crazy, any help or ideas appreciated.


Solution

  • When you deploy to an application server, it might not always be able to pick up your orm.xml in the META-INF directory by default. The best way is to solve this is usually create a custom orm file (in this case a JBPMorm.xml in the META-INF directory) and add the mapping directly to your persistence.xml:

    <persistence-unit name="org.jbpm.persistence.jpa" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <jta-data-source>java:jdbc/testDS1</jta-data-source>        
        <mapping-file>META-INF/JBPMorm.xml</mapping-file>
        ...