7 Replies Latest reply on May 13, 2015 7:21 AM by awizenm

    How to use/bind the DeploymentService in the CDI environment in jBPM 6.2

    awizenm

      I miss another piece of the puzzle.

       

      In my CDI based application the execution of the process fails probably because of still misconfigured environment.

       

      Meanwhile I mange to start my process in my application. The first task is created. To complete the task I use UserTaskService (as suggested by Jimmy in https://developer.jboss.org/thread/255891)

       

      Unfortunately the injected UserTaskService is not able to complete the task because it is not able to find a RuntimeManager for the task (see the complete implementation in UserTaskServiceImpl). This is because the deployment service is not aware of my process???

       

      Why is the process unknown to the deployment service?

      Is there a bug in the RuntimeEnvironmentBuilder? Or is it a feature?

       

      This is how I produce the RuntimeEnvironment:

       

       

      @Produces
      @Singleton
      @PerRequest
      @PerProcessInstance
      public RuntimeEnvironment produceEnvironment(EntityManagerFactory emf) {
      
          Environment env = EnvironmentFactory.newEnvironment();
          env.set(EnvironmentName.TRANSACTION_MANAGER, new ContainerManagedTransactionManager());
          env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
          
          JpaProcessPersistenceContextManager jpaProcessPersistenceContextManager = new JpaProcessPersistenceContextManager(env);
          JPATaskPersistenceContextManager jpaTaskPersistenceContextManager = new JPATaskPersistenceContextManager(env);
      
          env.set(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, jpaProcessPersistenceContextManager);
          env.set(EnvironmentName.TASK_PERSISTENCE_CONTEXT_MANAGER, jpaTaskPersistenceContextManager);
      
          RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get()
                  .newDefaultBuilder()
                  .userGroupCallback(userGroupCallback())
                  .addEnvironmentEntry(EnvironmentName.TRANSACTION_MANAGER, new ContainerManagedTransactionManager())
                  .addEnvironmentEntry(EnvironmentName.TASK_PERSISTENCE_CONTEXT_MANAGER, jpaTaskPersistenceContextManager)
                  .addEnvironmentEntry(EnvironmentName.PERSISTENCE_CONTEXT_MANAGER, jpaProcessPersistenceContextManager)
                  .entityManagerFactory(emf)
                  .registerableItemsFactory(factory)
                  .addAsset(ResourceFactory.newClassPathResource("myProcess.bpmn"), ResourceType.BPMN2).get();
      
          return environment;
      }
      
      
      
      

       

       

      By the way: there are no problems with execution of the same process in the test class based on JbpmJUnitBaseTestCase

       

      Any suggestions?