[JBoss jBPM] - Re: JBPM4 Spring-Hibernate Integration
by faisalgeek
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmSessionFactory' defined in class path resource [com/netsol/unittest/config/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: proxy class not found: org.jbpm.jpdl.internal.model.JpdlExecution
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:213)
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:189)
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:169)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:98)
at junit.framework.TestCase.runBare(TestCase.java:132)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.MappingException: proxy class not found: org.jbpm.jpdl.internal.model.JpdlExecution
at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:109)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:117)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
... 31 more
Caused by: java.lang.ClassNotFoundException: org.jbpm.jpdl.internal.model.JpdlExecution
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:106)
... 46 more
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250532#4250532
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250532
16 years, 7 months
[JBoss jBPM] - And this excepton too.
by faisalgeek
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jbpmSessionFactory' defined in class path resource [com/netsol/unittest/config/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: proxy class not found: org.jbpm.jpdl.internal.model.JpdlExecution
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:540)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:407)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:213)
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:189)
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:169)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:140)
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:98)
at junit.framework.TestCase.runBare(TestCase.java:132)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: org.hibernate.MappingException: proxy class not found: org.jbpm.jpdl.internal.model.JpdlExecution
at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:109)
at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:117)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.(AbstractEntityTuplizer.java:135)
at org.hibernate.tuple.entity.PojoEntityTuplizer.(PojoEntityTuplizer.java:55)
at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.(EntityEntityModeToTuplizerMapping.java:56)
at org.hibernate.tuple.entity.EntityMetamodel.(EntityMetamodel.java:302)
at org.hibernate.persister.entity.AbstractEntityPersister.(AbstractEntityPersister.java:434)
at org.hibernate.persister.entity.SingleTableEntityPersister.(SingleTableEntityPersister.java:109)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:753)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:691)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1390)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1359)
... 31 more
Caused by: java.lang.ClassNotFoundException: org.jbpm.jpdl.internal.model.JpdlExecution
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:100)
at org.hibernate.mapping.PersistentClass.getProxyInterface(PersistentClass.java:106)
... 46 more
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250531#4250531
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250531
16 years, 7 months
[JBoss jBPM] - Re: JBPM4 Spring-Hibernate Integration
by faisalgeek
I done the config that told in Adre Inze's tutorial, but getting the following exception.....
org.jbpm.api.JbpmException: No platformTransaction manager defined.
at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:60)
at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:54)
at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:55)
at org.jbpm.pvm.internal.svc.TaskServiceImpl.newTask(TaskServiceImpl.java:63)
at com.netsol.manager.wf.BPMService.dumyTask(BPMService.java:31)
at com.netsol.unittest.bpm.BPMTest.testBPMService(BPMTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:91)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250530#4250530
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250530
16 years, 7 months
[JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
by mr_magoo
Finally, the spring config to tie it all together which has hopefully survived sanitation intact. :) You will not the class names of the above classes have been fudged to protect the innocent.
Notes:
I also do not claim this is the perfect solution. There are probably further optimisations that could be made to reduce the size/complexity.
We create our own object factory and define various properties in spring.
The default jbpm context has the services injected manually to catch code that ignores the object factory. They are all named THE SAME as they would be in the jbpm config file. This is so our custom object factory will pick them up. You could rename them and put them into the objectfactory's map also.
<?xml version="1.0" encoding="UTF-8"?>
| <beans>
| <bean id="jbpmConfiguration" class="JbpmConfigurationFactoryBeanImpl">
| <property name="transactionTemplate" ref="transactionTemplate" />
| <property name="sessionFactory" ref="jBPMSessionFactory" />
| <property name="startJobExecutor" value="true" />
| <property name="objectFactory" ref="springJbpmObjectFactory" />
| <property name="processDefinitionsResources">
| <list>
| <value>classpath:where is my xml???</value>
| </list>
| </property>
| </bean>
| <bean id="springJbpmObjectFactory" class="SpringObjectFactory">
| <property name="jbpmProperties">
| <map>
| <entry key="jbpm.hide.stale.object.exceptions">
| <bean class="java.lang.Boolean"><constructor-arg value="true" /></bean>
| </entry>
| <entry key="resource.business.calendar" value="org/jbpm/calendar/jbpm.business.calendar.properties" />
| <entry key="resource.default.modules" value="org/jbpm/graph/def/jbpm.default.modules.properties" />
| <entry key="resource.converter" value="org/jbpm/db/hibernate/jbpm.converter.properties" />
| <entry key="resource.action.types" value="org/jbpm/graph/action/action.types.xml" />
| <entry key="resource.node.types" value="org/jbpm/graph/node/node.types.xml" />
| <entry key="resource.parsers" value="org/jbpm/jpdl/par/jbpm.parsers.xml" />
| <entry key="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml" />
| <entry key="resource.mail.templates" value="jbpm.mail.templates.xml" />
| <entry key="jbpm.mail.smtp.host" value="localhost" />
| <entry key="jbpm.mail.from.address" value="jbpm@noreply" />
| <entry key="jbpm.byte.block.size">
| <bean class="java.lang.Integer"><constructor-arg value="1024" /></bean>
| </entry>
| <entry key="jbpm.mail.address.resolver">
| <bean class="org.jbpm.identity.mail.IdentityAddressResolver"></bean>
| </entry>
| <entry key="jbpm.variable.resolver">
| <bean class="org.jbpm.jpdl.el.impl.JbpmVariableResolver"></bean>
| </entry>
| <entry key="jbpm.task.instance.factory">
| <bean class="org.jbpm.taskmgmt.impl.DefaultTaskInstanceFactoryImpl"></bean>
| </entry>
| </map>
| </property>
| </bean>
| <bean id="default.jbpm.context" class="org.jbpm.JbpmContext" scope="prototype">
| <constructor-arg>
| <bean class="org.jbpm.svc.Services">
| <constructor-arg>
| <map>
| <entry key="message" value-ref="message" />
| <entry key="authentication" value-ref="authentication" />
| <entry key="scheduler" value-ref="scheduler" />
| <entry key="tx" value-ref="tx" />
| <entry key="persistence" value-ref="persistence" />
| </map>
| </constructor-arg>
| </bean>
| </constructor-arg>
| <constructor-arg ref="springJbpmObjectFactory" />
| </bean>
| <bean id="jbpmCommandService" class="org.jbpm.command.impl.CommandServiceImpl">
| <constructor-arg ref="jbpmConfiguration" />
| </bean>
| <bean id="jbpm.job.executor" class="SpringJobExecutor">
| <property name="transactionTemplate" ref="transactionTemplate" />
| <property name="jbpmConfiguration" ref="jbpmConfiguration" />
| <property name="name" value="SpringJbpmJobExecutor" />
| <property name="nbrOfThreads" value="40" />
| <property name="idleInterval" value="5000" />
| <property name="maxIdleInterval" value="1700000" />
| <property name="historyMaxSize" value="20" />
| <property name="maxLockTime" value="300000" />
| <property name="lockMonitorInterval" value="60000" />
| <property name="lockBufferTime" value="5000" />
| </bean>
| <!-- services -->
| <bean id="persistence" class="org.jbpm.persistence.db.DbPersistenceServiceFactory">
| <property name="sessionFactory" ref="jBPMSessionFactory" />
| <property name="transactionEnabled" value="false" />
| <property name="currentSessionEnabled" value="true" />
| </bean>
| <bean id="authentication" class="org.jbpm.security.authentication.DefaultAuthenticationServiceFactory" />
| <bean id="message" class="org.jbpm.msg.db.DbMessageServiceFactory" />
| <bean name="tx" class="org.jbpm.tx.TxServiceFactory" />
| <bean name="scheduler" class="org.jbpm.scheduler.db.DbSchedulerServiceFactory" />
| </beans>
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250517#4250517
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250517
16 years, 7 months
[JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
by mr_magoo
The horribly ugly delegation node...
public class JbpmSpringDelegationNode implements DecisionHandler, ActionHandler, AssignmentHandler {
| private static final long serialVersionUID = 1L;
|
| private String beanName;
| protected static BeanFactory beanFactory;
| private Object bean;
|
| public String decide(ExecutionContext executionContext) throws Exception {
| DecisionHandler dh = getBean();
| return dh.decide(executionContext);
| }
| public void execute(ExecutionContext executionContext) throws Exception {
| ActionHandler ah = getBean();
| ah.execute(executionContext);
| }
| public void assign(Assignable assignable, ExecutionContext executionContext) throws Exception {
| AssignmentHandler ah = getBean();
| ah.assign(assignable, executionContext);
| }
| @SuppressWarnings("unchecked")
| private <T> T getBean() {
| if (bean == null) {
| bean = beanFactory.getBean(beanName);
| }
| return (T) bean;
| }
| public String getBeanName() {
| return beanName;
| }
| public void setBeanName(String beanName) {
| this.beanName = beanName;
| }
|
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250516#4250516
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250516
16 years, 7 months
[JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
by mr_magoo
Other java classes we use that are almost the same or identical as the ones in the articles. Just for completeness.
Lock monitor thread:
public class SpringLockMonitorThread extends LockMonitorThread {
| private TransactionTemplate transactionTemplate;
|
| public SpringLockMonitorThread(JbpmConfiguration jbpmConfiguration,
| int lockMonitorInterval, int maxLockTime, int lockBufferTime, TransactionTemplate transactionTemplate) {
| super(jbpmConfiguration, lockMonitorInterval, maxLockTime,lockBufferTime);
| this.transactionTemplate = transactionTemplate;
| }
| @Override
| protected void unlockOverdueJobs() {
| transactionTemplate.execute(new TransactionCallback() {
| public Object doInTransaction(TransactionStatus transactionStatus) {
| SpringLockMonitorThread.super.unlockOverdueJobs();
| return null;
| }
| });
| }
| public void setTransactionTemplate(TransactionTemplate transactionTemplate) {
| this.transactionTemplate = transactionTemplate;
| }
| }
|
Job executor:
public class SpringJobExecutor extends JobExecutor {
| private TransactionTemplate transactionTemplate;
|
| @Override
| public synchronized void start() {
| if (!isStarted) {
| for (int i = 0; i < nbrOfThreads; i++) {
| startThread();
| }
| lockMonitorThread = new SpringLockMonitorThread(jbpmConfiguration, lockMonitorInterval, maxLockTime, lockBufferTime, transactionTemplate);
| isStarted = true;
| }
| }
| @Override
| protected Thread createThread(String threadName) {
| log.info("Creating JobExecutor thread " + threadName);
| return new GfgSpringExecutorThread(threadName, this, jbpmConfiguration, transactionTemplate, idleInterval, maxIdleInterval, maxLockTime, historyMaxSize);
| }
| public void setTransactionTemplate(TransactionTemplate transactionTemplate) {
| this.transactionTemplate = transactionTemplate;
| }
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250515#4250515
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250515
16 years, 7 months
[JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
by mr_magoo
The next is the object factory. We use a map object to store the various nebulous properties that are required as well as getting those core, spring injected service factories in there.
The map makes specifying boolean and string properties a little cleaner and allows us to remove some ugly naming in our core spring config file that would otherwise be needed.
public class SpringObjectFactory implements ObjectFactory, ApplicationContextAware {
|
| private ApplicationContext applicationContext;
| private Map<String, Object> jbpmProperties;
|
| @Override
| public Object createObject(String objectName) {
| if (getJbpmProperties().containsKey(objectName)) {
| return getJbpmProperties().get(objectName);
| }
| else if (getApplicationContext().containsBean(objectName)) {
| return getApplicationContext().getBean(objectName);
| }
| else {
| return null;
| }
| }
| @Override
| public boolean hasObject(String objectName) {
| return
| getJbpmProperties().containsKey(objectName)||
| getApplicationContext().containsBean(objectName);
| }
| public void setJbpmProperties(Map<String, Object> jbpmProperties) {
| this.jbpmProperties = jbpmProperties;
| }
| public Map<String, Object> getJbpmProperties() {
| return jbpmProperties;
| }
| @Override
| public void setApplicationContext(ApplicationContext applicationContext) {
| this.applicationContext = applicationContext;
| }
| public ApplicationContext getApplicationContext() {
| return applicationContext;
| }
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250514#4250514
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250514
16 years, 7 months
[JBoss jBPM] - Re: Solution: JBPM3 and Spring Integration
by mr_magoo
The next issue is the extension of the jbpm configuration object.
In this example I would like my configuration to autodeploy my process definitions at startup and fail with warnings if something is not right. I would also like the option of safely starting the jobexecutor AFTER everything is deployed and safe for processing jobs that may have already been queued up.
Notes:
The object factory being injected is our own custom one that I will talk about next.
The line:
JbpmConfiguration.Configs.setDefaultObjectFactory(objectFactory);
Is necessary because I noticed jbpm attempting to use the default factory if it was not set. This step was the one that was preventing me from completely removing all dependency on an xml file and caused some subtle transaction bugs.
A bit random to be honest and I have not looked deeply into why it is trying to undermine my config behind my back. Nasty little troll...
JbpmSpringDelegationNode.beanFactory = applicationContext;
This is the bit of code I am most unhappy with. Basically there is no way currently (unlike in jbpm4) to hook the process def lookup to the spring beanfactory. So we have to inject it manually.
The new Spring 2.5/3.0 configuration annotations could be used here to force injection of properties, but we do not use them. Until then...yuck.
public class JbpmConfigurationFactoryBeanImpl implements ApplicationContextAware, FactoryBean, InitializingBean, ApplicationListener {
| private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(JbpmConfigurationFactoryBeanImpl.class);
|
| private JbpmConfiguration jbpmConfiguration;
| private TransactionTemplate transactionTemplate;
| private ObjectFactory objectFactory;
| private boolean startJobExecutor;
| private SessionFactory sessionFactory;
|
| private Resource[] processDefinitionsResources;
|
| @Override
| public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
| JbpmSpringDelegationNode.beanFactory = applicationContext;
| }
|
| public void afterPropertiesSet() throws Exception {
| JbpmConfiguration.Configs.setDefaultObjectFactory(objectFactory);
| jbpmConfiguration = new JbpmConfiguration(objectFactory);
| JbpmContext ctx = null;
| try {
| ctx = jbpmConfiguration.createJbpmContext();
| ctx.setSessionFactory(sessionFactory);
| } finally {
| if (ctx != null) {
| ctx.close();
| }
| }
| if (getProcessDefinitionsResources() != null) {
| InputStream inputStream = null;
| for (int i = 0; i < getProcessDefinitionsResources().length; i++) {
| try {
| ctx = jbpmConfiguration.createJbpmContext();
| Resource definitionLocation = getProcessDefinitionsResources();
| inputStream = definitionLocation.getInputStream();
| final ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(inputStream);
| final JbpmContext finalContext = ctx;
|
| getTransactionTemplate().execute(new TransactionCallback() {
| @Override
| public Object doInTransaction(TransactionStatus status) {
| finalContext.deployProcessDefinition(processDefinition);
| return null;
| }
| });
| } finally {
| if (inputStream != null) {
| inputStream.close();
| }
| if (ctx != null) {
| ctx.close();
| }
| }
| }
| }
| StaleObjectLogConfigurer.hideStaleObjectExceptions();
| }
| public Object getObject() throws Exception {
| return jbpmConfiguration;
| }
| @Override
| public Class getObjectType() {
| return JbpmConfiguration.class;
| }
| @Override
| public boolean isSingleton() {
| return true;
| }
| @Override
| public void onApplicationEvent(ApplicationEvent applicationEvent) {
| if (applicationEvent instanceof ContextClosedEvent) {
| jbpmConfiguration.getJobExecutor().stop();
| }
| if (applicationEvent instanceof ContextStartedEvent) {
| if (startJobExecutor) {
| log.info("Starting job executor ...");
| jbpmConfiguration.startJobExecutor();
| log.info("Job executor started.");
| }
| }
| }
| public void setStartJobExecutor(boolean startJobExecutor) {
| this.startJobExecutor = startJobExecutor;
| }
| public void setObjectFactory(ObjectFactory objectFactory) {
| this.objectFactory = objectFactory;
| }
| public void setSessionFactory(SessionFactory sessionFactory) {
| this.sessionFactory = sessionFactory;
| }
| public Resource[] getProcessDefinitionsResources() {
| return processDefinitionsResources;
| }
| public void setProcessDefinitionsResources(Resource[] processDefinitionsResources) {
| this.processDefinitionsResources = processDefinitionsResources;
| }
| public TransactionTemplate getTransactionTemplate() {
| return transactionTemplate;
| }
| public void setTransactionTemplate(TransactionTemplate transactionTemplate) {
| this.transactionTemplate = transactionTemplate;
| }
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4250513#4250513
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4250513
16 years, 7 months