-
1. Re: Converters saving problem
frantisek.kocun Dec 20, 2008 5:12 PM (in response to frantisek.kocun)Hi,
I know exactly where the problem is but I don't know the best way to solve it.
The problem is I have two JbpmConfigurations. It is ok that there is no current JbpmContex, when saving process instance by hibernate, because jbpmContext is closed and it uses default JbpmConfiguration which should have the same objectFactory. But it does't because context was created on another configuration.
Why I have 2 JbpmConfigurations? First is created when hibernate is scanning classes for mapping. Class org.jbpm.job.Timer is persistent and it has static attribute:
static BusinessCalendar businessCalendar = new BusinessCalendar();Constructor of BusinessCalendar look like this: public static synchronized Properties getBusinessCalendarProperties() { if (businessCalendarProperties==null) { String resource = JbpmConfiguration.Configs.getString("resource.business.calendar"); businessCalendarProperties = ClassLoaderUtil.getProperties(resource); } return businessCalendarProperties; } public BusinessCalendar() { this(getBusinessCalendarProperties()); }
So this creates first Configuration.
Second is created programmatically as a Spring bean and injected into JbpmTemplate.<!-- jBPM configuration --> <bean class="org.springmodules.workflow.jbpm31.LocalJbpmConfigurationFactoryBean" id="jbpmConfiguration"> <property name="sessionFactory" ref="sessionFactory"/> <property name="configuration" value="classpath:jbpm.cfg.xml"/> <property name="processDefinitionsResources"> <list> <value>classpath:processDefinitions/FlowTest.xml</value> </list> </property> </bean> <!-- jBPM template --> <bean class="org.springmodules.workflow.jbpm31.JbpmTemplate" id="jbpmTemplate"> <property name="jbpmConfiguration"> <ref bean="jbpmConfiguration"/> </property> <property name="hibernateTemplate"> <ref bean="hibernateTemplate"/> </property> </bean>
Problem is that this configuration is not in static map JbpmConfiguration.instances because it is created this way:ObjectFactory jbpmObjectFactory; // 1. create the configuration from the file if (configuration != null) { logger.info("creating JbpmConfiguration from resource " + configuration.getDescription()); InputStream stream = configuration.getInputStream(); jbpmObjectFactory = ObjectFactoryParser.parseInputStream(stream); stream.close(); } else jbpmObjectFactory = objectFactory; jbpmConfiguration = new JbpmConfiguration(jbpmObjectFactory);
So what should I do? I think this is wrong way and they should use JbpmConfiguration getInstance(String resource) to create configuration. Have anyone experience with spring module?
Thanks a lot
Fero -
2. Re: Converters saving problem
frantisek.kocun Dec 21, 2008 5:32 AM (in response to frantisek.kocun)I got it working by editing spring jbpm module. But don't know it is done as good as it can be.
Instead of new JbpmConfiguration(...) I use JbpmConfiguration.getConfiguration(..)
So question is simplier:
a) Should I commit transaction before closing context:tx start new jbpmcontext do something tx commit jbpmcontext close
b) Or should I work with only one jbpmconfiguration = only one object factory and use jbpmcontext like thistx start new jbpmcontext do something jbpmcontext close tx commit This fits me. I need only 1 configuration. But I don't like the static default when there is no jbpm context. Answers please:-) Thanks
-
3. Re: Converters saving problem
kukeltje Dec 22, 2008 8:14 PM (in response to frantisek.kocun)b, otherwise things are nested strangely