[JBoss Seam] - s:link jta - transaction, rollbackonly
by motte1979
Hi !
Im using s:link with @DataModelSelection to delete an entity.
<a jsfc="s:link" value="#{messages['action.delete']}" action="#{labelFilter.delete}"/>
If i have opened two pages with the same content and simulate simultan user-action 'delete' on the same entity, i got an OptimisticLockException on flush.
@TransactionAttribute (TransactionAttributeType.REQUIRES_NEW)
| public void delete(EmonitorEntity entity) {
| try {
| this.entityManager.remove(entity);
| this.entityManager.flush();
| } catch (OptimisticLockException ole) {
| if (sessionContext.getRollbackOnly())
| logger.info("rollbackonly", ole);
| }
| }
The transaction (the new one) should have been rolled back after processing this method (because i'm using CMT which is default). This seems to be done correctly. Afterwards i'm raising an event to a PAGE-scoped component to refresh it's contents. But the refresh does not work because the transaction
has been set to 'rollbackonly'.
public Long size(Class<?> clazz, String[] properties, Object[] values) {
| Query q = getSizeQuery (clazz, properties, values);
|
| if (sessionContext.getRollbackOnly())
| logger.fatal("rollbackonly", new AssertionError());
|
| try {
| return ((Number) q.getSingleResult()).longValue();
| } catch (RuntimeException rte) {
| throw rte;
| }
| }
This all is processed in the RENDER_RESPONSE_PHASE of jsf.
| * Does seam work correctly with @TransactionAttribute ?
| * I've spawn a new transaction for the delete-method, why does this effect the RENDER_RESPONSE-PHASE - transaction of seam?
|
| Thanks for your help! Hints are welcome ...
|
| Using :
|
| | * seam 2.0.0.BETA1 from cvs
| | * hibernate 3
| | * jboss 4.2.0.GA
| |
|
| Please let me know, if you need more informations.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079079#4079079
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079079
18Â years, 7Â months
[JBoss jBPM] - ClassCast Problem
by Candersen
Hello,
I am encountering a strange problem. I wrote a very simple Processdefinition:
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition
| xmlns="" name="objectTest">
| <start-state name="start">
| <event type="node-leave">
| <action name="action1" class="com.test.SetUpActionHandler"/>
| </event>
| <transition name="" to="node1"></transition>
| </start-state>
| <end-state name="end">
| </end-state>
| <node name="node1">
| <action class="com.test.ObjectTestActionHandler" />
| <transition name="" to="end"></transition>
| </node>
| </process-definition>
|
In the SepUpActionHandler class I declare a simple TestObject and put it into the ContextInstance:
| package com.test;
|
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.exe.ExecutionContext;
|
| public class SetUpActionHandler implements ActionHandler {
|
| private static final long serialVersionUID = 1L;
|
| public void execute(ExecutionContext executionContext) throws Exception
| {
| TestObject to = new TestObject();
| to.setText("TestString");
| executionContext.getContextInstance().setVariable("Test", to);
| }
| }
|
The TestObject itself is a very minimal serializable object:
| package com.test;
|
| import java.io.Serializable;
|
| public class TestObject implements Serializable {
|
| private static final long serialVersionUID = 1L;
|
| private String _text = "leer";
|
| public TestObject()
| {
|
| }
|
| public String getText()
| {
| return _text;
| }
|
| public void setText(String s)
| {
| _text = s;
| }
| }
|
And finally, in the ObjectTestActionHandler, I retrieve the TestObject from the ContextInstance:
| package com.test;
|
| import org.jbpm.graph.def.ActionHandler;
| import org.jbpm.graph.exe.ExecutionContext;
|
| public class ObjectTestActionHandler implements ActionHandler {
|
| private static final long serialVersionUID = 1L;
|
| public void execute(ExecutionContext executionContext) throws Exception
| {
| Object o = executionContext.getContextInstance().getVariable("Test");
| TestObject to = (TestObject) o;
|
| executionContext.getToken().signal();
| }
| }
|
When I execute this process in Eclipse, everything runs fine, there are no errors. But when I deploy it to a JBoss AS (4.0.4) and start it using the jbpm-web-console, I get a ClassCastException with the message: "com.test.TestObject cannot be cast to com.test.TestObject"
The Exception is thrown by the ObjectTestActionHandler in the line where the casting is done:
| TestObject to = (TestObject) o;
|
Does anybody know why this happens?
Regards,
Claus Andersen
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4079077#4079077
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4079077
18Â years, 7Â months