2 Replies Latest reply on Sep 8, 2006 11:10 AM by Andrew Bailey

    How to configure jbpm to use an extended persistence context

    Andrew Bailey Newbie

      I am trying to print out the processes defined in the JbpmContext
      and their nodes.

      I get the message

      failed to lazily initialize a collection of role: org.jbpm.graph.def.ProcessDefinition.nodes, no session or session was closed

      The bean
      public class ProcessManagerBean
      {
      @Logger
      private Log logger;

      @In(create=true)
      JbpmContext jbpmContext;

      @DataModel
      private List processList;

      @DataModelSelection
      @Out(required=false)
      private ProcessDefinition process;

      @PersistenceContext(type=EXTENDED)
      private EntityManager em;
      //not used yet

      @Out(required=false)
      private List nodeList;

      @Factory("processList")
      public void findMessages()
      {
      GraphSession graph = jbpmContext.getGraphSession();
      processList=graph.findLatestProcessDefinitions();
      }

      ....

      A fragment from the page is

      <h:dataTable id="someTable" var="proc" value="#{processList}" rendered="#{!empty processList}">
      <h:column>
      <f:facet name="header">
      <h:outputText value="Name"/>
      </f:facet>
      <h:commandLink value="#{proc.name}" action="#{processManager.select}"/>
      </h:column>
      </h:dataTable>


      <h3><h:outputText value="#{process.name}"/></h3>
      <h3><h:outputText value="#{process.nodes}"/></h3>

      The exception is caused by adding the last line

      My guess is that the jbpm session is not using an extended persistence context
      If thats the case how do I get it to use one.
      If not what is the problem.

      Thanks
      Andy Bailey
      www.hazlorealidad.com

        • 1. Re: How to configure jbpm to use an extended persistence con
          Basel Al-Mustafa Newbie

          I am not that experience with Jbpm but to have Seam us an extended persistence context, add the following to faces-config.xml:

          <lifecycle>
           <phase-listener>
           org.jboss.seam.jsf.SeamExtendedManagedPersistencePhaseListener
           </phase-listener>
          </lifecycle>
          


          Don't forget to remove the other PhaseListener, org.jboss.seam.jsf.SeamPhaseListener

          • 2. Re: How to configure jbpm to use an extended persistence con
            Andrew Bailey Newbie

            Thanks for the prompt reply but in this case it doesnt seem to be the answer, I already have those lines in the faces-config.xml

            I think jbpm handles its own connections to the datasource and I cant see how to get it to use an extended context.

            My temporary workaround is to load the process again in the current hibernate session using the name of the process.

            public void select()
            {
            GraphSession graph = jbpmContext.getGraphSession();
            processList=graph.findLatestProcessDefinitions();
            process=graph.findLatestProcessDefinition(process.getName());

            logger.info("ProcessDefinition "+process);
            //em.merge(process); this was my first try but the em is using a different configuration from jbpm and says that the class is not a persistent class
            if (process!=null)
            {
            nodeList=process.getNodes();
            ...