06-24-2008 05:41 AM
06-26-2008 02:28 AM
07-31-2008 03:22 PM
07-31-2009 05:32 AM
UserTransaction trx_A = serviceRegistry.getTransactionService()
.getUserTransaction();
try
{
trx_A.begin()
nodeService.createNode(…);
nodeService.createNode(…);
trx_A.commit();
}
catch(Throwable e)
{
try
{
if (trx_A.getStatus() == Status.STATUS_ACTIVE)
{
trx_A.rollback();
}
}
catch(Throwable ee)
{
// Handle double exception in whatever way is appropriate eg. log it
}
throw e;
}
….
UserTransaction trx_B = serviceRegistry.getTransactionService()
.getUserTransaction();
try
{
trx_B.begin()
nodeService.createNode(…);
nodeService.createNode(…);
trx_B.commit();
}
catch(Throwable e)
{
try
{
if (trx_B.getStatus() == Status.STATUS_ACTIVE)
{
trx_B.rollback();
}
}
catch(Throwable ee)
{
// Handle double exception in whatever way is appropriate eg. log it
}
throw e;
}
From http://wiki.alfresco.com/wiki/Java_Foundation_API#Handling_UserTransaction_Directly
11:08:14,080 ERROR [ch.custom.manageoffice.actions.SplittPDFFromERP] Error during the transaction
javax.transaction.RollbackException: The transaction has already been marked for rollback
at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:450)
at ch.custom.manageoffice.actions.SplittPDFFromERP.createErrorFile(SplittPDFFromERP.java:271)
at ch.custom.manageoffice.actions.SplittPDFFromERP.executeImpl(SplittPDFFromERP.java:229)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:72)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:127)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:592)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:529)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1$1.execute(AsynchronousActionExecutionQueueImpl.java:369)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:320)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:227)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper$1.doWork(AsynchronousActionExecutionQueueImpl.java:378)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:437)
at org.alfresco.repo.action.AsynchronousActionExecutionQueueImpl$ActionExecutionWrapper.run(AsynchronousActionExecutionQueueImpl.java:381)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
07-31-2009 09:24 AM
Boolean result = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>(){
public Boolean execute() throws Throwable {
//your code should be right here dropped
return true;
}
});
08-03-2009 09:58 AM
08-05-2009 10:21 AM
Boolean result = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>(){
public Boolean execute() throws Throwable {
…
if(val == null)
throw new IllegalStateException("Val must not be null");
return true;
}
});
08-06-2009 03:29 AM
final String var = …;
boolean resultAddFiles = transactionService.getRetryingTransactionHelper()
.doInTransaction(
new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>() {
public Boolean execute()
throws Throwable {
boolean success= method(var);
if (!success){
// Retry and rollback if always problem
throw new IllegalStateException("Problem during moveFilesAndAddMeta");
}
return true;
}
});
08-06-2009 04:36 AM
Boolean result = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Boolean>(){
public Boolean execute() throws Throwable {
…
if(val == null)
throw new IllegalStateException("Val must not be null");
return true;
}
//we need to setup a new transaction for this
}, false, true);
08-06-2009 07:31 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.