Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
Hi,
There is following a Execute Expression code Windchill 12.1.2 implemented in Change Activity workflow:
wt.lifecycle.State state = wt.lifecycle.State.toState("UNDERREVIEW");
wt.fc.QueryResult resulting = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.WTChangeActivity2) primaryBusinessObject);
while(resulting.hasMoreElements())
{
wt.fc.Persistable persistable = (wt.fc.Persistable) resulting.nextElement();
if (persistable instanceof wt.part.WTPart && !wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable) persistable))
{
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState((wt.lifecycle.LifeCycleManaged)persistable, state);
}
if (persistable instanceof wt.doc.WTDocument && !wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable) persistable))
{
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState((wt.lifecycle.LifeCycleManaged)persistable, state);
}
if (persistable instanceof wt.epm.EPMDocument && !wt.vc.wip.WorkInProgressHelper.isCheckedOut((wt.vc.wip.Workable) persistable))
{
wt.lifecycle.LifeCycleHelper.service.setLifeCycleState((wt.lifecycle.LifeCycleManaged)persistable, state);
}
}
This code has to execute set state on all changeables objects in ECN.
It is working well, but lately after few loops where the code worked perfectly, the following exception appeared:
wt.util.WTException: wt.lifecycle.LifeCycleException: (wt.pom.pomResource/10) wt.pom.PersistenceException: A commit cannot be done when a rollback is in progress. The following is the rollback stacktrace.
ROLLBACK: java.base/java.lang.Thread.getStackTrace(Thread.java:1602)
ROLLBACK: wt.pom.TransactionManager.rollbackTransaction(TransactionManager.java:754)
ROLLBACK: wt.pom.BasicTransactionMonitor.rollbackTransaction(BasicTransactionMonitor.java:77)
ROLLBACK: wt.pom.PersistentObjectManager.rollbackTransaction(PersistentObjectManager.java:428)
ROLLBACK: wt.pom.Transaction.rollback(Transaction.java:769)
ROLLBACK: wt.pom.Transaction.forceRollback(Transaction.java:429)
ROLLBACK: wt.pds.SQLDatabasePds.handleSQLException(SQLDatabasePds.java:1207)
ROLLBACK: wt.pds.SQLDatabasePds.handleException(SQLDatabasePds.java:1065)
ROLLBACK: wt.pds.SQLDatabasePds.query(SQLDatabasePds.java:923)
ROLLBACK: wt.pom.PersistentObjectManager.query(PersistentObjectManager.java:1077)
ROLLBACK: wt.fc.StandardPersistenceManager._query(StandardPersistenceManager.java:1967)
ROLLBACK: wt.fc.StandardPersistenceManager.query(StandardPersistenceManager.java:1919)
ROLLBACK: wt.fc.StandardPersistenceManager.query(StandardPersistenceManager.java:1449)
ROLLBACK: wt.fc.collections.RefreshHelper$LockRefresh.doLockPass(RefreshHelper.java:1343)
ROLLBACK: wt.fc.collections.RefreshHelper$LockRefresh.refresh(RefreshHelper.java:1304)
ROLLBACK: wt.fc.collections.RefreshHelper.refresh(RefreshHelper.java:144)
ROLLBACK: wt.fc.collections.StandardCollectionsManager.refresh(StandardCollectionsManager.java:80)
ROLLBACK: jdk.internal.reflect.GeneratedMethodAccessor55.invoke(Unknown Source)
ROLLBACK: java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
ROLLBACK: java.base/java.lang.reflect.Method.invoke(Method.java:566) ROLLBACK: wt.services.ServiceFactory$ServerInvoca
can you please help me what is wrong with this?
Thanks.
Solved! Go to Solution.
Some exception was thrown when it tried to set the state. Since this is done as a transaction, if even one item has a problem, it will failed the entire set and have to rollback that database actions. The most likely cause is that an item in the resulting objects was checked out or could not be set to that state (possible issue with current lifecycle template assigned to that object). We solved this for checked out objects by doing a precheck for any checked out objects before sending it to the robot that set the state. This allows us to direct a task to a user saying "Hey, check in your work!". This avoids the workflow just erroring out.
Some exception was thrown when it tried to set the state. Since this is done as a transaction, if even one item has a problem, it will failed the entire set and have to rollback that database actions. The most likely cause is that an item in the resulting objects was checked out or could not be set to that state (possible issue with current lifecycle template assigned to that object). We solved this for checked out objects by doing a precheck for any checked out objects before sending it to the robot that set the state. This allows us to direct a task to a user saying "Hey, check in your work!". This avoids the workflow just erroring out.