[JBoss jBPM] - Re: Converters saving problem
by frantisek.kocun@gmail.com
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197817#4197817
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197817
15 years, 11 months
[JBoss jBPM] - Converters saving problem
by frantisek.kocun@gmail.com
Hi,
we use open session in view. I would like to store some Booleans to db, it is stored, but no converter is set, so it si later read as String, which makes Exception.
Problem is that when I set variables their values are converted with converters. To find the right converter Converters.getConverterMaps() is used. It creates new converter map for given objectFactory. But when when values are stored, ConverterEnumType ask Converters for id Converters.getConverterId((Converter) value); . It uses the same method Converters.getConverterMaps() but with different object factory. Converters to convertersMap are created again and the key to map is converter itself (not its class) so method Converters.getConverterId(Converter converter) returns null. Why two different object factories are used in single request? There is the same session. My middle layer code looks like this:
public void startProcess(final StartEvent startEvent, final String transition){
getTemplate().execute(new JbpmCallback(){
public Object doInJbpm(JbpmContext context) throws JbpmException{
org.jbpm.graph.exe.ProcessInstance processInstance = context.newProcessInstanceForUpdate(startEvent.getProcess().getName());
processInstance.getContextInstance().setVariables(startEvent);
processInstance.signal(transition);
return null;
}});
}
We use spring jbpm module and spring is configured so that callback is wrapped in transaction. But all the actions form single request are in one session (open session in view) and every in its own transaction. But this time the only action was startProcess.
StartEvent is our class which implements map for process variables, and is typed (has process as attribute).
Thanks for your help
Fero
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4197810#4197810
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4197810
15 years, 11 months