0 Replies Latest reply on Nov 18, 2007 10:11 PM by Calvin Lee

    LazyInitializationExceptions while using JbpmTemplate (JBPM

    Calvin Lee Newbie

      I have my JbpmTemplate configured correctly in my spring application context and I can inject it into my Spring controllers and other beans, but I am having troubles with LazyInitializationExceptions when using the JbpmTemplate.findProcessInstance(long id) method.
      The test code is like that:
      ===================
      public class TestProcessServiceImpl extends TestCase {

      private ApplicationContext applicationContext;
      private JbpmTemplate jbpmTemplate;

      protected void setUp() throws Exception {
      super.setUp();
      applicationContext = new ClassPathXmlApplicationContext("platform_workflow_ manager_local.xml");
      out.println("Creating ApplicationContex-------"+applicationContext );
      jbpmTemplate = (JbpmTemplate)applicationContext.getBean("jbpmTemp late");
      }

      public void testTemplate(){
      ProcessInstance p =jbpmTemplate.findProcessInstance(1L);
      out.println("======="+p.getId());
      }
      }

      it throws exceptions:
      ERROR [org.hibernate.LazyInitializationException] - <could not initialize proxy - the owning Session was closed>
      org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
      at org.hibernate.proxy.AbstractLazyInitializer.initia lize(AbstractLazyInitializer.java:60)
      at org.hibernate.proxy.AbstractLazyInitializer.getImp lementation(AbstractLazyInitializer.java:111)
      at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitialize r.invoke(CGLIBLazyInitializer.java:150)
      at org.jbpm.graph.exe.ProcessInstance$$EnhancerByCGLI B$$5d7ec21a.toString()
      ============
      And the config files likes:
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

      <beans default-autowire="no" default-lazy-init="false"
      default-dependency-check="none">



      net.sourceforge.jtds.jdbc.Driver


      jdbc:jtds:sqlserver://localhost:1433/jbpmdemo


      sa


      sa


      <!-- Hibernate SessionFactory -->







      classpath:workflow/hibernate.cfg.xml



      <!-- TODO -->



      org.hibernate.dialect.SQLServerDialect


      true
      <!--

      org.hibernate.cache.HashtableCacheProvider

      -->

      org.hibernate.cache.EhCacheProvider


      org.hibernate.hql.ast.ASTQueryTranslatorFactory





      <!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->













      <constructor-arg index="0" ref="jbpmConfiguration" />



      ========
      Any suggestions why i might be experiencing these errors?

      thanks in advance