Saturday, 19 August 2017

Install NodeJs

What is NodeJS

  • Node.js is an open source server framework
  • Node.js is free
  • Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
  • Node.js uses JavaScript on the server

Click here to check Why Node.js

What is npm?

npm makes it easy for JavaScript developers to share and reuse code, and it makes it easy to update the code that you're sharing.
Click here to learn more on npm.

Install npm

Click here to download and install the npm on your machine.

Test if nodeJs is installed correctly, run below command.
npm -v
npm --version
npm version

Start npm run start, if you get below error 
npm ERR! path C:\Users\Kishore\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Kishore\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Kishore\AppData\Roaming\npm-cache\_logs\2017-08-19T14_53_13_265Z-debug.log

You can avoid above error by following below

  • running the npm command from bin folder
  • set environment variables (~\bin)

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.

Monday, 14 August 2017

Sling Resource API vs JCR API - Performance

Check the article to compare the performance when using Sling Resource API and JCR API.

This article illustrates different tests performed to compare the performance of sling resource api and jcr api.

Test 1: Traversing /content/geometrixx tree
Result: JCR API is roughly twice as fast as the Sling API when traversing a tree.

Test 2: Creating simple pages (single save)
When creating a 1000 simple pages and saving them in one go, it takes respectively 0.20 and 0.26 ms for the JCR and Sling API to create a single page. Creating 1000 pages took 200 and 260 ms respectively for JCR and Sling in total.

Saturday, 5 August 2017

Configuring Index Connector in Adobe Search & Promote

Why Index Connector?

Use Index Connector to define additional input sources for indexing XML pages or any kind of feed. Check how to integrate AEM with Search & Promote

You can use a data feed input source to access content that is stored in a form that is different from what is typically discovered on a website using one of the available crawl methods. However, a data feed either comes from an XML document or from a comma- or tab-delimited text file, and contains the content information to index.

Friday, 21 July 2017

Generic way to author text in AEM dialog

I am trying to author text in dialog, text contains dynamic values like name etc. I tried declaring sightly variable names in AEM dialog to fetch the data dynamically but it didn't work.

 I tried below approaches..

Approach 1:
  * Using String format
  String authoredText= "Hi %s, welcome to %s";
  authoredText = authoredText.format(authoredText,"Kishore","AEM Quickstart");"---Using String format----\n"+authoredText);

Approach 2:
  * Using StrSubstitutor - org.apache.commons.lang.text.StrSubstitutor
  Map valuesMap = new HashMap();
  valuesMap.put("name", "Kishore");
  valuesMap.put("blog", "AEM Quickstart");
  String templateString = "Hi ${name}, welcome to ${blog}.";
  StrSubstitutor sub = new StrSubstitutor(valuesMap);
  String resolvedString = sub.replace(templateString);"---Using StrSubstitutor----\n"+resolvedString);

Approach 3:
   * Using String replace
  String authoredText= "Hi ${name}, welcome to ${blog}";
  authoredText = authoredText.replace("${name}","Kishore");
  authoredText = authoredText.replace("${blog}","AEM Quickstart");"---Using String replace----\n"+authoredText);

From above approaches we can author the text in any of the format and parse it in java and we can get the text in HTL.


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.