Hi All,
I have requirement to use a master page template which would create around 100 to 1000 pages, as per the requirement I have made master page as rollout blueprint.
Using java code I am creating 1000 pages depending on data I receive from a 3rd party feed and tying them to blueprint. After creating these pages whenever author want to edit the pages they are suppose to go to master page template and add any component and use normal rollout button present on page property. This approach seems to work fine but for some pages rollout is failing and I am getting warning around concurrent use of session and finally getting this exception javax.jcr.InvalidItemStateException: OakState0001:.
Below is some snippets from my code, I am not able to understand is it issue because of my code or this issue with AEM not able to rollout large number of pages at one go which all have a single page as blueprint.
Warning:
05.11.2015 18:56:08.758 *WARN* [0:0:0:0:0:0:0:1 [1446749768729] POST /bin/wcmcommand HTTP/1.1] org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate Attempted to perform getItemOrNull while thread 0:0:0:0:0:0:0:1 [1446749768276] POST /bin/wcmcommand HTTP/1.1 was concurrently writing to this session. Blocked until the other thread finished using this session. Please review your code to avoid concurrent use of a session.
Exception:
com.day.cq.wcm.msm.impl.RolloutManagerImpl Failed to save changes {}, revert
javax.jcr.InvalidItemStateException: OakState0001: Unresolved conflicts in /content/platform/global/demo-site-1/cat/education/general-achievement/mathx/jcr:content
at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:237)
at org.apache.jackrabbit.oak.api.CommitFailedException.asRepositoryException(CommitFailedException.java:212)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.newRepositoryException(SessionDelegate.java:665)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.save(SessionDelegate.java:538)
at org.apache.jackrabbit.oak.jcr.session.SessionImpl$8.perform(SessionImpl.java:417)
at org.apache.jackrabbit.oak.jcr.session.SessionImpl$8.perform(SessionImpl.java:414)
at org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:293)
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.perform(SessionImpl.java:127)
at org.apache.jackrabbit.oak.jcr.session.SessionImpl.save(SessionImpl.java:414)
at sun.reflect.GeneratedMethodAccessor28.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.sling.jcr.base.SessionProxyHandler$SessionProxyInvocationHandler.invoke(SessionProxyHandler.java:113)
at com.sun.proxy.$Proxy0.save(Unknown Source)
at com.day.cq.wcm.msm.impl.RolloutManagerImpl.save(RolloutManagerImpl.java:1029)
at com.day.cq.wcm.msm.impl.RolloutManagerImpl.rollout(RolloutManagerImpl.java:487)
at com.day.cq.wcm.msm.impl.commands.RolloutCommand.performCommand(RolloutCommand.java:171)
at com.day.cq.wcm.core.impl.commands.WCMCommandServlet$CommandHolder.performCommand(WCMCommandServlet.java:161)
at com.day.cq.wcm.core.impl.commands.WCMCommandServlet.performCommand(WCMCommandServlet.java:264)
at com.day.cq.commons.servlets.AbstractCommandServlet.doPost(AbstractCommandServlet.java:49)
at org.apache.sling.api.servlets.SlingAllMethodsServlet.mayService(SlingAllMethodsServlet.java:148)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:344)
at org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:375)
at org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:533)
at org.apache.sling.engine.impl.filter.SlingComponentFilterChain.render(SlingComponentFilterChain.java:45)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:64)
at com.day.cq.personalization.impl.TargetComponentFilter.doFilter(TargetComponentFilter.java:96)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.core.impl.WCMDebugFilter.doFilter(WCMDebugFilter.java:146)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
at com.day.cq.wcm.core.impl.WCMComponentFilter.filterRootInclude(WCMComponentFilter.java:357)
at com.day.cq.wcm.core.impl.WCMComponentFilter.doFilter(WCMComponentFilter.java:166)
at org.apache.sling.engine.impl.filter.AbstractSlingFilterChain.doFilter(AbstractSlingFilterChain.java:60)
private void createCategoryPages(final ResourceResolver resolver, final PageManager pageManager, final Page blueprint, final String[] rolloutConfigurations, final String destinationPath) throws RepositoryException, CommerceException, WCMException { final Page templatePage = CatalogUtils.getTemplatePage(blueprint, "category"); final Node categoryBaseNode = resolver.getResource(destinationPath).adaptTo(Node.class); final RolloutConfig[] rolloutConfigs = CatalogUtils.getConfigs(resolver, rolloutConfigurations); Node categoryParentNode = null; System.out.println(" ------- START ---------"); for (final Resource category : CatalogUtils.getCategories(blueprint)) { final ValueMap categoryProperties = category.getValueMap(); final String parentCategoryPath = StringUtils.substringBeforeLast(categoryBaseNode.getPath() + categoryProperties.get("categoryNamePath", String.class), "/"); if (parentCategoryPath.equals(categoryBaseNode.getPath())) { categoryParentNode = resolver.getResource(categoryBaseNode.getPath()).adaptTo(Node.class); } else { categoryParentNode = resolver.getResource(parentCategoryPath).adaptTo(Node.class); } final String categoryName = CatalogUtils.mangleName(categoryProperties.get("name", String.class)); if (pageManager.getPage(parentCategoryPath + "/" + categoryName) == null) { final Page categoryPage = CatalogUtils.createPage(pageManager, categoryParentNode, categoryName); final Node categoryContentNode = CatalogUtils.createPageContent(categoryPage, templatePage); if (null != templatePage) { CatalogGeneratorImpl.this.liveRelationshipManager.establishRelationship(templatePage, categoryPage, false, false, rolloutConfigs); categoryContentNode.addMixin("cq:CatalogSyncAction"); } categoryContentNode.setProperty("jcr:title", categoryProperties.get("name", String.class)); categoryContentNode.setProperty("hybrisCategoryName", categoryProperties.get("name", String.class)); categoryContentNode.setProperty("hybrisCategoryPath", categoryProperties.get("categoryPath", String.class)); //LOG.info("Path :: "+ categoryContentNode.getPath()); System.out.println("Path :: "+ categoryContentNode.getPath()); } categoryParentNode.getSession().save(); } System.out.println(" ------- END ---------"); }
AEM version: 6.0.0.SP2
Solved! Go to Solution.
Views
Replies
Total Likes
session state you would have got when getting resolver might have been stale by the time you are saving. It happens sometime when you are saving node in the Oak. So always its better to do session.refresh() and then save()
Views
Replies
Total Likes
session state you would have got when getting resolver might have been stale by the time you are saving. It happens sometime when you are saving node in the Oak. So always its better to do session.refresh() and then save()
Views
Replies
Total Likes
Views
Likes
Replies