CAFLockException
Gurus salutem,
In my BPM flow I use a CAF service, and use the operation to update a record. Prior to the update I read the record, and use the results to be passed on to the update service, except for the attribute status. Attribute status is changed.
Operations findAll and read work fine.
I verified that all is passed correctly. Which it is.All fields are mapped, including the one that will change.
The message I get is;
Operation:update of interface:http://www.sap.com/caf/xxx.com/productpruning/modeled/catclustcombi#catclustcombihas returned a fault, namely:CAFLockException.
How could this be fixed?
Best regards,
Martijn
Edited by: Martijn on Jan 11, 2012 9:29 AM
Dear all,
The message is somewhat deceptive. What happened is that the fields modifyAt and createAt, on the data object from which I mapped, were of the type date and not of dateTime.
Once that was changed it worked.
Best regards,
Martijn
Similar Messages
-
hello
I am doing some tests in WebDynpro and CAF Core services.
I have a piece of code as below that retrieves an entity from CAF Core for update. I need this entity to be locked during the update but the two methods lock() and unlock() do nothing. I can still access for update the same entity instance from another user.
This probably works if the transaction is happening within CAF service but I also need to lock entities from webdynpro when doing complex updates. In other words I am not willing to create a custom method in CAF service for each update I need to implement in webdynpro.
Any advice ? How are we supposed to use the class com.sap.tc.col.client.generic.api.LockStrategy ? I did not find much about this api.
Thanks in advance
Vitaliano
public void UpdateKAMInTransaction( )
//@@begin UpdateKAMInTransaction()
IServiceFacade serviceFacade = CAFServiceFactory.getServiceFacade(cplxmdlDefinition.class);
String guid = wdContext.currentAKamElement().getGuid();
AKam akam = MyAppProxy.readKam(guid);
//locking is not working at all. concurrent changes are lost
akam.lock(LockStrategy.EXCLUSIVE);
//update a value here
akam.setVersion(akam.getVersion() + 1);
akam.getAspect().sendChanges();
serviceFacade.save();
//locking is not working at all. concurrent changes are lost
akam.unlock();
wdThis.wdGetAPI().getMessageManager().reportSuccess("done update AKAM=" + akam);
//@@endNow I feel lost. Please keep helping a newby.
I have implemented my custom method in CAF Services. Here I lock the entity, make all my chanegs, then update and return. I call this custom CAF Application Service method from WebDynpro.
Nevertheless I noticed that concurrency can still happen. If more than one user updates the same entity at the same time, and exception is thrown in the log files but no exception is thrown. I.e. I cannot intercept the collision.
in the log file a huge stacktrace is written, while the most interesting message is "javax.jdo.JDOUserException: optimistic transaction failed".
So... what am I doing wrong here? Should'nt new locking just hold until the existing one is released?
HELP!
Vitaliano
public java.lang.String myUpdateKam(java.lang.String guid, long newVersion) throws com.sap.caf.rt.exception.ServiceException
// logging
java.lang.String CAF_user = sessionContext.getCallerPrincipal().getName();
java.lang.String CAF_methodHeader = MyAppBean.JARM_REQUEST + ":" + "myUpdateKam(java.lang.String, long)";
Object[] CAF_parameters = new Object[] { guid, new java.lang.Long(newVersion)};
com.sap.caf.rt.util.CAFPublicLogger.entering(CAF_user, MyAppBean.JARM_REQUEST, CAF_methodHeader, MyAppBean.location, CAF_parameters);
java.lang.String retValue;
try
//@@custom code start - myUpdateKam(java.lang.String, long)
//Read the BO and prepare for changes
retValue = "";
Kam kam = getKamService().read(guid);
char modeLock = IBusinessEntityService.MODE_WRITE;
try
//Lock BO before updating
try
getKamService().lock(kam.getKey(), modeLock, 3000);
retValue += "-lock-";
catch (CAFLockException e)
retValue += e.getMessage();
//Now do the update and commit
// =====> NOTE: regardelss if there is another update in progress,
// a concurrent update still gets down to here. WHY ?
long counter = kam.getVersion();
kam.setVersion(++counter);
getKamService().update(kam);
retValue += "-update-";
catch (CAFUpdateException e)
//This case is when concurrent update occurs
retValue += e.getMessage();
catch (Exception e)
//any other exception thrown?
retValue += e.getMessage();
finally
//Make sure we always leave our BO unlocked
try
getKamService().unlock(kam.getKey(), modeLock);
retValue += "-unlock-";
catch (CAFLockException e)
retValue += e.getMessage();
//@@custom code end - myUpdateKam(java.lang.String, long)
return retValue;
finally
com.sap.caf.rt.util.CAFPublicLogger.exiting(CAF_user, MyAppBean.JARM_REQUEST, CAF_methodHeader, MyAppBean.location, CAF_parameters);
This is the code in WebDynpro to invoke CAF custom method.
public void UpdateKAMRemotely( )
//@@begin UpdateKAMRemotely()
IServiceFacade serviceFacade = CAFServiceFactory.getServiceFacade(cplxmdlDefinition.class);
IAspect retValue = null;
for (int i = 1; i < 101; i++)
long newLong = wdContext.currentAKamElement().getVersion() +i;
retValue = MyAppProxy.myUpdateKam(wdContext.currentAKamElement().getGuid(),newLong);
IAspectRow row = retValue.getAspectRow(0);
String retMsg = row.getAttributeAsString("value");
wdThis.wdGetAPI().getMessageManager().reportSuccess("IAspectRow=" + row + "index="+i);
serviceFacade.save();
//@@end
Message was edited by:
Vitaliano Trecca
Maybe you are looking for
-
Running a sql script from stored procedure
Hi everyone! Has anybody tell me how to execute a sql script from a stored procedure! Thanks in advance! Sasa
-
Threads effect both of the diffrent model
Hello all, I will try to explain the status: 1. I create a table model that include objects(strings). Every "call" has a time to be desplay at the table , and after the time pass the cell at the table model set by default string like "XXX". In the ta
-
The iPad stick in the recovery mode
Hello My iPad stick in the recovery mode, so when i connect it to the PC to restore it, it's keep restarting and the iTunes doesn't start I don't know what to do, It drive me to madness Hope anyone can help me :'(
-
Gurus, Has anybody worked on BI 7.0 with GRC 5.2? Does BI follow the same approach like integrating ECC with GRC tools? Any thoughts will be very helpful. Thanks Sundaram
-
Can't install with regional options changed
Hi, I tried to install WL 8 in Windows XP. I've set the Regional Language Options to Tamil. I'm not able to install WL. After I change it to English, I was able to install it. Similarly when starting a server, if I had set my Regional Language Option