Expand my Community achievements bar.

javax.jcr.InvalidItemStateException the property cannot be saved because it has been modified externally.

Avatar

Level 4

Hi there, It is a single cq5 instance and a page node properties are changed by using adminResourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null); 

10.08.2016 10:25:09.768 *ERROR* [192.168.80.146 [1470838218034] GET /content/tpd/uk/en/funds.html HTTP/1.1] com.trp.twx.tpd.services.FundService setFundPageProperties(): ERROR  org.apache.sling.api.resource.PersistenceException: Unable to commit changes to session. at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.commit(JcrResourceProvider.java:513) at org.apache.sling.resourceresolver.impl.helper.ResourceResolverContext.commit(ResourceResolverContext.java:159) at org.apache.sling.resourceresolver.impl.ResourceResolverImpl.commit(ResourceResolverImpl.java:1108) at com.trp.twx.tpd.services.impl.FundServiceImpl.__AW_setFundPageProperties(FundServiceImpl.java:1091) at com.trp.twx.tpd.services.impl.FundServiceImpl.setFundPageProperties(FundServiceImpl.java) at com.trp.twx.tpd.services.impl.FundServiceImpl.__AW_getFundOverviewPagesByCategory(FundServiceImpl.java:749) at com.trp.twx.tpd.services.impl.FundServiceImpl.getFundOverviewPagesByCategory(FundServiceImpl.java) at org.apache.jsp.apps.tpd.components.content.fund_002dcategory_002dlist.fund_002dcategory_002dlist_jsp.__AW__jspService(fund_002dcategory_002dlist_jsp.java:372) at org.apache.jsp.apps.tpd.components.content.fund_002dcategory_002dlist.fund_002dcategory_002dlist_jsp._jspService(fund_002dcategory_002dlist_jsp.java) at org.apache.sling.scripting.jsp.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.__AW_service(HttpServlet.java:820) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:502) at org.apache.sling.scripting.jsp.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:449) at org.apache.sling.scripting.jsp.JspScriptEngineFactory.callJsp(JspScriptEngineFactory.java:265) at org.apache.sling.scripting.jsp.JspScriptEngineFactory.access$100(JspScriptEngineFactory.java:87) at org.apache.sling.scripting.jsp.JspScriptEngineFactory$JspScriptEngine.eval(JspScriptEngineFactory.java:465) at org.apache.sling.scripting.core.impl.DefaultSlingScript.call(DefaultSlingScript.java:361) at org.apache.sling.scripting.core.impl.DefaultSlingScript.eval(DefaultSlingScript.java:171) at org.apache.sling.scripting.core.impl.DefaultSlingScript.service(DefaultSlingScript.java:463) ........................ etc and .............. Caused by: javax.jcr.InvalidItemStateException: property /content/tpd/uk/en/funds/sicav/emerging-local-markets-bond-fund/jcr:content/vehicle: the property cannot be saved because it has been modified externally. at org.apache.jackrabbit.core.PropertyImpl.makePersistent(PropertyImpl.java:161) at org.apache.jackrabbit.core.ItemSaveOperation.persistTransientItems(ItemSaveOperation.java:849) at org.apache.jackrabbit.core.ItemSaveOperation.perform(ItemSaveOperation.java:243) at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) at org.apache.jackrabbit.core.ItemImpl.perform(ItemImpl.java:91) at org.apache.jackrabbit.core.ItemImpl.save(ItemImpl.java:329) at org.apache.jackrabbit.core.session.SessionSaveOperation.perform(SessionSaveOperation.java:65) at org.apache.jackrabbit.core.session.SessionState.perform(SessionState.java:216) at org.apache.jackrabbit.core.SessionImpl.perform(SessionImpl.java:361) at org.apache.jackrabbit.core.SessionImpl.save(SessionImpl.java:812) at com.day.crx.core.CRXSessionImpl.save(CRXSessionImpl.java:142) at org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider.commit(JcrResourceProvider.java:511) ... 215 more

Any ideas, what this exception is and how to fix it ?

Thank you,Sri

2 Replies

Avatar

Employee

Are you sure there are not two separate threads trying to modify this property?

Avatar

Level 4

It could be possible there could be multiple threads doing this update on node properties. I am not sure how to handle this scenario in Sling, CQ/AEM.

Data is coming from a REST call in the bundle. when a component is authored on number of pages, bundle service call will be made to get data from RDBMS using REST calls. Service will get the currentPage node value map and change the properties of pagenode using valuemap.put(key, value). then resourceresolver.commit called to update the page node properties.