Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-4479

Unable to configure JBPM executor module with Spring on Wildfy.

    XMLWordPrintable

Details

    • Hide

      install wildfly,
      deploy sample spring web app with dependency to jbpm-executor modules

      Show
      install wildfly, deploy sample spring web app with dependency to jbpm-executor modules

    Description

      There is some problem with jbpm-executor module configuration in Spring managed environment. I want to use AsyncWorkItemHandler and the power of ExecutorServiceImpl for some tasks executed during the process but i'm not able to configure the executor.

      1. When I try to deploy application i get "Can't find org.jbpm.domain persitence unit" exception message. That's ok cuz i don't have such one. I have other one configure in Spring not in Weld, Is it possible to omit this ? I don't want to disable weld.

      2. If I disable Weld , i have problem with "AvailableJobsExecutor" due to following annotations:

      @Stateless
      @TransactionManagement(TransactionManagementType.BEAN)
      public class AvailableJobsExecutor {
      

      AvailableJobsExecutor is bind to JNDI ("java:module/AvailableJobsExecutor") but does not have properly injected references to dependent beans ( ExecutorQueryService , ClassCacheManager classCacheManager, ExecutorStoreService)
      (WELD is switched off so it's ok) and the follwing code in ExecutorServiceFactory doesn't allow me initialized that bean in catch block:

       public static ExecutorRunnable buildRunable(EntityManagerFactory emf) {
          	ExecutorRunnable runnable = new ExecutorRunnable();
          	AvailableJobsExecutor jobExecutor = null;
          	try {
          		jobExecutor = InitialContext.doLookup("java:module/AvailableJobsExecutor"); --------------> here it is ,I have not initialized AvailableJobsExecutor in JNDI 
          	} catch (Exception e) {
          		jobExecutor = new AvailableJobsExecutor(); //not executed code following
      	    	ClassCacheManager classCacheManager = new ClassCacheManager();
      	    	ExecutorQueryService queryService = new ExecutorQueryServiceImpl(true);
      			//// much more code..
      

      I have tried to modify that classes , by removing CDI annotations , @Produces methods , enabling Spring context in that module (jbpm-executor) and adding some code to ExecutorServiceFactory (which also implement ApplicationContextAware interface).

      	@Override
      	public final void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
      		ExecutorServiceFactory.applicationContext = applicationContext;
      	}
      
      	public static synchronized ExecutorService newService(){
      		EntityManagerFactory emf = (EntityManagerFactory) applicationContext.getBean("entityManagerFactory_JBPM");
      		if ( mode.equalsIgnoreCase( "singleton" ) ) {
      			if (serviceInstance == null) {
      				serviceInstance = configure(emf);
      				serviceInstance.init();
      			}
      			return serviceInstance;
      		} else {
      			ExecutorService executorService = configure(emf);
      			executorService.init();
      			return executorService;
      		}
      	}
      

      The code mentioned above allowed me to manually inject my EMF, and initialized ExecutorServiceImpl properly in the same way, that's would be done by Weld in Weld managed enviroment with persistence unit "org.jbpm.domain".

      But the above code when the TransactionServiceCommand is executed throw the exception:

      	
      	Caused by: java.lang.IllegalStateException: Executor is not set or is not active
              at org.jbpm.executor.impl.wih.AsyncWorkItemHandler.executeWorkItem(AsyncWorkItemHandler.java:68)  probably due to CMT but BTM is required.
      

      Is it possible to configure jbpm-executor module to work with Spring on Wildfly ?

      Below is my spring configuration.

       <bean id="jpaAdapter_JBPM"
                class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
              <property name="database" value="SQL_SERVER"/>
              <property name="showSql" value="true"/>
              <property name="generateDdl" value="false"/>
          </bean>
      
          <bean id="entityManagerFactory_JBPM"
                class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
              <property name="dataSource" ref="dataSource_JBPM"/>
              <property name="persistenceUnitName" value="org.jbpm.persistence.spring.jta"/>
              <property name="jpaVendorAdapter" ref="jpaAdapter_JBPM"/>
              <property name="mappingResources">
                  <list>
                      <!-- base jbpm tables -->
                      <value>META-INF/JBPMorm.xml</value>
                      <!--human tasks-->
                      <value>META-INF/Taskorm.xml</value>
                      <!--audit log -->
                      <value>META-INF/TaskAuditorm.xml</value>
                      <value>META-INF/Executor-orm.xml</value>
                      <!--<value>META-INF/Servicesorm.xml</value>-->
                  </list>
              </property>
      
              <property name="packagesToScan">
                  <list>
                      <value>org.drools.persistence</value>
                      <value>org.jbpm.persistence</value>
                      <value>org.jbpm.runtime</value>
                      <value>org.jbpm.process</value>
                      <value>org.jbpm.services.task</value>
      
                      <!--<value>org.jbpm.executor.entities</value>-->
                  </list>
              </property>
      
              <property name="jpaProperties">
                  <props>
                      <prop key="hibernate.hbm2ddl.auto">validate</prop>
                      <prop key="hibernate.dialect">org.hibernate.dialect.SQLServer2012Dialect</prop>
                      <prop key="hibernate.transaction.jta.platform">org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform
                      </prop>
                      <prop key="hibernate.connection.charSet">UTF-8</prop>
                      <prop key="hibernate.id.new_generator_mappings">true</prop>
                      <prop key="hibernate.ejb.entitymanager_factory_name">entityManagerFactory_JBPM</prop>
                  </props>
              </property>
          </bean>
      
          <bean id="transactionManager_JBPM" class="org.springframework.orm.jpa.JpaTransactionManager">
              <property name="entityManagerFactory" ref="entityManagerFactory_JBPM"/>
              <property name="dataSource" ref="dataSource_JBPM"/>
          </bean>
      
          <!-- JBPM enviroment conf. -->
          <bean id="process" factory-method="newClassPathResource" class="org.kie.internal.io.ResourceFactory">
              <constructor-arg>
                  <value>jbpm/MyProcess.bpmn</value>
              </constructor-arg>
          </bean>
      
      
          <bean id="runtimeEnvironment" class="org.kie.spring.factorybeans.RuntimeEnvironmentFactoryBean">
              <property name="type" value="DEFAULT"/>
              <property name="entityManagerFactory" ref="entityManagerFactory_JBPM"/>
              <property name="transactionManager" ref="transactionManager_JBPM"/>
              <property name="assets">
                  <map>
                      <entry key-ref="process">
                          <util:constant static-field="org.kie.api.io.ResourceType.BPMN2"/>
                      </entry>
                  </map>
              </property>
          </bean>
      
      
          <bean id="runtimeManager" class="org.kie.spring.factorybeans.RuntimeManagerFactoryBean" destroy-method="close">
              <property name="identifier" value="spring-rm"/>
              <property name="runtimeEnvironment" ref="runtimeEnvironment"/>
          </bean>
      
          <bean id="runtimeManagerImpl" class=my.wrapper.jbpm.RuntimeManagerFactory">
              <property name="runtimeManagerImpl" ref="runtimeManager"/>
          </bean>
      
      
          <!-- Audit LOG -->
          <bean id="logService" class="org.jbpm.process.audit.JPAAuditLogService">
              <constructor-arg>
                  <ref bean="entityManagerFactory_JBPM"/>
              </constructor-arg>
          </bean>
      

      Attachments

        Activity

          People

            swiderski.maciej Maciej Swiderski (Inactive)
            karol.kornecki Karol Kornecki (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: