12-04-2020 02:34 AM
Hi,
Started maapi transaction in read mode and fetched device specific service instances and stored that data in global variable and finished transaction.
Passing this variable to different method argument and trying to read that but am getting exception "com.tailf.navu.NavuException: com.tailf.maapi.MaapiException: /ncs:devices/device{ios0}/service-list: No such transaction"
Sample Code:
private NavuLeafList servicesLeafList = null;
public NavuLeafList method1(String device)
{
NavuLeafList servicesLeafList = null;
try{
int th = maapi.startTrans2(Conf.DB_RUNNING, Conf.MODE_READ, trans.getUserInfo().getUserId());
NavuContext context = new NavuContext(maapi, th);
NavuContainer ncsRoot = new NavuContainer(context).container(Ncs.hash);
servicesLeafList = ncsRoot.container(Ncs._devices_).list(Ncs._device_).elem(device).leafList("service-list");
maapi.finishTrans(th);
}catch(Exception e){}
return servicesLeafList;
}
public void method2(NavuLeafList servicesLeafList)
{
LOGGER.info("Service List::"+servicesLeafList.elements().size()); // Exception throwing
}
ncs-java-vm.log:
com.tailf.navu.NavuException: com.tailf.maapi.MaapiException: /ncs:devices/device{ios0}/service-list: No such transaction
at com.tailf.navu.NavuContextBase.getElem(NavuContextBase.java:872)
at com.tailf.navu.NavuContext.getElem(NavuContext.java:1001)
at com.tailf.navu.NavuLeaf.refresh(NavuLeaf.java:573)
at com.tailf.navu.NavuLeafList.elements(NavuLeafList.java:368)
at com.cisco.casb.rfs.deviceoffboard.DeviceOffBoard.deviceOffboard(DeviceOffBoard.java:61)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.tailf.dp.annotations.ActionCallbackProxy.action(ActionCallbackProxy.java:125)
at com.tailf.dp.DpActionTrans.protoCallback(DpActionTrans.java:315)
at com.tailf.dp.DpActionTrans.read(DpActionTrans.java:221)
at com.tailf.dp.DpActionTrans.run(DpActionTrans.java:128)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
at com.tailf.dp.DpThread.run(DpThread.java:41)
Caused by: com.tailf.maapi.MaapiException: /ncs:devices/device{ios0}/service-list: No such transaction
at com.tailf.maapi.MaapiException.mk(MaapiException.java:61)
at com.tailf.maapi.Maapi.safeGetElem(Maapi.java:2785)
at com.tailf.maapi.Maapi.safeGetElem(Maapi.java:2823)
at com.tailf.navu.NavuContextBase.getElem(NavuContextBase.java:861)
We did temp fix to avoid above exception. Read navuleaflist elements before finishing maapi transaction.
servicesLeafList = ncsRoot.container(Ncs._devices_).list(Ncs._device_).elem(device).leafList("service-list");
//below line of code added to avoid exception
Collection<ConfValue> confValue = servicesLeafList.elements();
maapi.finishTrans(th);
Any guidance is appreciated.
Thanks
Ramathulasi
Solved! Go to Solution.
12-05-2020 02:42 AM - edited 12-05-2020 02:43 AM
Hi,
Thanks for the quick reply.
I have implemented the below option and it is working fine.
12-04-2020 02:48 AM
Hello Ramuthalasi,
what you see there is a feature of transactiions. A transaction gives a consistent snapshot of a DB at one point in time. Closing the transaction signals that you have read all you wanted and are no longer interested. All those Navu objects become unuseable at that point as you have seen.
You have 2 options
If you are wondering which to take just go for 1, 2 is just there for completeness.
12-05-2020 02:42 AM - edited 12-05-2020 02:43 AM
Hi,
Thanks for the quick reply.
I have implemented the below option and it is working fine.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide