Maven Dependencies Version Issue in AEM

In this post, I will explain package version issues for AEM package dependencies. Here is the scenario where I got this issue:

Issue Description

In one of my project, I had to create a tool for AEM that supports AEM5.6.1 and AEM6.x versions. For some dependencies, these AEM version instances (CQ5.6.1, AEM6.0, AEM6.1, and AEM6.2) needed to use different version of dependencies.

If I used an older version of these dependencies then my bundle did not work in AEM6.2 and remains in installed state. If I used the higher version of these dependencies then my code was not working for the older versions of AEM (CQ5.6.1, AEM6.0, AEM6.1).

Underlying Reason

Versions available for these package dependencies in OSGi container are not same as required by my bundle.
For example, lets take the case of cq-commons dependency.
AEM6.2 supports 5.9.22 version of cq-commons dependency.
AEM6.1 supports 5.8.32 version of cq-commons dependency.
AEM6.0 supports 5.7.12 version of cq-commons dependency.
AEM5.6.1 supports 5.6.4 version of cq-commons dependency.

Because of these different versions some of my java packages ( were not getting resolved.


Here are the list of steps, I followed, to resolve this issue.

Step 1

I have chosen the lowest version of available dependency i.e. 5.6.4 and added a dependency entry in the parent pom.xml file.

Step 2

I defined a property in <properties> section in my parent pom.xml file as mentioned below.
Note: – you can use whatever tag name you want but to make it readable I used this name.

Step 3

I have updated my <maven-bundle-plugin> as shown below-
Here I have used <DynamicImport-Package> tag. Now I have built my project for different AEM versions and it works fine for me in all AEM versions.

Here is the list of questions that may come in your mind:

Q1). What exactly <DynamicImport-Package> tag do?

It will add an entry in MANIFEST.MF file for the packages you mentioned in <bundle.dynamicImport.package> tag. MANIFEST.MF file entry is-

Q2). How bundle start working after using the <DynamicImport-Package> tag?

For answering this question-
First, we need to know about, How OSGi container works?
So, When you deploy your bundle into AEM OSGi container then first OSGi container checks that the available Java Packages versions are compatible with the versions of packages listed in Import-Package tag of your bundle MANIFEST.MF file. If version of Import-Package is not present then you will get an error as written below-

But if you defined these packages in <DynamicImport-Package> tag then OSGi container will not perform the versions checking for these packages and provides the available package definitions to your bundle at runtime.
i.e. using <DynamicImport-Package> is a kind of hack that short-circuits OSGi version checking process.

Note:- It is not recommended to use <DynamicImport-Package> with OSGi container.

Q3). Could we add multiple entries in <bundle.dynamicImport.package> tag?

Yes, you can add multiple packages using comma( “,”) delimiter. for ex.

Adobe Marketing Cloud


Marketing professionals have to speak the language of their customers. In order to reach them, they have to deliver right content through right channels to the right devices and provide a personalised experience. To achieve this, they need to quantify the facts with huge data.

Online presence must be consistent across devices channels and languages to ensure a personalised experience. They also need to efficiently manage and measure their social marketing activities and optimize their marketing expend on certain display.

So is there a solution that can address these challenges??

Fortunately, there is… The Adobe Marketing Cloud

Leveraging 8 solutions offered by Adobe marketing cloud, one can comfortably master this digital marketing solution.

Let’s elaborate these solutions one by one…

Experience Manager 

It’s quiet difficult to understand demands and to meet out the expectations of every single customer, they are expecting companies to provide the relevant content on all the devices they have been using and they are actually switching from one of these digital devices to another. So they may be shopping on website, looking on things on mobile app and when they go into store they want all of that digital experiences to connect together.

So it’s important for brands to think about how to deliver that consistent continuous experience across all these devices.

Marketers has to manage several websites that’s quite a challenge because website should be adaptive to multiple devices and languages.

The content is inconsistent because assets aren’t organised. Also it is difficult to properly optimise websites all tie in social media which makes content less relevant to customer’s web experience.

That’s where Adobe experience Manager comes in.

Adobe experience manager helps marketer get everything under control. The Adobe solution provides a web content management system featuring a multilingual what you see is what you get mode, so it becomes very easy to manage all the website apps and digital publications.

 AEM has 5 components to it

  1. Sites
  2. Assets
  3. Apps
  4. Forms
  5. Communities

 Each of these are critical to brand journey and building out a comprehensive digital strategy.


People visiting your site have different intentions, some are there to buy stuff, others simply doing research, and some might be trying to get a job with you. Then you got your first time visitors, and returning ones. Some don’t know why they’re there and are looking for a way out.

Despite of this, most websites and landing pages display exactly the same content for all visitors – no matter what they’re searching for or how they got there in the first place. These websites try to appeal to a wide range of visitors simultaneously, and thus are not exciting many.

Wouldn’t it be awesome to display different content and call-to-actions for different types of visitors? Essentially making your visitors feel like that the page speaks their language?
Well there is a grounded leading solution named as ADOBE ANALYTICS 

that provides digital marketers with one place to measure, analyze, and optimize integrated data from all online initiatives across multiple marketing channels. 

It provides marketers with actionable, real-time web analytics intelligence about digital strategies and marketing initiatives.

It works by looking at the data which is provided by analytics about the visitor – things like location, keywords they searched for, ads they clicked in, whether they’ve been to the site before and also things like buying history – and compares that against a set of variables that you have put in place. It lets you target relevant content to different types or groups of visitors based on their behavior or other variables.

Those variables could include:

  • Location – city, country, region
  • Device – iPhone, iPad, Android phone/tablet, Windows, Mac, Linux
  • Search keywords 
  • Visitor frequency – First, second, third, fifth time visitor?
  • Date and time of day, proximity to payday
  • Referring URL – where did they come from?
  • Customer history – have bought before, what, how much did it cost?
  • Sessions behaviour – navigation clicks, page views

There are many more variables which can be taken into account like age, gender etc. – possibilities are pretty much endless and it depends a lot on how much info you have about that customer already.


In this competitive era of digital marketing, every visitor on the website can never be a customer. Every marketing professional wants to communicate well with their visitors by extracting their needs and personalised interest. Every customer expects a unique experience and personalised offers rather than a one side communication by a website. In order to fulfil those expectations, a marketer requires an effective plan to get an optimum amount of marketing expenditure so as to avail a limited number of offers on stuff

Adobe target analyses customer wishes and demands by the data provided by adobe analytics helps to deliver relevant content and tightly integrates with adobe social for enhanced social marketing. Now one can deliver right products to the right targeted customers. This kind of automated behavioural targeting imparts an exponential growth in number of customers

Also it helps to dynamically create content based on the visitor’s profile and to suggest targeted recommendations to the user even before he finishes typing their search queries. External data sources like order history can also be integrated to analyse visitors profile which further helps in optimised merchandising and discount on the targeted stuff. This dynamic navigation guarantees a perfect on site experience 


It is very important to reach out your customers in meaning full ways.

With Adobe campaign you are able to integrate and deliver one to one campaign so all the customers get relevant and consistence experience across online and offline channels.

We come to understand each customer through integrated profile which is made up of the purchasing history social interaction, where they are from and other information gathered by analytics pull into adobe campaign

Adobe campaign use this analytics data to create personalised campaigns according to the customers interest.

Reports in adobe campaign show you how things are going, you can see who is responding to your offers, how much revenue your campaigns is generating.

With adobe campaign you have a deep real time understanding of your customers so you can design, integrate and automate cross channel experiences and measure the success. All for one solution


Social media manager are responsible for increasing brand reach and audience engagement through social and creating a consistent brand experience across channels and devices

They must also ensure the right message gets through all the noise of social traffic to the right customers and you need to respond to customer issues that arise via social platforms. And you need to connect all these social efforts to measurable business results

How one possibly monitor manage and measure so many social media channels and also quantify the business value of social marketing.

Easy. All we need is Adobe Social

Adobe social enables marketers to scale social across the organisation; create and deliver relevant, engaging content across all social properties; capture and analyse all key sources of meaningful social data alongside integrated conversion metrics; leverage data to demonstrate social value and optimise interactions; and manage and strengthen customer relationships across social channels – All from one integrated platform

Audience Manager

What problem are we trying to solve with Audience Manager?

Marketers had multiple database and technologies that they use to solve personalisation across each channels.

There are lot of technologies, customers can be on web, mobile, email or social. The challenge here is database is touching into multiple channels. Marketer here really dint have a coherent or a relevant conversation as a consumer moves across multiple touchpoint. And this is the reason for disjoint experience. 

And this something which can be address by DMP

A data management platform or Audience Manager consolidate audience information from all available sources. It identifies, quantified and optimises high value target audiences which can then be offered to advertisers via an integrated, secure, privacy-friendly management system that works across all advertising distribution platforms

 DMP consist 4 key part

  1. Collect data – Collect data and allows that to sit in single repository.
  2. Unify Data to a profile – DMP can take this data from the different sources and unify that data back to a profile
  3. Create Audiences – In DMP, you can take the various profile information that you have to create audiences and audience segments.
  4. Push to Marketing platforms: Value you creating this segments is the capability to reach the people who follow the segments
Adobe Media Optimiser

Once building a great website is done, it is time think about MONEY

Marketers really need to get a larger return on their ad spend to engage more relevant audiences derive brand awareness and generate revenue.

But how one should distribute their media budget between display, search and social

What is the most profitable way to run across channel advertising campaign.

Advertisers are trying to simplify their lives, they are trying to have more control to right campaigns and their budgets and trying to be more efficient with their ad buys.

With Adobe Media optimiser we can answer all these questions easily and get maximum return on our investments.

Using mathematical models and industry leading algorithm adobe media optimiser preciously evaluates the situation which enables us to adjust our strategies, goals and budget in real time

It also provides precise forecast based on our goals and predicts the best channels mix for his budget

With adobe optimiser marketers can manages all of his campaigns for every platform.

Search engine like google & Bing. Social platforms like Facebook and Twitter

So Marketers can always rely on peak conversions and the right investments

The right messages to right people at the right time

so finally not only traffic on website will increase but the revenue will also grow profitably


The way people watch TV and video has evolved. 

You need to personalize it.

Users want to jump in and only experience they want to be fully immersed. This means making it easy for each viewer to have the TV shows and sports and films they want, streaming securely and high definition across different screen wherever and whenever

Adobe primetime part of adobe marketing cloud helps delivering helps delivering engaging experiences for viewers and subscribers and more revenue from advertising and subscription

Now its possible to create engaging experiences on every device using primetime 

Primetime allows you to deliver the right ads to right audience to improve the effectiveness of your ad sells


We all know key to mastering customer experience is knowing the customer and for this Adobe Marketing cloud is perfect fit. My vote goes for Adobe Marketing cloud.

What about you????

Credits: Adobe Sites 

Sling Models with Sightly Part – IV (Key Annotations – II)

In this post, I will explain some important questions related to OSGi Services and Sling Models. These questions had been asked by some of my blog readers on the basis of my last blog.

So the Problem Statement is-

According to them, They have one interface with multiple service implementations and want to choose any one of these service implementations according to their need. So their questions were-

1. How to choose the desired service implementation from these service implementations in another services or servlets?
2. How to choose the desired service implementation from these service implementations in Sling Model Class?

I have created a demo implementation according to their requirement and for doing that I have created an interface named as TestService with a dummy method named as test(). Here is the code-

Now, I have created two dummy service implementations of this interface. Here is the code for the first implementation named as TestServiceFirstImpl.

Here is the code for my second implementation named as TestServiceSecondImpl.

Answer for the first question-
It is a two-step process. These steps are explained below-

Step 1
Add a new property that have a unique value for each and every service implementation. This property could be anything you want to add. For example, I am using service.label property for these services and on the basis of this property I will choose from these implementations.

Here are my new definitions for TestServiceFirstImpl class.

Code For TestServiceSecondImpl class.

Step:- 2

Use @Reference annotation in another servlet or in OSGi Service with an extra attribute named as “target”. Just redefine this line as shown below-

Try to run your code, you will get the desired output.

Q2. How to choose these services in Sling Model class?

In Sling Model class you can call an external service using two annotations. These are-
1. @OSGiService
2. @Inject with @Source annotation

If you are using @OSGiService annotation then you have an attribute “filter”, here add your condition and you will get the desired implementation as shown below-

If you are using @Inject with @Source annotation then you need to add one more annotation @Filter. Here is the new code-

Now here my complete working code that will show you the use of both of these two approaches.

Q3. How am I testing these annotations in Sling Model class?

I have created a dummy component and that component calls these Sling Model classes. Sightly code snippet is-

For complete working code, I am sharing the Git repository link.

Happy Coding..!!

Ankur Chauhan
Tech Lead

Magical Marketing Mechanism


You are munching your most loved hot hot crispy samosa, while checking your emails on mobile, you receive an email from your favorite e-commerce site and you spot your chosen “jeans” which you have been looking for some time now, is available at a steep discount. You were following that “jeans” on web and social for quite some time and always wished you get some discount on it. You had seen ads of it in your social networking and media sites and were always thought of buying it. You had in fact added it into your shopping cart but always felt it to be expensive.

You click the link in the email and see some nice photos of it and also some more suggestions based on your interest and find more attractive options.

You call you friend and tell the same but your friend has not received any such email or see any reduction in price or discounts on the site.

You are provoked more to buy it immediately as you do not want to lose the opportunity and don’t want to risk the out of stock scenario.

You go ahead get you credit card and buy it immediately. WOW, that’s the feeling you get and you are excited about your purchase for the next party you are going to have over the weekend. You feel thankful to the e-commerce site to give, only you the discounted price and feel great about your quick decision to purchase. You quickly share and tweet about your purchase and your friends are liking it.


  • How your favorite e-commerce site knew you were looking for “jeans” from quite some time now?
  • How could only you could get the email and the discounts?
  • How could you see more suggestions and options which you had tried searching but could not get?
Adobe Marketing Cloud is one such solutions which is the answer for above questions.

Lets suppose, e-commerce site was using the Adobe Marketing Cloud to achieve this. Here is how they must have used different tools available in the suite.

Adobe Audience Manager consolidate audience information from all available sources and create profiles of audience segment to send email only to you.

 Adobe Campaign used analysis done by Adobe Social and Audience Manager to send you a personalized email. Adobe  Target and Personalization provided you with more suggestions and compelling offers and options. 

You shared your purchase through social sites and the e-commerce site could do more promotions based on the links and shares and could get more people know about the purchase and could listen to the social activity using Adobe Social.

Nice looking website and all the graphics, content along with the personalized options were hosted on Adobe Experience Manager.

Adobe Media Optimizer helps e-commerce site to get maximum return on their investments.

e-commerce site benefited by acquiring the customer by providing a good experience and it can go a long way retaining the customer.

It helped converting a potential user to a customer and sold the product and also received a good follow on social networking sites, which can only lead to more users getting converted to loyal customers.

It is very important to not just reach customers but also need to know them and Adobe Marketing Cloud solutions helps in the same.

Adobe Marketing Cloud is a comprehensive marketing solution which enables marketers to measure, personalize and optimize marketing campaigns and digital experiences for optimal marketing performance. Adobe Marketing Cloud includes a set of analytics, social, advertising, media optimization, targeting, Web experience management and content management aimed at digital marketing.

 It is the most comprehensive & integrated marketing solution for digital marketers.

 Adobe Marketing Cloud Solution consists of –

  1. Adobe Analytics
  2. Adobe Audience Manger
  3. Adobe Campaign
  4. Adobe Experience Manger
  5. Adobe Media Optimiser
  6. Adobe Primetime
  7. Adobe Social
  8. Adobe Target

 We will explore each product in detail in upcoming blogs.

Custom Xtype For Pathfield BrowseDialog

Sometimes the xtypes provided by AEM doesn’t fulfill our requirements. So we need to design our custom xtypes on regular basis.


While working with xtype pathfield, I stumbled upon a use case/problem. I wanted a pathfield so that  I can choose the product under /etc/commerce/products/accunity/en_us/products hierarchy by a productName property.

Note: Generally, pathfield can show the nodes by its name or jcr:title.

Steps I followed:

  1. I created a widget of xtype:pathfield
  2. If I opened my  dialog, I could select any values under /content.
  3. So needed to set rootPath in the widget.
  4. The nodes under products are of type nt:unstructured. By default, pathfield doesn’t allow this types of nodes in the tree hierarchy.
  5. So added a property predicate: nosystem

Now the pathfield looked like this:

But still, it is a very tedious task for the author to select a particular product. I wanted pathfield to show the productName in place of node-name. So I decided to write custom xtype.

But how?

The first question here is how this tree structure shows up here:

So while debugging my dialog, I found, it calls currentPath.ext.json and shows the “name”property of  JSON in the tree hierarchy. 

So next step for me was to change this servlet.

The Next Question was from where this servlet is getting called.

The answer is browserDialog widget. Inside pathfield widget, it is calling browserDialog to show this tree structure.

Note: Go to browseDialog.js

Change this part:

Here is the updated browseDialog.js

We can’t make this change in the /libs section. So, I made my own xtype as productPathfield and add a custom browseDialog in pathfield.js with this modification.

Note: xtype pathfield doesn’t fulfill my requirements so needed to change it with productPathfield.

After all the changes, we can see our desired results here:

Please leave your precious comments of what you think about this approach. Happy to learn better solution for the same problem.

Sling Models with Sightly Part – V (Key Annotations – III)

In this post, I will answer some of the queries asked by my blog readers. This blog will also help you in getting knowledge of How you access cq:defined Object in Sling Model classes?
Before answering these question, I want to make sure that you guys are using latest Sling Model dependency and AEM version 6.x. So let’s start-

Q1. How will I get properties object in Sling Model Class?

I think there is no need to get this properties object as you can directly inject the resource properties ( already described in my previous blog) but if you still want to do that then, you have to make two changes.

First use adaptable as SlingHttpServletRequest.class as shown below-

Then you can directly inject properties as shown below-

Q2. During the build time, I am getting a Maven build error as shown below-

How to resolve this issue?

For resolving this issue,  you need to add one more maven dependency into your project the dependency name is
cqcommens and it’s Maven dependency is-

Q3. How will I get inherited page properties object in Sling Model class?

For getting this object in your Sling Model class, you need to inject a field as shown below-

With SlingHttpServletRequest.class as an adaptable value.

Q4. Can I use Resouce.class as well as slingHttpServletRequest.class as adaptable in the same class?

Yes, you can do that. Here is the syntax-

Q5. How will I get page object in Sling Model class?

For getting this object in your Sling Model class, you need to inject a field as shown below-

With SlingHttpServletRequest.class as an adaptable value.

Q6. Do you have any working Sling model class example that implements all these properties?

Yes, here it is-

Q7. How am I testing these annotations in Sling Model class?

I have created a dummy component and that component calls these Sling Model classes. Sightly code snippet is-

Happy Coding..!!

Ankur Chauhan
Tech Lead

Sling Models with Sightly Part – III (Key Annotations – I)

The title of this blog is “Key Annotations – I” because In this post, I will explain two important annotations related to Sling Models and continue explaining other annotations in my coming posts. So for explaining two annotations, I have selected following two questions for this post.

1). How to include OSGI Services in Sling Model?
2). What is the use of @ResoucePath annotation?

I am assuming that you are using the latest versions of Sling Model APIs that I described in my previous blog.
For Answering first question, I have created an OSGi Service that have a dummy method as follows-

Now, You can include OSGi Services in your Sling Models using two annotations, these are-

1. @OSGiService Annotations
2. @Inject Annotation

Here is the Sling Model class, that shows how to use these annotations?

When you call this Model class then you will see that both of these two annotations working in the same manner.

Q1. What is the use of @ResoucePath annotations?

@ResoucePath annotation is a very handy annotation provide by Sling and using this annotation, you can convert a path into its resource object without writing any code. Let’s suppose you have a predefined path (e.g. /content/geometrixx/en) of the resource and want to convert that path into resource object then you can use @ResourcePath annotation.

Q2. How to use @ResoucePath annotation?

Here the code snippet that shows you the use of this annotation-

Q3. How am I testing these annotations?

I have created a dummy component and that component calls these Sling Model classes. Sightly code snippet is-

For complete working code, I am sharing the Git repository link.

Happy Coding..!!

Ankur Chauhan
Tech Lead

Sling Models with Sightly Part – II ( Key Points )

In this post, I will explain some key points, which need to be kept in mind while working with AEM, Sightly, and Sling Models.

Q1). Issues with Sling Models with Sightly while using AEM6.0 instance?

If you are using AEM6.0 then it provides bundle with version 1.0.0 with very limited functionalities. e.g. You can inject some properties which exist on the resource and also you can use some basic annotations. See snippet example below:

But if you want to inject ResourceResolver or Resource object as shown below –


then this code will not run. Because Injectors for these kinds of Objects are not supported in Sling Model API version 1.0.0. In this case, you will get a warning that “not able to inject these properties” or you will get a null or NullPointerException.

Another point is “@Self” annotation will not work in AEM6.0. as its injector is also not available in Sling Model API version 1.0.0.

Q2). How to resolve this issue?

For resolving this issue just go to the maven repository and download the latest bundles for and bundles.
Latest versions for these dependencies were 1.2.2 at the time of writing this blog.

Note :-  Both of these dependencies are mandatory.

Now you can install these bundles in two different ways.

1). Directly install these bundles using /system/console/bundles tab.

2). Place these bundles under /apps/<project>/install folder in your maven project so that whenever you build your project these bundles are automatically installed in your AEM instance.

Q3). Do I need these packages in AEM6.1?

AEM6.1 provides 1.1.0 version for these APIs, that support all annotations, but it’s always good to go with the latest APIs version. So I think you should keep these latest versions in your project for AEM6.1 instance. If you keep these JAR files in your project, you wont need to worry about the issue, that your code will run or not in any of the AEM6.x instances.

Q4). You are talking about AEM6.x versions, what about the older versions of CQ?

I am talking about these two versions because Sightly is only supported from AEM6.0 version but If you are working with CQ5.x version and want to use Sling Modes in your JSP files then you can follow the same steps by placing these API bundles into your maven project install directory and your code will work perfectly fine.

Q5). Where to find all Injectors information supported by any AEM instance?

You can check this information at-

I am also sharing the Git repository link.
Git repository link is –

Happy Coding..!!

Ankur Chauhan
Tech Lead

Sling Model with Sightly Part – I

In this post, I will explain, how to use sling models with Sightly in AEM6.x?

For doing this, I have created a project using maven archetype for AEM6. If you want to use any existing project, then you need to check two things-

1. Dependency for Sling models in your project’s pom.xml file. You can find this maven dependency in you AEM instance package finder tab as shown in fig-


Now search for this dependency in your Maven project parent pom.xml file. If it’s already there then it’s fine else add this dependency into your project.

2. In whatever java packages, you want to add your Sling Model classes, add these java packages information into your maven-bundle-plugin.
For example, I am using two java package for adding my Sling Model classes, these packages are-
sling.models and, so I have to place these package information into my maven-bundle-plugin, as shown below-

Q1). What will happen, If I don’t add these entries?

If you don’t add these entries, then maven will not add
“Sling-Model-Packages: sling.models,”
header entry in your bundle Manifest file. So that these classes will not behave as sling models and will work as simple java classes and, If you try to run your code without this entry, then you will not get desired output as well as there will be no error message in error.log file.

In this post, I will create a very basic example where I will get a name from the component dialog and print that value using Sling Model. So Let’s start-

Create a Sling model class.

Here I am using @Inject annotation on “firstName” property, it means that this property will be looked up from the resource (after first adapting it to a ValueMap) and it is injected.
@PostConstructor annotation defines that this method will run after injecting all field (having @Inject annotation) from the resource.

Create the component as shown below-

In slingModel.html file add these lines.

My dialog properties are as shown below: –

Dialogue Properties



Build your maven project and drop this component on your page. You will see a screen as-

Open the dialog of this component and add any entry (For example “Ankur Chauhan”) you will see the desired output as-

Q2). Why are we creating Sling Model class for this example even we can directly use ${properties.firstName} in our slingModel.html file?

You are right, We can do that or you can say, we must do that. But as I already mention that, in this post I am going to show you a very basic use of Sling Model. So I think this is the simplest example for this post. You will see must better examples in my coming blogs.

I am also sharing the Git repository link.
Git repository link is –

Happy Coding..!!

Ankur Chauhan
Tech Lead

Understanding Sling Models in AEM

Learn about Sling Models from the Digital Experience Experts