Saturday, August 20, 2016

How to invalidate the dispatcher cache for dam assets referred from multiple sites? - Adobe CQ5/AEM

How to invalidate the dispatcher cache for dam assets referred from multiple sites? - Adobe CQ5/AEM

Sometimes, we may have the scenario like the same DAM asset is referred from multiple sites and cached locally(site specific) in dispatcher for all the sites. The local cache of all the sites should be invalidated whenever the asset is modified.

This post will explain how to achieve the above mentioned scenario.

Create a user in all the publisher and provide only the access to DAM- /content/dam


Create a flush agent for individual sites with the following details in all the publishers(repeat the below step for all the sites)




Agent user Id: Specify the user created in the first step
URI : Specify the URL with dispatcher server name
HTTP headers : Specify the site name(DNS for the site) as Host and specify CQ-Action-Scope: ResorceOnly(this will inform the dispatcher to only invalidating the dam asset by deleting it and not touching the .stat file)

Now, whenever the asset is modified all the local cache will be invalidated.




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:
Login to Jenkins console --> 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



java.util.concurrent.ExecutionException: hudson.util.IOException2: Failed to create a temporary file in xxxxx/figerprints/2c/73

We were receiving the following exception while executing the deployment jobs from Jenkins

java.util.concurrent.ExecutionException: hudson.util.IOException2: Failed to create a temporary file in xxxxx/figerprints/2c/73



Based on the analysis, the issue happened due to in sufficient space in the server.


The deployment got success after freeing some space in the server.



Saturday, April 23, 2016

How to modify the scheduler time for daily and weekly maintenance jobs - AEM 6.1?

This post will explain the steps to modify the scheduler time for daily and weekly maintenance jobs in AEM 6.1.

To change the scheduled time of the jobs:

Login to CRXDE and navigate to /libs/granite/operations/config/maintenance/granite:weekly or /libs/granite/operations/config/maintenance/granite:daily

Change the windowStartTime and windowEndTime accordingly to change the schedule time of the job.




Click on the job category, this will display the status of the current job and the next schedule time.
We will be able to see the message related to the job failure and also will be able to start the Job immediately.




To stop the scheduled jobs – Login to OSGI console and stop the bundle -“Granite Maintenance OAK”






Friday, April 15, 2016

How to manage the i18 translation in Adobe CQ5 (AEM)

This post will explain how to manage the i18 translation in Adobe CQ5 (AEM)

Follow the below URL to create the i18 language nodes for first time.

The translator.html can be used to manage the i18 translation for different languages.


Here you can add/delete modify keys and language values.

Whenever we perform any operation the same can be viewed from CRXDE – under the language node created as part of the first step.

The i18 keys can be replicated to publisher in different ways as mentioned below.
·         Manually creating the i18 nodes in publisher
·         Creating the package from author and deploying it to publisher
·         Replicating the nodes through tree activation


Select the node that needs to be replicated and activate
Selected nodes will be replicated to publisher



Thursday, April 7, 2016

How to restrict crawling/indexing of specific URLs in Adobe Search and Promote(Adobe S&P)

Some cases we may need to index specific type of URLs from the website and excluding all other URLs available.

The URL Masks can be used in Adobe S&P to achieve this.

URL mask will help us to define the rules to include or exclude the specific URLs during the indesing.

We will be able to define include and exclude rules

Include - pattern that specifies the URLs will be indexed
Exclude - pattern that specifies the URLs will be excluded from the indexing.

To index the URLs that is starting with mask.


The crawler will index all the URLs that starts with https://server.com/content/doc

To index the URLs that is in the particular format.

This crawler will index all the URLs matching with  - https://server.com/content/doc/*.html?id=*

e.g. https://server.com/content/doc/sample.html?id=123

Regex can be used to match the URLs for indexing


This crawler will index all the URLs matching with the regex ^.*/content/doc/.*\.html$
e.g. https://server.com/content/doc/sample.html



Wednesday, April 6, 2016

How to Clear/Recompile the JSP classes in AEM 6.1

Sometime when we are deploying the packages, the JSP classes will not get compiled automatically in AEM 6.

We can follow the below option to clear/recompile the JSP classes.

Login to - http://<AEM HOST>:<AEM PORT/system/console/slingjsp

Click on Recompile all JSPs




Saturday, February 13, 2016

Pending - Waiting for next available executor/Disk space too low on /tmp - Jenkins

Pending - Waiting for next available executor/Disk space too low on /tmp - Jenkins

While we were trying to execute the job, it was displaying "Pending - Waiting for next available executor". When looking into the Jenkins node from the console, the Master node is offline and the error message displayed was "Disk space too low. Only xxxGB on /tmp" but the /tmp folder has space around 1GB.





The following steps are followed to resolve the issue.

  • Increase the space available in /tmp folder. If not able to increase the space in /tmp folder then TemporarySpaceMonitor can be disabled or the memory threshold value of the TemporarySpaceMonitor can be reduced in $JENKINS_HOME/nodeMonitors.xml(make sure atleast minimum memory is available)


<?xml version='1.0' encoding='UTF-8'?>
<hudson.util.DescribableList>
  <hudson.node__monitors.ArchitectureMonitor>
    <ignored>false</ignored>
  </hudson.node__monitors.ArchitectureMonitor>
  <hudson.node__monitors.ClockMonitor>
    <ignored>false</ignored>
  </hudson.node__monitors.ClockMonitor>
  <hudson.node__monitors.DiskSpaceMonitor>
    <ignored>false</ignored>
    <freeSpaceThreshold>1GB</freeSpaceThreshold>
  </hudson.node__monitors.DiskSpaceMonitor>
  <hudson.node__monitors.SwapSpaceMonitor>
    <ignored>false</ignored>
  </hudson.node__monitors.SwapSpaceMonitor>
  <hudson.node__monitors.TemporarySpaceMonitor>
    <ignored>false</ignored>//Change to true to disable monitoring 
    <freeSpaceThreshold>50MB</freeSpaceThreshold>
  </hudson.node__monitors.TemporarySpaceMonitor>
  <hudson.node__monitors.ResponseTimeMonitor>
    <ignored>false</ignored>
  </hudson.node__monitors.ResponseTimeMonitor>
</hudson.util.DescribableList>

  • Increase the number of executor from default value 2


  • Remove the following content from $JENKINS_HOME/config.xml

<temporaryOfflineCause class="hudson.node_monitors.DiskSpaceMonitorDescriptor$DiskSpace">
    <path>/tmp</path>
    <size>966733824</size>
    <triggered>true</triggered>
    <trigger>hudson.node_monitors.TemporarySpaceMonitor</trigger>
  </temporaryOfflineCause>

  • Restart the Jenkins server.



Wednesday, February 10, 2016

Restricitng the content access to authenticated user - Adobe CQ5/AEM

By default anonymous user in AEM will have the read access to content, so the content can be accessed via dispatcher/publisher directly without providing any credential.

This blog will explain how to restrict the content access to only authenticated users via dispatcher(including cached content) and publisher.

Remove the access of Anonymous user for content node in publisher


Create a user sample1 in publisher and provide the read access for content node (Multiple users can be created based on the requirement)



Enable the authentication in dispatcher:

Execute the below command to create the passwordfile and add the user - htpasswd -c /etc/httpd/conf/dispatcher.htaccess sample1 (enter the same password used in the publisher for sample1)

Command to add the users to the existing password file - htpasswd /etc/httpd/conf/dispatcher.htaccess sample2 (Multiple users can be created as per requirement, make sure the users are also created in publisher with same credentials)

Add the below configurations in httpd.conf file

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
Require valid-user

 Make sure the below mentioned line is commented out in httpd.conf file

 #RequestHeader unset Authorization

 Securing the cached content:

 Refer the following Adobe blog to enable the same - https://docs.adobe.com/docs/en/dispatcher/permissions-cache.html

 Make sure you are merging the existing /filter section with /auth_checker -/filter section in dispatcher.any file.



Monday, February 8, 2016

Enabling basic authentication for different directories with differnt credentials in dispatcher - Adobe CQ5/Adobe AEM

Separate credential for two different directories:

Create the .httpaccess for different directories

htpasswd -c /etc/httpd/conf/dispatcher.htaccess <username>
htpasswd -c /etc/httpd/conf/dispatcher1.htaccess <username>

Add the below configuration in the httpd.conf

<LocationMatch ^/content/sample1*>
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/sample1* auths=0
AuthName "Please login to access the site"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</LocationMatch>

<LocationMatch ^/content/sample2*>
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/sample2* auths=1
AuthName "Please login to access the press release"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher1.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</LocationMatch>

Restart the dispatcher

Now you will be able to access /content/sample1 and /content/sample2 with different credential

There is a another scenario, separate credential for particular directory and rest of all the directories will use the same credentials.

Create the .httpaccess for different directories

htpasswd -c /etc/httpd/conf/dispatcher.htaccess <username>
htpasswd -c /etc/httpd/conf/dispatcher1.htaccess <username>

<Location />
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/* auths=1
SetEnvIf Request_URI ^/content/sample2* auths=0
AuthName "Please login to access the site"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</Location>

<LocationMatch ^/content/sample2*>
# unsets authorization header when sending request to AEM
RequestHeader unset Authorization
SetEnvIf Request_URI ^/content/sample2* auths=1
AuthName "Please login to access the press release"
AuthType Basic
AuthUserFile /etc/httpd/conf/dispatcher1.htaccess
# first, allow everybody
Order Allow,Deny
Satisfy any
Allow from all
Require valid-user
# then, deny only if required
Deny from env=auths
</LocationMatch>

Restart the server.



Friday, January 29, 2016

send-mail: fatal: open /etc/postfix/main.cf: No such file or directory - Linux

I was receiving the following exception "send-mail: fatal: open /etc/postfix/main.cf: No such file or directory" while trying to send the mail through cron job. But the main.cf file is available in the specified location /etc/postfix/main.cf.

I tried providing the complete permission to /etc/postfix/main.cf but this not resolved the issue.

Followed the below steps to fix the issue:

yum reinstall postfix

postfix stop
postfix start





Friday, January 15, 2016

Not able to access the siteadmin and useradmin pages - Adobe CQ5

We were not able to access the useradmin,siteadming and other website pages in one of our publisher but was able to access the crxde and system console.

After analysis the issue is due to some of the bundles were stopped(100+), we tried to start those bundles manually without any luck.

The following was the exception in the log file.

11.01.2016 16:48:47.307 *ERROR* [FelixDispatchQueue] com.day.cq.collab.cq-collab-core FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle com.day.cq.collab.cq-collab-core [166]: Unable to resolve 166.0: missing requirement [166.0] osgi.wiring.package; (&(osgi.wiring.package=com.day.cq.collab.commons)(version>=0.0.0)(!(version>=5.7.0))) [caused by: Unable to resolve 165.0: missing requirement [165.0] osgi.wiring.package; (osgi.wiring.package=com.day.cq.wcm.api) [caused by: Unable to resolve 288.1: missing requirement [288.1] osgi.wiring.package; (osgi.wiring.package=com.day.cq.tagging) [caused by: Unable to resolve 218.1: missing requirement [218.1] osgi.wiring.package; (&(osgi.wiring.package=com.day.cq.search)(version>=1.1.0)(!(version>=2.0.0))) [caused by: Unable to resolve 209.1: missing requirement [209.1] osgi.wiring.package; (&(osgi.wiring.package=org.apache.abdera.ext.media)(version>=1.0.0)(!(version>=2.0.0)))]]]])

This error points to missing package of org.apache.abdera.ext.media and this belongs to the bundle - Abdera Extensions - Media.
After looking into the system console, the bundle is not there and it got uninstalled(not sure how it got uninstalled).

Follow the below steps to resolve the issue.

Identify the bundle id from another environment.


Copy the bundle.jar from the serer.


Rename the bundle.jar to abdera-extensions-media-1.0-R783018.jar
Install the bundle through system console.
Restart the server.

Now all the pages will be accessible.



Contact Form

Name

Email *

Message *