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/>

Sidekick is not loading in AEM

We can hide/disable sidekick in author mode in page component by removing/commenting or by not including "/libs/wcm/core/components/init/init.jsp" in any of the jsps of the page or its super/parent resource.

In Sightly we can use below code
<sly data-sly-include="/libs/wcm/core/components/init/init.jsp" data-sly-unwrap/>

Creating a site footer in AEM 6 using Sightly and Sling Models

The Adobe-developed and recently-donated-to-Apache-Sling project Sightly project has been out for a little under a year now, alongside Adobe Experience Manager 6, and has slowly been amassing documentation and gaining presence. The server-side templating language aims to give a facelift to the web development facet of Java-based software stacks, Adobe's AEM chief among them.
This post will run the reader through a sample implementation of a site footer using Sightly, showcasing and describing a few of its features. It will also make use of Sling Models as the back-end tool to grab JCR data (nodes, properties) into useful class models.
What we want is an authorable footer serving all pages of a language branch of a content tree. Let's assume that our site is for Acme, the reputable maker of all things widgets, gadgets, and sprockets. Our site structure will be traditional and look like,
and so on. Let's assume that the en page serves as the homepage for the English site, and similarly, the /content/acme/fr will serve as the French homepage, with all French content pages under it. As such, each homepage will need to have an instance of footer data.

How to add AEM Dependency that is missing from public repository

So you just updated to the nice and shiny AEM 6.1, looking at new functionality and exploring around. Then you decide to tap into the new api documentation. Then reality comes back in, the boss wants to connect a new product into AEM 6.1. Too easy! I'll use a custom cloud configuration. Google to the rescue... Adobe documentation here I come. Oh no! The documentation is a CRXDE Lite tutorial.
Following the tutorial and testing it out, the screen explodes into a torrent of letters and characters...stack trace! Who would of thought...
Turns out ConfigurationManager is turned off by default for security reasons http://localhost:4502/system/console/configMgr/ Well I could enable it then the tutorial would work, but those Adobe guys probably have good reason to disable it.

Decompile AEM: How to get a jar from AEM

AEM development is sometimes difficult to get started due to limited documentation. By having some code examples or a clearer understanding of what is under the hood, this could be the difference from good code to great code. Having the ability to decompile a jar can be very helpful in the development process. Decompiling the jar is the easy part. Finding and getting the jar in AEM can be more difficult. There are two ways that this can be accomplished in AEM, with Vault or without Vault.
Check it out!

With Vault (vlt)

  1. Search for webservice, click Day Communique 5 WCM Webservice Support
  2. Notice Bundle Location copy the path after jcrinstall: (If you don't see jcrinstall, go to without vlt section)
  3. Open CRXDE Lite and add the copied path. You should see the name of the jar inside that path
  4. Now that the location is confirmed. Go to terminal and vlt down the jar. In my case this is what I used:

AEM 6.1 - Filter RequestDispatcher Forward breaks i18n

I just noticed that on AEM 6, in my Filter, when I call RequestDispatcher forward, i.e. request.getRequestDispatcher(...).forward(req, res);, it cause i18n to break. Here's a snippet of my codes:
boolean filtered = false;

SlingHttpServletRequest request = req instanceof SlingHttpServletRequest ? (SlingHttpServletRequest) req : null;
SlingHttpServletResponse response = res instanceof SlingHttpServletResponse ? (SlingHttpServletResponse) res : null;
if (request != null && response != null) {
    // block of codes to resolve the request uri and get the new desired URI 
    if (this.resolvedUriResource != null) {
        String uri = this.resolvedUriResource.getPath() + ".html";
        RequestDispatcherOptions options = new RequestDispatcherOptions();
        this.filterConfig.getServletContext().getRequestDispatcher(uri).forward(req, res); // OR
        //request.getRequestDispatcher(this.resolvedUriResource, options).forward(req, res);
        filtered = true;

if (!filtered) {
    chain.doFilter(req, res);
The exact same codes was working on AEM6.0 and AEM 5.6.x.
Download this package to try out and see the issue:

Adding to the Create Page Wizard in Touch UI

In this blog post, I will describe how you can add a new property to the Page dialog and make it available in the Create Page wizard and Touch UI Dialog in AEM 6.1. It is common to add new properties to dialogs whenever you need to give authors additional options for configuring components or pages. Whenever you need to add a new property into the Page dialog, it typically will not be required by authors at the time of Page creation. For those rare cases when you need some detail specified about a page upon page creation, you will need to add properties into the Create Page wizard. Below is what the out-of-the-box Create Page wizard looks like.

Using Grunt in an AEM Maven build

This post is a guide on how to establish a functional Maven build for AEM that includes Bower front-end dependency management and Grunt task management. The Grunt build will download Bower dependencies, move them to a client library, then create their respective .content.xml, css.txt, and js.txt to be used at the AEM component level.
Prerequisites for this post:
  • AEM instance (requires Java SDK)
  • Maven (Link)
  • NodeJS w/ npm (Link)
  • Grunt (Link)
  • Bower (Link)
  • Optional reference file packet (Link)
After installing above dependencies, set up a mvn project using the below code in a terminal or command prompt: mvn archetype:generate -DarchetypeRepository= -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=my-group-id -DartifactId=gruntproject -Dversion=1.0-SNAPSHOT -Dpackage=com.grunt.gruntproject -DappsFolderName=gruntproject -DartifactName="Grunt Project" -DcqVersion="5.6.1" -DpackageGroup="Grunt"

Logging in Operations Dashboard in AEM 6.X

This post will discuss logging via the Operations Dashboard in AEM 6.0 and beyond, and will also include a short tutorial to set it up for quick troubleshooting for developers and system operators alike.

UI tests using Hobbes.js in AEM

This blog will discuss the usage of the Hobbes.js testing library available in AEM 6.0 and above, to run UI tests from within the browser. This framework technically relies on clientlibs, and the dependencies and categories settings of the clientlibs differentiates them from regular clientlibs.
The 4 quick setup steps:
  1. Create a Client Library Folder in the desired location, say, in a component as apps/myProject/components/myComponent/tests.
  2. Create Test Suite(s), which are just a collection of similar Test Cases. There can be more than one Test Suite in the Client Library Folder.
  3. Specify Test Cases for each Test Suite.
  4. Add Actions in each Test Case that will validate (or invalidate) the Test Case.
Once the tests are written, all one needs to do is go to the Developer mode of the Touch UI to execute them.

AEM DTM Integration

The purpose of this blog is to go over AEM DTM Integration process step by step, using the recommended configuration options. There is documentation available for integration by Adobe here. Although, for someone who is integrating AEM DTM for the first time or with limited knowledge of one or the other, it is quite overwhelming to be exposed to the technicalities of all the available options at once. This post will also elaborate and expand on embedding DTM code on various experiences built within a single AEM instance. I hope this blog helps in simplifying the process for you.
Assuming you have an author instance of AEM running, there are the three majors steps you need to perform to add the DTM code on your site via the cloud-hosted services integration:
  1. Create web property in DTM
  2. Configure AEM DTM Integration
  3. Embed DTM code in a specific AEM site

Sightly/HTL Javascript Use Class Logging

Sightly Log Filter

This tool makes it easier to filter out log messages in the error.log for just messages generated by your Javascript Sightly Use Classes.


You can use the file standalone in the logs directory by performing a chmod +x on the file, then running the file as so:
./ myUseClass.js
Optionally you could alias this and just call the command.
This tool is covered by the LICENSE file at the root of this repository.
The readme and use of the helper bash script should be sufficient to get you up and running in no time. The installation is very straightforward, just drop the script into the log directory of your AEM instance, chmod to allow execution, and then start viewing your JS Use class logs! An alternative approach is to alias it, then use it as a standalone command.

Friday, 10 February 2017

Create maintenance page in Apache Dispatcher

Creating Maintenance Page

  • Create a maintenance page say maintenance.html under document root (C:\Apache2\htdocs)
  • Create an empty file, named “maintenance.enable”, inside the site's document root (C:\Apache2\htdocs)
  • Redirect to Maintenance Page Using HTAccess create .htaccess file under C:\Apache2\htdocs
  • Copy below code in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{DOCUMENT_ROOT}/maintenance.enable -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /maintenance.html [R=503,L]
ErrorDocument 503 /maintenance.html
Header Set Cache-Control "max-age=0, no-store"
  • To disable the maintenance delete “maintenance.enable” file or rename it.

Troubleshooting Dispatcher

  • In httpd.conf,
                a)Under <Directory "/Apache2/htdocs"> update below code
                                #AllowOverride None
                    AllowOverride All
                                #Order allow,deny
                                #Allow from all
                                <IfVersion < 2.4>
                                                Allow from all
                                <IfVersion >= 2.4>
                                                Require all granted
                b) Under <Directory />

                                comment to avoid forbidden error => Deny from all