07-28-2012 06:47 AM
<customer:detail customer="#{processVariables['order'].customer}" />
I observed that the entity 'customer', and its related entity 'address' is updated correctly when i modify values in the JSF view and execute
<h:commandButton id="complete" value="#{msg.completeTaskButton}" action="#{businessProcess.completeTask(true)}" />
Following the user task there are service tasks which works on the process variable 'order'.
@Override
public void execute(DelegateExecution execution) throws Exception {
Order order = (Order) execution.getVariable(VariableNames.ORDER);
}
i see that the values set on the entities just before in the user task are not there.
public Object getValue() {
if (!type.isCachable() || cachedValue==null) {
cachedValue = type.getValue(this);
}
return cachedValue;
}
In the 'order' referenced by cachedValue i see the modified entity from the user task, but due to the fact that JPAEntityVariableType is not cachable07-28-2012 02:10 PM
EntityManagerSessionImpl.getEntityManager() line: 84
JPAEntityMappings.findEntity(Class<?>, Object) line: 123
JPAEntityMappings.getJPAEntity(String, String) line: 119
JPAEntityVariableType.getValue(ValueFields) line: 77
VariableInstanceEntity.getValue() line: 158
ExecutionEntity(VariableScopeImpl).getVariable(String) line: 93
GetExecutionVariableCmd.execute(CommandContext) line: 60
CommandExecutorImpl.execute(Command<T>) line: 24
CommandContextInterceptor.execute(Command<T>) line: 42
JtaTransactionInterceptor.execute(Command<T>) line: 59
LogInterceptor.execute(Command<T>) line: 33
RuntimeServiceImpl.getVariable(String, String) line: 102
UiMediatedBusinessProcessBean(BusinessProcess).getVariable(String) line: 303
ProcessVariableMap.get(Object) line: 43
MapELResolver.getValue(ELContext, Object, Object) line: 196
DemuxCompositeELResolver._getValue(int, ELResolver[], ELContext, Object, Object) line: 176
DemuxCompositeELResolver.getValue(ELContext, Object, Object) line: 203
AstValue.getValue(EvaluationContext) line: 169
ValueExpressionImpl.getValue(ELContext) line: 189
WeldValueExpression.getValue(ELContext) line: 50
TagValueExpression.getValue(ELContext) line: 109
UIComponentBase$AttributesMap.get(Object) line: 2362
CompositeComponentAttributesELResolver$ExpressionEvalMap.get(Object) line: 345
MapELResolver.getValue(ELContext, Object, Object) line: 196
DemuxCompositeELResolver._getValue(int, ELResolver[], ELContext, Object, Object) line: 176
DemuxCompositeELResolver.getValue(ELContext, Object, Object) line: 203
AstValue.getValue(EvaluationContext) line: 169
ValueExpressionImpl.getValue(ELContext) line: 189
WeldValueExpression.getValue(ELContext) line: 50
ContextualCompositeValueExpression.getValue(ELContext) line: 156
TagValueExpression.getValue(ELContext) line: 109
ComponentStateHelper.eval(Serializable, Object) line: 194
ComponentStateHelper.eval(Serializable) line: 182
HtmlOutputText(UIOutput).getValue() line: 169
TextRenderer(HtmlBasicInputRenderer).getValue(UIComponent) line: 205
TextRenderer(HtmlBasicRenderer).getCurrentValue(FacesContext, UIComponent) line: 355
TextRenderer(HtmlBasicRenderer).encodeEnd(FacesContext, UIComponent) line: 164
HtmlOutputText(UIComponentBase).encodeEnd(FacesContext) line: 875
GridRenderer(HtmlBasicRenderer).encodeRecursive(FacesContext, UIComponent) line: 312
GridRenderer.renderRow(FacesContext, UIComponent, UIComponent, ResponseWriter) line: 185
GridRenderer.encodeChildren(FacesContext, UIComponent) line: 129
HtmlPanelGrid(UIComponentBase).encodeChildren(FacesContext) line: 845
GridRenderer(HtmlBasicRenderer).encodeRecursive(FacesContext, UIComponent) line: 304
GridRenderer.renderRow(FacesContext, UIComponent, UIComponent, ResponseWriter) line: 185
GridRenderer.encodeChildren(FacesContext, UIComponent) line: 129
HtmlPanelGrid(UIComponentBase).encodeChildren(FacesContext) line: 845
GroupRenderer(HtmlBasicRenderer).encodeRecursive(FacesContext, UIComponent) line: 304
GroupRenderer.encodeChildren(FacesContext, UIComponent) line: 105
UIPanel(UIComponentBase).encodeChildren(FacesContext) line: 845
UIPanel(UIComponent).encodeAll(FacesContext) line: 1779
CompositeRenderer.encodeChildren(FacesContext, UIComponent) line: 78
UINamingContainer(UIComponentBase).encodeChildren(FacesContext) line: 845
UINamingContainer(UIComponent).encodeAll(FacesContext) line: 1779
FormRenderer(Renderer).encodeChildren(FacesContext, UIComponent) line: 168
HtmlForm(UIComponentBase).encodeChildren(FacesContext) line: 845
OutputPanelRenderer(CoreRenderer).renderChild(FacesContext, UIComponent) line: 55
OutputPanelRenderer(CoreRenderer).renderChildren(FacesContext, UIComponent) line: 43
OutputPanelRenderer.encodeEnd(FacesContext, UIComponent) line: 44
OutputPanel(UIComponentBase).encodeEnd(FacesContext) line: 875
GroupRenderer(HtmlBasicRenderer).encodeRecursive(FacesContext, UIComponent) line: 312
GroupRenderer.encodeChildren(FacesContext, UIComponent) line: 105
HtmlPanelGroup(UIComponentBase).encodeChildren(FacesContext) line: 845
GridRenderer(HtmlBasicRenderer).encodeRecursive(FacesContext, UIComponent) line: 304
GridRenderer.renderRow(FacesContext, UIComponent, UIComponent, ResponseWriter) line: 185
GridRenderer.encodeChildren(FacesContext, UIComponent) line: 129
HtmlPanelGrid(UIComponentBase).encodeChildren(FacesContext) line: 845
HtmlPanelGrid(UIComponent).encodeAll(FacesContext) line: 1779
UIOutput(UIComponent).encodeAll(FacesContext) line: 1782
UIViewRoot(UIComponent).encodeAll(FacesContext) line: 1782
EntityManagerSessionImpl.flush() line: 63
JPAEntityVariableType.setValue(Object, ValueFields) line: 61
VariableInstanceEntity.setValue(Object) line: 164
ExecutionEntity(VariableScopeImpl).setVariableInstanceValue(Object, VariableInstanceEntity) line: 196
ExecutionEntity(VariableScopeImpl).setVariableLocal(String, Object) line: 189
ExecutionEntity(VariableScopeImpl).setVariable(String, Object) line: 167
ExecutionEntity(VariableScopeImpl).setVariables(Map<String,Object>) line: 264
TaskEntity.setExecutionVariables(Map<String,Object>) line: 360
CompleteTaskCmd.execute(CommandContext) line: 54
CompleteTaskCmd.execute(CommandContext) line: 28
CommandExecutorImpl.execute(Command<T>) line: 24
CommandContextInterceptor.execute(Command<T>) line: 42
JtaTransactionInterceptor.execute(Command<T>) line: 59
LogInterceptor.execute(Command<T>) line: 33
TaskServiceImpl.complete(String, Map<String,Object>) line: 148
UiMediatedBusinessProcessBean(BusinessProcess).completeTask() line: 263
UiMediatedBusinessProcessBean.completeTask() line: 53
UiMediatedBusinessProcessBean(BusinessProcess).completeTask(boolean) line: 274
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object…) line: 597
AstValue.invoke(EvaluationContext, Class[], Object[]) line: 262
MethodExpressionImpl.invoke(ELContext, Object[]) line: 278
WeldMethodExpression(ForwardingMethodExpression).invoke(ELContext, Object[]) line: 39
WeldMethodExpression.invoke(ELContext, Object[]) line: 50
TagMethodExpression.invoke(ELContext, Object[]) line: 105
MethodBindingMethodExpressionAdapter.invoke(FacesContext, Object[]) line: 88
ActionListenerImpl.processAction(ActionEvent) line: 102
HtmlCommandButton(UICommand).broadcast(FacesEvent) line: 315
07-31-2012 06:30 AM
07-31-2012 03:38 PM
<jee:jndi-lookup id="dataSource" jndi-name="java:/datasources/appDS" />
<!– use transaction manager from the application server –>
<jee:jndi-lookup id="transactionManager" jndi-name="java:jboss/TransactionManager" />
<jee:jndi-lookup id="entityManagerFactory" jndi-name="persistence/appEMF" resource-ref="false" />
<!– integrate Activiti with CDI and JTA –>
<bean id="processEngineConfiguration"
class="org.activiti.cdi.CdiJtaProcessEngineConfiguration">
<!– config for JTA managed persistence –>
<property name="dataSource" ref="dataSource" />
<property name="transactionManager" ref="transactionManager"/>
<property name="transactionsExternallyManaged" value="true" />
<property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
<property name="jpaHandleTransaction" value="false" />
<property name="jpaCloseEntityManager" value="false" />
<!– upgrade Activiti model if needed –>
<property name="databaseSchemaUpdate" value="true" />
<property name="databaseType" value="mysql" />
<!– enable timers –>
<property name="jobExecutorActivate" value="true" />
<!– log full details to the history tables –>
<property name="history" value="full" />
</bean>
07-31-2012 05:25 PM
08-01-2012 02:05 AM
<property name="jpaEntityManagerFactory" ref="entityManagerFactory" />
<property name="jpaHandleTransaction" value="false" />
<property name="jpaCloseEntityManager" value="false" />
08-01-2012 04:46 PM
public void flush() {
if (entityManager != null && (!handleTransactions || isTransactionActive()) ) {
try {
entityManager.flush();
The reason why there is no EntityManager available when the task is completed is that no one is created using the then active EntityManagerSession.
public void setValue(Object value, ValueFields valueFields) {
EntityManagerSession entityManagerSession = Context
.getCommandContext()
.getSession(EntityManagerSession.class);
Why not get an EntityManager there and perform an em.merge(value)? Then the EntityManagerSession would have an EM for the flush() operation and the JPA entity would be attached to the persistence context? Or do we need to implement the merge and persist logic ourself, and if so, how can we align the containers EntityManager with the one Activiti will use? Activiti will, if it would do it, get an EntityManager using the configured EntityManagerFactory. But for sure it will not get the same EntityManger which is injected to lets say service tasks which resolve to EJBs…
public void setValue(Object value, ValueFields valueFields) {
EntityManagerSession entityManagerSession = Context
.getCommandContext()
.getSession(EntityManagerSession.class);
if (entityManagerSession == null) {
throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured");
} else {
// get EM and merge entity to be flushed afterwards
EntityManager entityManager = entityManagerSession.getEntityManager();
if (entityManager != null) {
entityManager.merge(value);
}
// Before we set the value we must flush all pending changes from the entitymanager
// If we don't do this, in some cases the primary key will not yet be set in the object
// which will cause exceptions down the road.
entityManagerSession.flush();
}
it works nicely for me.08-02-2012 02:39 AM
08-02-2012 07:33 AM
// get EM and merge entity to be flushed afterwards
EntityManager entityManager = entityManagerSession.getEntityManager();
if (entityManager != null) {
entityManager.merge(value);
}
AFAIK a em.merge() does not perform a flush?08-02-2012 07:51 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.