Friday, April 12, 2019

Not Found (404) - The requested URL /siteadmin resulted in an error in org.apache.sling.servlets.get.DefaultGetServlet.

Not Found (404) - The requested URL /siteadmin resulted in an error in org.apache.sling.servlets.get.DefaultGetServlet.


In one of our AEM(Adobe Experience Manager) environment recently we were facing 404 issue for all standard URL's like siteadmin, useradmin, welcome.html etc and for the custom content URLs.

The below message has been displayed in the browser while accessing the pages.

Not Found (404)
The requested URL /siteadmin resulted in an error in org.apache.sling.servlets.get.DefaultGetServlet.

Request Progress:
      0 TIMER_START{Request Processing}
      0 COMMENT timer_end format is {<elapsed microseconds>,<timer name>} <optional message>
      3 LOG Method=GET, PathInfo=null
      4 TIMER_START{handleSecurity}
   3166 TIMER_END{3160,handleSecurity} authenticator org.apache.sling.auth.core.impl.SlingAuthenticator@1444cb1f returns true
   3344 TIMER_START{ResourceResolution}
   3438 TIMER_END{93,ResourceResolution} URI=/siteadmin resolves to Resource=JcrNodeResource, type=cq/ui/components/widget, superType=null, path=/apps/wcm/core/content/siteadmin
   3443 LOG Resource Path Info: SlingRequestPathInfo: path='/apps/wcm/core/content/siteadmin', selectorString='null', extension='html', suffix='null'
   3443 TIMER_START{ServletResolution}
   3446 TIMER_START{resolveServlet(/apps/wcm/core/content/siteadmin)}
   3455 TIMER_END{8,resolveServlet(/apps/wcm/core/content/siteadmin)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet
   3457 TIMER_END{14,ServletResolution} URI=/siteadmin handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet
   3459 LOG Applying Requestfilters
   3463 LOG Calling filter: com.adobe.granite.resourceresolverhelper.impl.ResourceResolverHelperImpl
   3469 LOG Calling filter: org.apache.sling.security.impl.ContentDispositionFilter
   3472 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
   3476 LOG Calling filter: com.adobe.granite.httpcache.impl.InnerCacheFilter
   3481 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
   3484 LOG Calling filter: com.adobe.cq.mcm.campaign.servlets.CampaignCopyTracker
   3486 LOG Calling filter: com.day.cq.wcm.core.impl.WCMRequestFilter
   3489 LOG Calling filter: com.adobe.cq.wcm.core.components.internal.servlets.CoreFormHandlingServlet
   3491 LOG Calling filter: com.adobe.granite.optout.impl.OptOutFilter
   3496 LOG Calling filter: com.day.cq.wcm.foundation.forms.impl.FormsHandlingServlet
   3498 LOG Calling filter: com.adobe.cq.social.commons.cors.CORSAuthenticationFilter
   3500 LOG Calling filter: org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
   3513 LOG Calling filter: com.day.cq.wcm.mobile.core.impl.redirect.RedirectFilter
   3515 LOG Calling filter: com.day.cq.wcm.core.impl.AuthoringUIModeServiceImpl
   3518 LOG Calling filter: com.adobe.granite.csrf.impl.CSRFFilter
   3522 LOG Calling filter: com.adobe.granite.rest.assets.impl.AssetContentDispositionFilter
   3525 LOG Calling filter: com.adobe.granite.requests.logging.impl.RequestLoggerImpl
   3528 LOG Calling filter: com.adobe.granite.rest.impl.servlet.ApiResourceFilter
   3822 LOG Calling filter: com.adobe.cq.social.ugcbase.security.impl.SaferSlingPostServlet
   3826 LOG Calling filter: com.day.cq.dam.core.impl.assetlinkshare.AdhocAssetShareAuthHandler
   3831 LOG Calling filter: com.day.cq.dam.core.impl.servlet.ActivityRecordHandler
   3839 LOG Applying Componentfilters
   3841 LOG Calling filter: com.day.cq.personalization.impl.TargetComponentFilter
   3844 LOG Calling filter: com.day.cq.wcm.core.impl.PageLockFilter
   3846 LOG Calling filter: com.day.cq.wcm.core.impl.WCMComponentFilter
   3958 LOG Calling filter: com.day.cq.wcm.core.impl.WCMDebugFilter
   3962 TIMER_START{org.apache.sling.servlets.get.DefaultGetServlet#0}
   3966 LOG No renderer for extension html
   3970 LOG Applying Error filters
   3970 LOG Calling filter: org.apache.sling.i18n.impl.I18NFilter
   3971 LOG Calling filter: org.apache.sling.rewriter.impl.RewriterFilter
   3973 TIMER_START{handleError:status=404}
   4138 TIMER_END{163,handleError:status=404} Using handler org.apache.sling.servlets.resolver.internal.defaults.DefaultErrorHandlerServlet
   5244 LOG Found processor for post processing ProcessorConfiguration: {contentTypes=[text/html], order=-1, active=true, valid=true, processErrorResponse=true, pipeline=(generator=Config(type=htmlparser, config={}), transformers=(Config(type=linkchecker, config={}), Config(type=mobile, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobile: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=mobiledebug, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-mobiledebug: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), Config(type=contentsync, config=JcrPropertyMap [node=Node[NodeDelegate{tree=/libs/cq/config/rewriter/default/transformer-contentsync: { jcr:primaryType = nt:unstructured, component-optional = true}}], values={jcr:primaryType=nt:unstructured, component-optional=true}]), serializer=Config(type=htmlwriter, config={}))}
   5340 TIMER_END{5339,Request Processing} Dumping SlingRequestProgressTracker Entries
 
The trace says org.apache.sling.servlets.get.DefaultGetServlet is used to render the response instead of specific one in this case it should heave been /libs/cq/ui/components/widget/html.jsp - this was the case for all the pages, default servlet were used for rendering the response.

  3455 TIMER_END{8,resolveServlet(/apps/wcm/core/content/siteadmin)} Using servlet org.apache.sling.servlets.get.DefaultGetServlet

  Based on the analysis

  •   All the bundles were active
  •   CRXDE and system console were accessible with out any issue
  •   There was no recent configuration changes or code deployment
  •   All the standard configurations were looking fine  

  Unfortunately we were not able to identify the root cause, it looks to be the server was not started completely last time.  The issue got resolved after restarting the server.


Tuesday, April 9, 2019

How to use the Request Processing Analyzer to analyze the recent requests in Adobe Experience Manager(AEM)

How to use the Request Processing Analyzer to analyze the recent requests in Adobe Experience Manager(AEM)


The “Recent Requests” is a very useful feature on the OSGi Felix Console to know what going on at each request, how is Sling resolving the resources and the time taken to load the sub resources.

This will help as to debug the resource resolution issues and also to capture the time taken to process the resources.

By default 20 recent request are captured in to the recent request console - http://localhost:4502/system/console/requests

Apache_Sling_Request_Processing_Analyzer

Apache_Sling_Request_Processing_Analyzer

The value "Number of Requests to Record" can be changed in the Apache Sling Main Servlet through OSGI console - http://localhost:4502/system/console/configMgr/org.apache.sling.engine.impl.SlingMainServlet

Also the "Recorded Request Path Patterns" can be specified in Apache Sling Main Servlet configuration to only capture the paths that matches the pattern - e.g capture only the json requests.

Apache_Sling_Request_Processing_Analyzer

Apache_Sling_Request_Processing_Analyzer

Unfortunately this will not help us to trace millions of request through console and also only the recent values will be shown based on the configuration.

Sometimes we may need to analyse huge requests during the load testing to identify the time taken by individual request and to identify the requests that taking more time to process.

Sling Request Processing Analyzer help to achieve the above scenario.

Sling Request Processing Analyzer logs each request in a special file - ${sling.home}/logs/requesttracker.txt with a header line providing core information on the request:

  • Start time stamp in ms since the Epoch
  • Request processing time in ms
  • Request Method
  • Request URL
  • Response content type (plus character encoding if available)
  • Response Status
After that first line the complete data from the requests RequestProgressTracker is dumped.

Configuring Request Processing Analyzer:

  • Download the Request Processing Analyzer bundle from https://github.com/apache/sling-org-apache-sling-reqanalyzer
  • Build the bundle - mvn clean install
  • Install the bundle(org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar) from target folder to server through OSGI console- http://localhost:4502/system/console/bundles


This will create a new log file - requesttracker.txt under ${sling.home}/logs and capture all the request details into the log file.

Apache_Sling_Request_Processing_Analyzer

Analyzing the log file:


The generated log file can be analyzed through the below command.

java -jar C:\sling-org-apache-sling-reqanalyzer-master\target\org.apache.sling.reqanalyzer-0.0.1-SNAPSHOT.jar requesttracker.txt

This will open the Swing GUI with basic request details - click on individual request to see more details about the request

Apache_Sling_Request_Processing_Analyzer

Apache_Sling_Request_Processing_Analyzer

The generated log file can be analyzed through system console - http://localhost:4502/system/console/requestanalyzer

Apache_Sling_Request_Processing_Analyzer
Click on Analyze Now action, this will open the same Swing GUI shown above.

Dumping the details to separate log file:


The Request Process details can be dumped to a separate log file for reference through Apache Sling Request Progress Tracker Log Filter - no bundle is required to be installed but this file can't be analyzed through the approach explained above. The dumped file details can be used for manual analysis.

Define a new logger with below details.

Apache_Sling_Request_Processing_Analyzer

Configure Apache Sling Request Progress Tracker Log Filter

Apache_Sling_Request_Processing_Analyzer

Configure the Extension filter with required file extensions for those the request details should be captured.

Select "Compact Log Format" - this will print the logs fin more readable format.

Apache_Sling_Request_Processing_Analyzer



Friday, April 5, 2019

How to disable the minification for client libraries in Adobe Experience Manager(AEM)

How to disable the minification for client libraries in Adobe Experience Manager(AEM)


Minification refers to the process of removing unnecessary or redundant data without affecting how the resource is processed by the browser - e.g. code comments and formatting, removing unused code, using shorter variable and function names, and so on.

Minfication helps to reduce the size of the resources(Java Script and CSS) and improves the performance of page loading.

Sometimes we may required to disable the minifcation for specific Java script files may be due to the files are already minified or the issue with minification process.

Adobe Granite HTML Library Manager:


Un-select minify option in Adobe Granite HTML Library Manager through configMgr(http://localhost:4502/system/console/configMgr/com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl)

disable-minification-clientlibrary-aem

Please note this is a global configuration and it will impact all the client libraries, non of the client libraries will be minified now and this will impact the performance. This approach is not recommended as this will disable the minification for all the client libraries.

Disable Minfication for specific client libraries:


Enable the minification in global configuration(Adobe Granite HTML Library Manager) - http://localhost:4502/system/console/configMgr/com.adobe.granite.ui.clientlibs.impl.HtmlLibraryManagerImpl and disable the minification for required client libraries in client library level. This will only disable the minification for specific client library.

disable-minification-clientlibrary-aem


To disable the minification for specific client library add the below properties to client library node.

To disable Java Script Minification - add jsProcessor String[] default:none, min:none

disable-minification-clientlibrary-aem2.png

Please note jsProcessor String[] default:none was disabling the minification for Java Scripts in AEM 6.2 but the same is not working in AEM 6.4(min:none should be added as additional configuration)

To disable CSS Minification - add cssProcessor String[] default:none, min:none

disable-minification-clientlibrary-aem

Please note cssProcessor String[] default:none was disabling the minification for CSS in AEM 6.2 but the same is not working in AEM 6.4(min:none should be added as additional configuration)


Thursday, April 4, 2019

Issue with turning off location tracker feature(Remove the geolocation store) in Adobe Experience Manager(AEM)

Issue with turning off location tracker feature(Remove the geolocation store) in Adobe Experience Manager(AEM)


I was trying to turn off the location tracker in AEM 6.4, unfortunately it was not working.

Steps Followed:


  • Define new clientcontex- /etc/clientcontext/new (copy the existing /etc/clientcontext/default node through CRXDE)
geo-location-tracker-aem

geo-location-tracker-aem

  • Remove the geolocation store from /etc/clientcontext/new
geo-location-tracker-aem

geo-location-tracker-aem

  • Change the clientcontext path in Design mode of a page.
geo-location-tracker-aem

  • Replicate the design(e.g /etc/designs/default) to publisher


Unfortunately after implementing above steps still the geo location tracker popup was displaying in the browser.

The popup is displayed due to the clientcontext path is still pointing to the default path - /etc/clientcontext/default(Geo Location store is available) instead of pointing to /etc/clientcontext/new(Geo Location store is not available)

 $CQ(function() {
        CQ_Analytics.SegmentMgr.loadSegments("\/etc\/segmentation");
        CQ_Analytics.ClientContextUtils.init("\/etc\/clientcontext\/default", "\/content\/sample\/test");        
    });

Based on the analysis the root cause of the problem is currentStyle.getPath() inside the clientcontext component was returning the wrong path value.

 currentStyle.getPath() was returning /etc/designs/default/jcr:content/homepage but the expected value is /etc/designs/default/jcr:content/homepage/clientcontext(this node has the property path with the value /etc/clientcontext/new) due to the wrong  currentStyle.getPath() is returned server was not able to locate the path property and used the default clientcontext value-/etc/clientcontext/default

 The design path was modified by the below code executed before including the client context - 

if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {
IncludeOptions.getOptions(getRequest(), true).forceSameContext(true);
getRequest().setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);
}

 <div data-sly-resource="${@path='clientcontext', resourceType='cq/personalization/components/clientcontext'}"></div>

The issue is resolved after changing the order of the above code blocks(this order should be maintained even if these two code blocks are in two different files).

<div data-sly-resource="${@path='clientcontext', resourceType='cq/personalization/components/clientcontext'}"></div>

if (!getWcmMode().isEdit() && !getWcmMode().isDesign()) {
IncludeOptions.getOptions(getRequest(), true).forceSameContext(true);
getRequest().setAttribute(ComponentContext.BYPASS_COMPONENT_HANDLING_ON_INCLUDE_ATTRIBUTE, false);
}

Now the /etc/clientcontext/new is considered and also the geolocation tracker popup is disabled.

 $CQ(function() {
        CQ_Analytics.SegmentMgr.loadSegments("\/etc\/segmentation");
        CQ_Analytics.ClientContextUtils.init("\/etc\/clientcontext\/new", "\/content\/sample\/test");        
    });


Tuesday, April 2, 2019

Exception while browsing the tags in page creation wizard: The method transform(Object) of type new Transformer(){} must override a superclass method - AEM

Exception while browsing the tags in page creation: The method transform(Object) of type new Transformer(){} must override a superclass method - AEM 


We were getting the following exception while browsing the tags in page creation wizard - http://localhost:4502/mnt/overlay/cq/gui/content/coral/common/form/tagfield/picker.html?root=%2fetc%2ftags&selectionCount=multiple&_=1554223439347 500 (Server Error)

tag_browsing_issue_500_error

tag_browsing_issue_500_error

tag_browsing_issue_500_error

The below exception is displayed while trying to open the above mentioned URL

Compilation errors in /libs/cq/gui/components/coral/common/form/tagfield/datasources/children/children.java: Line 78, column 3367 : The method transform(Object) of type new Transformer(){} must override a superclass method
Cannot serve request to /mnt/overlay/cq/gui/content/coral/common/form/tagfield/picker.html in /libs/cq/gui/components/coral/common/form/tagfield/datasources/children/children.java

Exception:
org.apache.sling.scripting.java.impl.ServletWrapper$CompilerException: Compilation errors in /libs/cq/gui/components/coral/common/form/tagfield/datasources/children/children.java:
Line 78, column 3367 : The method transform(Object) of type new Transformer(){} must override a superclass method

tag_browsing_issue_500_error

Steps to resolve the issues:


Clear the compiled JSP cache:


The compiled jsp class files might have corrupted, follow the below steps to remove the existing classes and recompile the JSP's

Go to http://aem-host:port/system/console/slingjsp
Click Recompile all JSPs.

Unfortunately the specified issue was not resolved after clearing the cache.

Verify the Source VM and Target VM in Apache Sling Java Script Handler:


Ensure the the Source VM and Target VM values are specified with the version the AEM server is running or specify as auto to automatically consider the current VM version.

In our case the VM version was pointing to 1.5 but our current VM version is 1.8, the issue was resolved after changing the VM versions to auto.

This issue was observed in AEM 6.4 version after upgrading from AEM 6.2, the same VM version(1.5) was working in AEM 6.2 without any issue.

tag_browsing_issue_500_error

tag_browsing_issue_500_error