JBoss Community

Re: Error creating bean with name 'taskResourceFactory' defined in class path resource [META-INF/spring/applicationContext.xml]

created by Kris Verlaenen in jBPM - View the full discussion

Hi,

 

I wasn't able to reproduce the exact issue (due to some missing classes and not having the same context setup), but here's an example that successfully loads the human task service:

 

        ClassPathXmlApplicationContext context =

            new ClassPathXmlApplicationContext("spring-conf.xml");

       

        TaskSessionSpringFactoryImpl springFactory =

            (TaskSessionSpringFactoryImpl) context.getBean("springTaskSessionFactory");      

        springFactory.initialize();

               

        org.jbpm.task.service.TaskService internalTaskService =

            (org.jbpm.task.service.TaskService) context.getBean("taskService");

        TaskService taskService = new LocalTaskService(internalTaskService);

        System.out.println("Done setting up " + taskService);

 

With the following spring configuration file

 

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

       xmlns:jbpm="http://drools.org/schema/drools-spring"      

       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd

                           http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.5.0.xsd">

 

  <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

    <property name="driverClassName" value="org.h2.Driver"/>

    <property name="url" value="jdbc:h2:tcp://localhost/~/jbpm-db"/>

    <property name="username" value="sa"/>

    <property name="password" value=""/>

  </bean>

   

  <bean id="jbpmEMF" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">

    <property name="dataSource" ref="dataSource"/>

    <property name="persistenceUnitName" value="org.jbpm.persistence.jpa.local"/>

  </bean>

 

  <bean id="jbpmTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">

    <property name="entityManagerFactory" ref="jbpmEMF"/>

    <property name="nestedTransactionAllowed" value="false"/>

  </bean>

 

  <bean id="htTxMgr" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager">

    <constructor-arg ref="jbpmTxManager" />

  </bean>

 

  <bean id="systemEventListener" class="org.drools.SystemEventListenerFactory" factory-method="getSystemEventListener" />

  <bean id="taskService" class="org.jbpm.task.service.TaskService" >

    <property name="systemEventListener" ref="systemEventListener" />

  </bean>

   

  <bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl" depends-on="taskService" >

    <property name="entityManagerFactory" ref="jbpmEMF" />

    <property name="transactionManager" ref="htTxMgr" />

    <property name="useJTA" value="true" />

    <property name="taskService" ref="taskService" />

  </bean>

 

</beans>

 

Hope this helps.

 

Kris

Reply to this message by going to Community

Start a new discussion in jBPM at Community