Showing posts with label Troubleshooting. Show all posts
Showing posts with label Troubleshooting. Show all posts

Sunday, 18 February 2018

Ajax reqeuts getting cached in IE and Firefox

Usecase: Debug ajax cache issues in IE and Firefox.

Issue: Ajax requests return wrong or same data in IE and Firefox, since the requests get cached in the browser. Requests work for the first time, from next time browser will give the same result.

Root Cause: When a GET request is made to a web service, IE will automatically cache the responses from GET requests. Once IE has successfully made a GET request, it will no longer make a new AJAX call until the cache expires on that object.


  1. Use POST: Use POST requests instead of GET requests in your application. However, this is bad practise, simply because POST requests should only be used when you are submitting data or modifying a resource on the server.
  2. Response Headers: You can prevent caching by sending additional headers along with your response. By specifying the “Cache-Control” header with a value of “no-cache,no-store” and returning it with the web service response you can instruct the browser not to cache the result. For example in C#:HttpContext.Current.Response.AddHeader("Cache-Control","no-cache,no-store");
  3. Cache Buster: A cache-buster is a dynamic parameter that you append to a request which makes each request unique, most commonly a random number or the current date/time ticks.
    1. var url = '/get/userDetails?buster='+new Date().getTime();
  4. Disable Cache for JQuery AJAX Request:  If you’re using JQuery to perform your Ajax requests, you can add cache: false to the parameter list like so:
    url: url,
    cache: false,
    dataType: 'json',
    type: "GET",
    data: data,
    success: func,
    error: ajaxError
If you want to globally setup cache for all JQuery AJAX requests use below code.
$.ajaxSetup({ cache: false });

Wednesday, 16 August 2017

Troubleshooting AEM 6.1 to AEM 6.2 upgradation

When we try to upgrade website developed on AEM 6.1 to AEM 6.2 we need to consider below points.

Update uber.jar version to 6.2.0


Issue 1:

When tried to build code we normally see below error message.
java.lang.NoClassDefFoundError: com/day/cq/commons/Externalizer

06.07.2017 09:55:54.242 *ERROR* [0:0:0:0:0:0:0:1 [1499331350444] GET /content/kishore/en/test.html HTTP/1.1] Exception: com/day/cq/commons/Externalizer
java.lang.NoClassDefFoundError: com/day/cq/commons/Externalizer

Fixed this issue by rebuilding the package with AEM 6.2 uber.jar

Issue 2:
Caused by: 
Cannot find a a file corresponding to class com.aem.kishore.HelloWorld in the repository.


This issue is caused due to the Java version. Use the correct java version preferably Java 8.

Saturday, 22 July 2017


Sometimes when we try to deploy code, bundles may not be in active state in AEM 6.1. We can see below error message.

Error Message:
22.07.2017 10:40:27.509 *ERROR* [qtp2141213534-59] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Unresolved constraint in bundle com.aem.kishore.bundle-core [463]: Unable to resolve 463.2: missing requirement [463.2] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.cq.sightly)(version>=2.2.0)(!(version>=3.0.0))))

org.osgi.framework.BundleException: Unresolved constraint in bundle com.aem.kishore.bundle-core[463]: Unable to resolve 463.2: missing requirement [463.2] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.cq.sightly)(version>=2.2.0)(!(version>=3.0.0)))

  • Delete existing bundle first.
  • Add below code in bundle pom.xml and rebuild the code.

Tuesday, 18 July 2017

org.osgi.framework.BundleException: osgi.wiring.package=com.adobe.cq.mcm.salesforce

Sometimes when we try to deploy code, bundles may not be in active state in AEM 6.1. We can see below error message.

Error Message:
18.07.2017 23:44:01.519 *ERROR* [qtp1756110899-265] org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Unresolved constraint in bundle com.aem.kishore.bundle-core [654]: Unable to resolve 654.1: missing requirement [654.1] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.cq.mcm.salesforce)(version>=1.1.0)(!(version>=2.0.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle com.aem.kishore.bundle-core [654]: Unable to resolve 654.1: missing requirement [654.1] osgi.wiring.package; (&(osgi.wiring.package=com.adobe.cq.mcm.salesforce)(version>=1.1.0)(!(version>=2.0.0)))

  • Delete (or stop) the ''org.eclipse.equinox.region" bundle from the felix.
  • Delete the existing custom bundle.
  • Restart the server (check without restarting) and then redeploy your code bundle.
This bundle has some dependency with eclipse and should not be in AEM6.1, it was meant for AEM 6.2. But somehow it got introduced in this version.

If still issue is not resolved check this post.

Tuesday, 11 July 2017

java.lang.NoClassDefFoundError: com/day/cq/commons/Externalizer

I have developed a website using AEM 6.1 API. In some piece of java code I used the Externalizer class from AEM ( This piece of code worked fine in 6.1 aem instance. When tried to deploy on AEM 6.2 got below error.

06.07.2017 09:55:54.242 *ERROR* [0:0:0:0:0:0:0:1 [1499331350444] GET /content/kishore/en/test.html HTTP/1.1] Exception: com/day/cq/commons/Externalizer
java.lang.NoClassDefFoundError: com/day/cq/commons/Externalizer


Fixed this issue by rebuilding the package with AEM 6.2 uber.jar

Offline Compaction - AEM Repository Size Growing Rapidly

Sometimes we observe AEM repository size increase rapidly. This post helps you in decreasing the respository size

AEM Repository Offline Compaction

  • Create new folder compact and place oak-run-1.2.2.jar and below .bat file.
  • Create a .bat file containing below code

java -jar oak-run-1.2.2.jar compact C:\Users\Kishore\AEM\crx-quickstart\repository\segmentstore

Download oak-run-1.2.2.jar

Monday, 3 July 2017

Not able to inherit page properties from parent page

I have created a live copy from Geometrixx site. I have pointed cq:template and sling:resourceType of parent page to my custom template and page component. I have created a new child page, when I checked the page properties of child page I don't see inheritance (lock symbol) on my child page properties dialog.


I am able to see the lock symbol on child page properties dialog after adding the mixin "cq:LiveRelationship".

Saturday, 1 July 2017

AEM Page Properties Touch UI Dialog conversion issue

When tried to create a touch dialog of page properties from classic ui we may may get duplicate widgets on the newly created touch dialog from dialog conversion tool. See how to create touch dialog from dialog conversion tool.

To avoid above issue you can use granite/ui/components/foundation/include resource type in the touch ui for including granite UI components in the current component dialogs. Take a look at the following example in crxde - /libs/wcm/foundation/components/page/cq:dialog/content/items/tabs/items/basic

Failed to execute goal org.apache.felix:maven-scr-plugin

I have created maven archetype 10 project for AEM 6.1 and jdk 1.8. When I ran mvn clean install I ran in to below errors.

1) When maven-scr-plugin (1.11.0) and org.apache.felix.scr.annotations (1.9.0)
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.11.0:scr (generate-scr-descriptor) on project digital-spearhead-core: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.11.0:scr failed. IllegalArgumentException -> [Help 1]

2) When maven-scr-plugin (1.12.0) and org.apache.felix.scr.annotations (1.9.0)
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.12.0:scr (generate-scr-descriptor) on project aem-sample-core: SCR Descriptor parsing had failures (see log) -> [Help 1]

Use correct maven-scr-plugin and org.apache.felix.scr.annotations versions.  I have used maven-scr-plugin (1.20.0) and org.apache.felix.scr.annotations (1.9.0), now build is success.

Tuesday, 27 June 2017

AEM Components not loading in touch ui

I am facing below issues when working on touch UI
  1. I don't see the components on the left rail though I have added the components from design mode. I am dragging and dropping the component from classic ui. I found in forum that there is cache issue in touch ui. Cannot find my components in touch ui sideline. I could see this error on page load /libs/wcm/core/content/components.1498484847911.html?_=1498484940719 500 (Server Error)
  2. When I tried to author the touch ui dialog and click on save, I don't see page is refreshed and authoring changes are not reflected. I see below JS error in browser console.
Error 1:

Error 2:
Uncaught TypeError: Cannot read property 'componentConfig' of undefined
    at f (editor.min.js:4355)
    at Object.<anonymous> (editor.min.js:4578)
    at i (jquery.min.js:784)
    at Object.fireWith [as resolveWith] (jquery.min.js:820)
    at cf (jquery.min.js:2421)
    at XMLHttpRequest.i (jquery.min.js:2519)

Error 3:

Uncaught Error: Components could not be loaded.

Error 4:
GET https://localhost:5433/libs/wcm/core/content/components.1537887896814.html 500 (Server Error)

Root Cause:
when I hit url [1], am getting below exception.
It seems that total number of components in AEM instance is more than the default number i.e 1500 (AEM 6.1) or 1000 (AEM 6.2). So the new components are not displayed in side rail and not able to edit the existing components.

We need to increase the "sling.max.calls" property value of "Apache Sling Main Servlet" OSGI config. My total component count was 1602, I have increased to 2000 and solved above 2 issues

Wednesday, 21 June 2017

Bundle is not uploading after maven build

Check first if bundle is installed in /system/console/bundles. check if jar files is present in /apps/app-name/install folder. If bundle is not present then change the filter.xml as shown below.

Under the path definition /apps/<appname>, define the following include and exclude rules
  • include pattern="/apps/<appname>(/.*)?"
  • exclude pattern="/apps/<appname>/install(/.*)?"
Note: these rules ensure that your bundle will be reinstalled upon every reinstall of the package.
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/app-name">
<include pattern="/apps/app-name(/.*)?" />
<exclude pattern="/apps/app-name/install(/.*)?" />
<filter root="/etc/designs/app-name">
<filter root="/apps/sling/servlet/errorhandler/500.jsp" />

Saturday, 17 June 2017

Changing a .content.xml file locally is not reflecting in CRX after maven build

If .content.xml file is changed locally and changes are not reflecting in crx then check maven-resources-plugin.

Add below plugin in pom.xml of UI module.(aem-sample/aem-content-ui/pom.xml).


For maven-resources-plugin check that its copying your .content.xml to target folder and for content-package-maven-plugin check that correct filter values are set.
We can also verify by extracting the generated package and check if it has the changes or not or look at a vault-work directory in target and get to the directory in which you have changed the .content.xml, verify if it has changes. If your changes are there in vault-works then the maven-resources-plugin is working absolutely fine and the issue may be with the content-package-maven-plugin.

If bundle is not installed check this post.

Monday, 24 April 2017

AEM OSGI component is not visible

When new AEM project is created we may find OSGI components are not displayed in /system/console/components or in or in bundle.

To avoid this add the below plugin in the parent pom.xml and rebuild the project


Monday, 17 April 2017

Cannot create maven project

When trying to create maven project using multi module content package archetype we may get exception

Maven command to create project:

mvn archetype:generate -DarchetypeRepository= -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=com.mycompany.myproject.htl -DartifactId=htl -Dversion=1.0-SNAPSHOT -Dpackage=com.mycompany.myproject.htl -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="5.6.1" -DpackageGroup="My Company"


Caused by: org.apache.maven.plugin.MojoFailureException: The desired archetype does not exist (


Check the settings.xml under .m2 folder.

Friday, 14 April 2017

AEM: design and preview mode toolbar not visible

If you are using the sidekick on an author instance of CQ, you may notice that the toolbar at the bottom which includes the design and preview mode buttons, is not visible or available.
The functionality in the sidekick is determined by the ACLs (Access-Control-Lists) defined in the CQ server.  If you do not have the appropriate privileges then functionality may be hidden in your sidekick.  Sometimes the sidekick may become unstable if you add faulty components to the page, or after you have installed some packages that may have overwritten required objects in your application, breaking some dependencies.

You should first try to clear your browser cache, and then reload the page from WCM console to refresh the sidekick.
You should also ensure you have the correct privileges to access the appropriate design in /etc/designs.  This can be changed by an administrator on the Users tab in the siteadmin console.  If the privileges appear to be correct, then try to disable them, save, and then re-enable them and save.  The sidekick should now display the toolbar again as expected.

To display the design button on the sidekick enable Modify permission for etc path.

Tuesday, 11 April 2017

AEM Component is in satisfied state, not in active

Some times we face OSGI component is in active state when the component is installed for the first time. When we modify the component from configMgr, component state changes to satisfied.

To avoid this and make the component in active state add the annotation @Activate to the activate method. This helps in changing the component state to Active whenever the component is modified.

Tuesday, 28 March 2017

Salesforce: Can't refresh access token. Response: {"error":"invalid_grant","error_description":"token validity expired"}

Sometimes we may not be able to refresh the Salesforce access_token using the rest api and get below error in logs

28.03.2017 23:41:40.184 *ERROR* [0:0:0:0:0:0:0:1 [1490724696957] GET /content/training/en/salesforce/jcr:content/par/salesforcesearch.html HTTP/1.1] com.adobe.cq.mcm.salesforce.SalesforceClient Can't refresh access token. Response: {"error":"invalid_grant","error_description":"token validity expired"}

Root cause:
This issue is due to the "Refresh Token Policy" settings of the connected app is set to "Immediately expire refresh token"

Follow the below steps to resolve this issue:

  • Goto setup -> Connected apps ->Manage Policies
  • Select Refresh Token Policy as Refresh token is valid until revoked

Wednesday, 22 February 2017

Custom bundles are in installed state after AEM server restart

Many a times while working with AEM we find various errors related to bundles.Sometimes it is very dificult to find as to why AEM bundles are going to installed state.

Adobe has given us a HOTFIX for this issue.
"AEM bundles going to installed sate" HOTFIX comes in the form of a small JAR file.
he AEM bundle hotfix comes in the form of org.eclipse.equinox.region jar file. 

Solution 1:

If you have tried other ways and just couldn't get it working and still see various AEM system
bundles in installed state then try to install this JAR into your Felix console /system/console/bundles

Click here to Download Jar

This is a good fix which works most of the time. Also trying this solution will not hurt.You can
always delete the bundle if it didn't do the job. 

AEM will refresh all the bundles. So please wait 5 minutes after installing the Equinox HOTFIX.
Solution 2:
For AEM version 6.1 only.

If the above method didn't resolve your problem then try to remove equinox related JAR file.
Look for a bundle with this name "Region Digraph(org.eclipse.equinox.region)"

Now remove this bundle. Also remove the bundle you installed in Solution 1 if necessary.
Long story short, there should not be any equinox jars installed.

Why this Happens?

According to Adobe the equinox eclipse bundle has some dependency with eclipse and should not be in AEM6.1, it was meant for AEM version 6.2. But this bundle got introduced in this version.

Other Version of Jar file:
1. Click here to Download

Monday, 20 February 2017

javax.inject,version=[0.0,1) -- Cannot be resolved

Sling Models is a way to create model objects which are automatically mapped from Sling objects, typically resources but also request objects.
This article explains how to use sling models in AEM. But, If you want to use Sling models with AEM 6.2, you might encounter some dependency issues.
Recently I faced a problem when my AEM project stopped working. The project was created using Maven archetype 10. It was working fine until I was on AEM 6.1. When I tried deploying it to AEM 6.2, the bundle was not coming to Active state. Later while debugging, I found out that it was not able to find a particular dependency. I was seeing something like below in the console.
javax.inject,version=[0.0,1) -- Cannot be resolved
Solved by adding this line in yourproject.core pom file
(with in the maven-bundle-plugin)

Here is the plugin after adding that line

    <!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->

Friday, 17 February 2017

Uncaught ReferenceError: CQ is not defined

To avoid this error add init.jsp or init.html in your code.
<sly data-sly-include="/libs/wcm/core/components/init/init.jsp" data-sly-unwrap/>