Avneesh Sisodia [https://community.jboss.org/people/avneesh] created the discussion
"Error creating bean with name 'taskResourceFactory' defined in class path resource [META-INF/spring/applicationContext.xml]" To view the discussion, visit: https://community.jboss.org/message/761043#761043 -------------------------------------------------------------- Hi, When I am trying to create Local Task Service for jbpm human task using spring framework. It throwing exception. I have a java class TaskResourceFactory.java public class TaskResourceFactory implements ApplicationContextAware { private static final Logger logger = LoggerFactory.getLogger(TaskResourceFactory.class); private static ApplicationContext context; private static TaskService taskService; private static AbstractPlatformTransactionManager transactionManager; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.context = applicationContext; } public TaskResourceFactory(TaskService tService, AbstractPlatformTransactionManager tManager) { TaskResourceFactory.taskService = tService; TaskResourceFactory.transactionManager = tManager; } public static LocalTaskService getTaskClient(TaskService taskService, AbstractPlatformTransactionManager transactionManager) { initializeSessionFactory(transactionManager); logger.debug("Creating local task service client, based on {}",taskService); LocalTaskService returnBean = new LocalTaskService(taskService); logger.debug("Returning task client: {}", returnBean.toString()); return returnBean; } public static void initializeSessionFactory(AbstractPlatformTransactionManager transactionManager) { logger.debug("Initializing the session factory"); TaskSessionSpringFactoryImpl springFactory = (TaskSessionSpringFactoryImpl) context.getBean("springTaskSessionFactory"); logger.debug("Setting the transaction manager, based on {}",transactionManager); TransactionManager taskTx = new DroolsSpringTransactionManager(transactionManager); springFactory.setTransactionManager(taskTx); logger.debug("Initializing"); springFactory.initialize(); } public TaskService getTaskService() { return taskService; } public void setTaskService(TaskService taskService) { this.taskService = taskService; } public AbstractPlatformTransactionManager getTransactionManager() { return transactionManager; } public void setTransactionManager( AbstractPlatformTransactionManager transactionManager) { this.transactionManager = transactionManager; } When *springFactory* object is to be create it throwing exception. my applicationContext.xml is: <bean id="transactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"> <property name="transactionManagerName" value="java:jboss/TransactionManager"/> </bean> <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:jboss/datasources/RI"/> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="generateDdl" value="true" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <property name="persistenceUnitName" value="jbpm" /> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter" ref="jpaVendorAdapter" /> </bean> <bean id="jpaTxMgr" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> <property name="nestedTransactionAllowed" value="true"/> </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="htEm" class="org.springframework.orm.jpa.support.SharedEntityManagerBean"> <property name="entityManagerFactory" ref="entityManagerFactory"/> </bean> <bean id="htTxMgr" class="org.drools.container.spring.beans.persistence.HumanTaskSpringTransactionManager"> <constructor-arg ref="transactionManager" /> </bean> <bean id="springTaskSessionFactory" class="org.jbpm.task.service.persistence.TaskSessionSpringFactoryImpl" depends-on="taskService" > <property name="transactionManager" ref="htTxMgr" /> <property name="useJTA" value="true" /> <property name="taskService" ref="taskService" /> </bean> <bean id="taskResourceFactory" class="com.nijhazer.jbpm.quickstart.TaskResourceFactory" factory-method="getTaskClient"> <constructor-arg type="org.jbpm.task.service.TaskService" ref="taskService" /> <constructor-arg type="org.springframework.transaction.support.AbstractPlatformTransactionManager" ref="transactionManager" /> </bean> stacktrace is: 13:18:57,120 INFO [stdout] (MSC service thread 1-1) org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskResourceFactory' defined in class path resource [META-INF/spring/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static org.jbpm.task.service.local.LocalTaskService com.nijhazer.jbpm.quickstart.TaskResourceFactory.getTaskClient (org.jbpm.task.service.TaskService,org.springframework.transaction.support.AbstractPlatformTransactionManager)] threw exception; nested exception is java.lang.NullPointerException 13:18:57,120 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:581) 13:18:57,120 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod (AbstractAutowireCapableBeanFactory.java:1015) 13:18:57,120 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance (AbstractAutowireCapableBeanFactory.java:911) 13:18:57,120 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485) 13:18:57,120 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) 13:18:57,121 INFO [stdout] (MSC service thread 1-1) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3368) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.apache.catalina.core.StandardContext.start(StandardContext.java:3821) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:70) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) at java.lang.Thread.run(Thread.java:662) 13:18:57,122 INFO [stdout] (MSC service thread 1-1) Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public static org.jbpm.task.service.local.LocalTaskService com.nijhazer.jbpm.quickstart.TaskResourceFactory.getTaskClient (org.jbpm.task.service.TaskService,org.springframework.transaction.support.AbstractPlatformTransactionManager)] threw exception; nested exception is java.lang.NullPointerException 13:18:57,123 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:169) 13:18:57,123 INFO [stdout] (MSC service thread 1-1) at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:570) 13:18:57,123 INFO [stdout] (MSC service thread 1-1) ... 22 more 13:18:57,123 INFO [stdout] (MSC service thread 1-1) Caused by: java.lang.NullPointerException -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/761043#761043] Start a new discussion in jBPM at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user