Saturday, July 9, 2016

How to populate the current page path to the dialog through EXT JS - AEM 6.1

This post will explain, how to populate the current page path to the dialog through EXT JS - AEM 6.1

Add the listener for the widget and use the below script.

function(widget) {
        var currentPath;
if(CQ.wcm.SiteAdmin.hasListSelection()) {
        var grid = CQ.wcm.SiteAdmin.getActiveGrid();
        var selections = grid.getSelectionModel().getSelections();
currentPath = selections[0].id;
console.log(currentPath);
widget.setValue(currentPath)
}
}








Friday, June 24, 2016

Caused by: org.apache.sling.api.resource.PersistenceException: Resource is not modifiable - Adobe CQ5/AEM

The below exception will be thrown most of the cases while accessing the servlet with post from AEM.

The actual issue is AEM could not ale to resolve the servlet and assumes it as a resource path but this is not a valid resource path, the below exception will be thrown when AEM tries to set the property values.

Caused by: org.apache.sling.api.resource.PersistenceException: Resource at '/services/formservlet' is not modifiable.
    at org.apache.sling.servlets.post.impl.helper.SlingPropertyValueHandler.setProperty(SlingPropertyValueHandler.java:153)
    at org.apache.sling.servlets.post.impl.operations.ModifyOperation.writeContent(ModifyOperation.java:411)
    at org.apache.sling.servlets.post.impl.operations.ModifyOperation.doRun(ModifyOperation.java:101)

The steps to narrow down the issue:

Resolve the Servlet:

Go to http://<<AEM Host>>:4503/system/console/configMgr - Sling--> Sling Servlet Resolver and resolve the servlet path, if the servlet path is resolved then there is no issue if not the servlet is not configured properly.

Path resolved to a Servlet


Path not resolved a Servlet

Verify the Servlet configuration:

Cross verify and make sure the servlet is configured properly

e.g servlet

@Component(
immediate = true,
label = "Servlet",
description = "Servlet",
metatype = true)
@SlingServlet(
name = "FormServlet",
description = "FormServlet",
methods = "POST",
generateComponent = false,
paths = "/services/formservlet")
@Service(value = Servlet.class)
public class FormServlet extends SlingAllMethodsServlet implements Serializable {

@Override
protected void doPost(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
        }
protected void doGet(SlingHttpServletRequest request,
SlingHttpServletResponse response) throws ServletException,
IOException {
doPost(request, response);
}

}

Verify the servlet resolver configuration:

Go to http://<<AEM Host>>:4503/system/console/configMgr - Sling--> Apache Sling Servlet/Script Resolver and Error Handler and make sure the servlet base patch is added under Execution paths.


Apache Sling Referrer Filter:

If the servlet is invoked externally then make sure the host name of the source system is added to the Allow Hosts section of the Apache Sling Referrer Filter


CSRF Filter(above AEM 6.1):

Adobe added CSRF (Cross-Site Request Forgery) protection with version 6.1 and we need to ensure that the CSRF token is included while submiting the form.

This should be handled automatically if we are using AEM's version of jQuery. This library has the code to get the token and add it to all XHR and forms.

If we are using a different version of jQuery or not using the jQuery, then we have to include the 'granite.csrf.standalone' client library and it will do the same functionality.

Refer the following link for more details - https://helpx.adobe.com/experience-manager/using/custom-sling-servlets6_1.html


Also, if the servlet is working properly from publisher/author and not only working from dispatcher then the issue might be with some of the cached scripts in dispatcher is not updated, try to clear the dispatcher cache for JS scripts and try the scenario again.




Wednesday, June 22, 2016

Dispatcher Cache Invalidation for Multi Site Configuration - Adobe CQ5(AEM)

This post will explain the approach to invalidate the cache for particular site in multi site configuration - Adobe CQ5(AEM).

Recently, i was working on a dispatcher caching issue with multi site configuration - The cache was not getting invalidated in all the dispatcher.

The setup is with multiple dispatcher connected via load balancer. The load balancer will route the request to individual dispatchers via round robin algorithm. The dispatcher is configured with individual virtual host and farm for every site(Load balanced DNS is used).

The flush agent was configured in publisher for every site with load balanced DNS(the flush agent was equal to number of sites configured in dispatcher) - The issue here is when ever publisher send the invalidation request that is not reaching the corresponding dispatcher as the flush agent is configured with load balanced DNS for invalidation URI - The request will be send to random dispatcher from the load balancer due to this the cache will not be invalidated in all the dispatcher.

Solution:

Create a flush agent in individual publisher that points to individual dispatcher(based on the renders configuration). The flush agent should be configured with dispatchers server name(one flush agent in one publisher)

http://dispatcher1.server.name:80/dispatcher/invalidate.cache


Make sure the following HTTP Headers are configured.


The flush agent can be configured in author also, if we are configuring in author then the number of flush agents should be equal to number of dispatchers.

Create a Location Match in all the dispatchers httpd.con file for all the websites.

<LocationMatch "^/dispatcher/invalidate.cache$">
 
    # Site Finance
    SetEnvIfNoCase CQ-Path ".*/content/sample1/.*" FLUSH_HOST=sample1.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST

    # Site TR
    SetEnvIfNoCase CQ-Path ".*/content/sample2/.*" FLUSH_HOST=sample2.com
    RequestHeader set Host %{FLUSH_HOST}e env=FLUSH_HOST
</LocationMatch>

Based on the CQ-Path the corresponding sites cache will be invalidated.

Referred from  - http://www.netcentric.biz/blog/2016/01/aem-dispatcher-cache-invalidation-for-multiple-dispatcher-farms.html



Monday, June 20, 2016

Query the pages with the properties of child node - Adobe CQ5/AEM

Query to find the pages with the properties of child nodes of the page


SELECT * FROM [cq:Page] AS page WHERE ISDESCENDANTNODE(page ,"<<Parent folder of pages>>")  AND [jcr:content/<<child node name>>/<<child node property>>]=<<value>>

e.g

SELECT * FROM [cq:Page] AS page WHERE ISDESCENDANTNODE(page ,"/content")  AND [jcr:content/test_node/test_property=test

http://<<AEM Host>>:<<AEM Port>>/crx/explorer/ui/search.jsp - Paste the query and click on Search Now.



Tuesday, May 31, 2016

Integration of Jenkins server with GIT Hub

We are having multiple blogs around this but could not able to find the complete information on this.

Thought of sharing this for my reference too. This post will explain how to integrate Jenkins in Linux with private GIT Hub.

Configuring the GIT plugin in Jenkins:

Jenkins à Manage Jenkins à Manage Plugins
Make sure Jenkins GIT Client Plugin and Jenkins GIT plugins are installed.


Configure GIT in server:

Login to Jenkins server via puty
Execute the following command - sudo yum install git-all

Configure GIT executable path:

Jenkins àMange JenkinsàConfigure System
Enter the git executable path(git installed to the server in previous step)
My case the path is /usr/bin/git, change accordingly


SSH Configuration:

Login to Jenkins server via putty
Execute the following commad - sudo -u jenkins ssh-keygen -t rsa
Enter the details accordingly, Passphrase is optional if required then enter some string.
This will create private and public keys under /var/lib/jenkins/.ssh (default files are id_rsa and id_rsa.pub)

Configuring Credential:

Jenkins àCredentials
Click on add a domain – Enter some name(better git hub host name)
Click on Add credential
Enter the user name as Jenkins(the user that runs the jenkins)
Select From the Jenkins master ~/.ssh


Configure deployment key in GIT:

Login to GIT and click on Profile Settings
Click on SSH Keys – Enter the content of id_rsa.pub(cat id_rsa.pub) to Key filed
Click on add key.



Configure the Job:

Configure the GIT URL and select the credential name created in the previous step
Specify the branch to be build.





Saturday, April 30, 2016

Only a type can be imported. xxxxxx resolves to a package - AEM/Adobe CQ5

We were receiving the following error in run time due to this the pages got broken. The same scenario was working fine earlier and broken without any code or config change to the server.

We have tried multiple options as follows without any luck
  • Re-deploying the code to affected server
  • Restarting the server
  • Removing run time class files - /var/classes/org/apache
  • Recompile/Clear the JSP classes - http://www.albinsblog.com/2016/04/how-to-clearrecompile-jsp-classes-in-AEM-6.1.html
We could not able to identify the root cause but as a work around manually added a space to the component and saved through CRXDE and that helped to fix the issue.



Friday, April 29, 2016

How to disable the online compaction - AEM/Adobe CQ5

AEM 6.1 will have daily job scheduled and that will perform the online compaction.

Some times this may cause performance issue when the online compaction takes more time to complete due to load or authoring.

As a solution the online compaction job can be disabled and offline compaction can be used whenever required based on the maintenance window.

Steps to disable online compaction:
  •  Go to CRXDE path - /libs/granite/operations/config/maintenance/granite:daily/granite:RevisionGC
  • Changed run mode from crx3 to crx3-disabled
  • Save



Contact Form

Name

Email *

Message *