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. 

NOTE:
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)
<Import-Package>javax.inject;version=0.0.0,*</Import-Package>

Here is the plugin after adding that line


<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <extensions>true</extensions>
    <configuration>
    <instructions>
    <!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
    <Import-Package>javax.inject;version=0.0.0,*</Import-Package>
       <Sling-Model-Packages>
             com.yourproject.core
        </Sling-Model-Packages>
      <Export-Package>com.yourproject.core.*</Export-Package>
     </instructions>
     </configuration>
</plugin>

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,
/content/acme/en
/content/acme/en/about-us
/content/acme/en/news
/content/acme/en/products
/content/acme/en/contact
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/com.day.cq.wcm.webservicesupport.impl.ConfigurationManagerImpl. Well I could enable it then the tutorial would work, but those Adobe guys probably have good reason to disable it.