Article Summary


Discusses how setup and debug an AEM project by using IntelliJ. 

For information about using Eclipse instead of IntelliJ, see Creating an AEM project using Eclipse IDE

Digital Marketing Solution(s) Adobe Experience Manager (Adobe CQ)
Developer (intermediate)
Required Skills
Java, Maven
Version Adobe Experience Manager 6.x
Video Click Here


You can create an AEM application by using the Java IntelliJ Integrated Development Environment (IDE). By building an AEM application using the IntelliJ IDE, you can access features within the IDE such as code completion and the ability to remote debug the application. That is, you can set a breakpoint on a line of Java code used for an OSGi bundle and you can walk through the code to troubleshoot issues. 

You can synchronize code (both Java code and JSP code) in the IntelliJ environment with the code in the AEM JCR. For example, assume that you have application logic in IntelliJ that represents a JSP component. You can synchronize the code in the IntelliJ IDE with code in the AEM JCR using the vault tool. That is, you can check in code you write in IntelliJ into the AEM JCR. Likewise, if you make a change in AEM using CRXDE lite, you can checkout the code that results in the code in IntelliJ being updated. To synchronize code, you configure the vault tool (this is shown later in this development article).

The following illustration shows application logic for an AEM application within the IntelliJ IDE.   


This article walks you through how to build an AEM application using IntelliJ and synchronize the code with the code in the AEM JCR. In addition, it discusses how to setup AEM for remote debugging and starting an AEM application from IntelliJ. 


To follow along with this article, download IntelliJ IDEA from the Downloads page at JetBrains.

Setup Maven in your development environment

You can use Maven to build an OSGi bundle that uses the JCR API and is deployed to Experience Manager. Maven manages required JAR files that a Java project needs in its class path. Instead of searching the Internet trying to find and download third-party JAR files to include in your project’s class path, Maven manages these dependencies for you.

You can download Maven 3 from the following URL:

After you download and extract Maven, create an environment variable named M3_HOME. Assign the Maven install location to this environment variable. For example:


Set up a system environment variable to reference Maven. To test whether you properly setup Maven, enter the following Maven command into a command prompt:

%M3_HOME%\bin\mvn -version

This command provides Maven and Java install details and resembles the following message:

OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"

Note: For more information about setting up Maven and the Home variable, see: Maven in 5 Minutes.

Next, copy the Maven configuration file named settings.xml from [install location]\apache-maven-3.0.4\conf\ to your user profile. For example, C:\Users\scottm\.m2\.

You have to configure your settings.xml file to use Adobe’s public repository. For information, see Adobe Public Maven Repository at

The following XML code represents a settings.xml file that you can use.

<?xml version="1.0" encoding="UTF-8"?>
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
 | This is the configuration file for Maven. It can be specified at two levels:
 |  1. User Level. This settings.xml file provides configuration for a single user, 
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |                 NOTE: This location can be overridden with the CLI option:
 |                 -s /path/to/user/settings.xml
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in 
 |                 ${maven.home}/conf/settings.xml.
 |                 NOTE: This location can be overridden with the CLI option:
 |                 -gs /path/to/global/settings.xml
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
<settings xmlns=""
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   | Default: ~/.m2/repository
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   | Default: true
  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   | Default: false
  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are 
     |       used together.
    <!-- Another sample, using keys to authenticate.
      <passphrase>optional; leave empty if not used.</passphrase>
  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred 
   | server for that repository.
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
      <name>Human Readable Name for this Mirror.</name>
  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is 
   | dereferenced during the build process to configure the cactus plugin.
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a 
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
          <name>Repository for JDK 1.4 builds</name>
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
                    <name>Nexus Proxy Repository</name>
                    <name>Nexus Proxy Repository</name>
  <!-- activeProfiles
   | List of profiles that are active for all builds.

Create an Experience Manager archetype project 

You can create an Experience Manager archetype project by using the Maven archetype plugin. In this example, assume that the working directory is C:\AdobeCQ.  


To create an AEM project, open the command prompt and change to a working directory. For example, C:\AdobeCQ. Next, enter the following Maven command:

mvn archetype:generate -DarchetypeRepository= -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DartifactId=echoproject -Dversion=1.0-SNAPSHOT -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="5.6.1" -DpackageGroup="My Company"

Click Y when prompted to do so in the command prompt. This will create a Maven project named echoproject. You should see the following message in the command prompt. 


Modify the Java files

Modify these Java files that were created by Maven:

  • echoproject\bundle\src\main\java\com\aem\community\
  • echoproject\bundle\src\main\java\com\aem\community\impl\

In the file, add the following method signature:

public String echo(String msg);

Likewise, in the, add the following method body:

public String echo(String msg){
 return "AEM says " +msg ;


The AEM application invokes the echo method later in this development article. 

Deploy the bundle to AEM

Next, from within the command prompt, change the directory to the echoproject root. For example, C:\AdobeCQ\echoproject. Once deployed, the AEM service is automatically placed into an Active state. Enter the following Maven command:

mvn -PautoInstallPackage install

You can see the bundle running in an active state by going to the following URL: http://localhost:4502/system/console/services.


For information about the project files that Maven created, see

Prepare for JSP support in IntelliJ IDE 

Modify the POM file located at C:\AdobeCQ\echoproject\content to add support for JSP compilation in IntelliJ. The Maven setup described so far creates a content package that can also include components and their corresponding JSPs. However, Maven treats them as any other file that is part of the content package and does not even recognize them as JSPs.

The resulting components work in AEM all the same, but making Maven aware of the JSPs has two major benefits:

  • It allows Maven to fail if the JSPs contain errors, so that these are surfaced at build time and not when they are first compiled in AEM
  • For IDEs that can import Maven projects, this also enables code completion and tag library support in the JSPs

Add the follownig dependencies to this POM file. 

    <!-- javax.jcr -->
    <!-- -->
    <!-- -->
    <!-- -->
    <!-- javax.servlet.jsp.jstl.core -->
    <!-- -->
    <!-- -->
    <!-- com.adobe.granite.xss -->
    <!-- -->
    <!-- org.apache.commons.lang3 -->

In addition, add the following plugin elements to the POM file in the content folder.


Import the Maven project into IntelliJ

Import the Maven generated project into the IntelliJ IDE by performing these steps:

1. Start IntelliJ. 

2. From the IntelliJ Qucik Start menu, select import project. 

3. Browse to the POM file located at C:\AdobeCQ\echoproject, as shown in the following illustration.



4. Continue with the default settings and click Finish. 

The following illustration shows the echoproject that you created using Maven imported into IntelliJ IDE.


To successfully import content from the AEM JCR under apps/echoproject, you have to modify the echoproject\content\src\main\content\META-INF\vault\filter.xml file. Add the following lines of bolded XML code:

<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
<filter root="/apps/echoproject"/>
<filter root="/libs/foundation"/>


At this point, you have the echoproject in both IntelliJ and in AEM JCR (it was placed into AEM when you executed the following maven command: mvn -PautoInstallPackage install).

The following illustration shows the echoproject in AEM. Notice the the new project at /apps/echoproject.



Now you have the same project located in both IntelliJ and AEM JCR. The next task to perform is to synchronize the code by using the vault tool. 

Setup the vault tool

The next task to perform is to setup the vault tool so Intellij can use it to synchronize between AEM JCR and IntelliJ. For example, later in this development article, a template and page component is created using CRXDE lite. You can synchronize the code using the vault tool from Intellij, which is shown later. 


Install the filevault tool in your development environment. For details, see How to use the VLT Tool.

Once you setup the filevault tool, you can configure IntelliJ to use it. If you have the auth.xml in the user's vault folder (for example, C:\Users\<user>\.vault\auth.xml ), then you do not need --credentials admin:admin with each vlt command. These values are present in the xml file. 

<?xml version="1.0" encoding="UTF-8"?>
<auth version="1.0">
<repository uri="http://localhost:4502/crx/server/null">
<credentials type="simple">
<user name="admin" password="admin"/>

For example, without auth.xml the command parameters for vlt check out are going to be update --force --credentials admin:admin and not update --force.

To setup the vault tool in IntelliJ, perform these steps:

1. From within IntelliJ, click File, Settings.

2. Select External tools and click the + icon. 

3. Enter the following information:

  • Name: vlt full check out
  • Group: vault
  • Description: Checkout the full app source
  • Program: C:\filevault\vault-cli-3.1.6\bin\vlt.bat
  • Parameters: co http://localhost:4502/crx
  • Working Directory: $FileDir$

The following illustration shows the correct configuration. 


4. Add a vault command for the directory check-out. Add the following values:

  • Name: vlt check out
  • Group: vault
  • Description: Checkout from AEM
  • Program: C:\filevault\vault-cli-3.1.6\bin\vlt.bat
  • Parameters: update --force
  • Working Directory: $FileDir$
5. Add a vault command for the directory check-in. Add the following values:
  • Name: vlt check in
  • Group: vault
  • Description: Checkin to AEM
  • Program: C:\filevault\vault-cli-3.1.6\bin\vlt.bat
  • Parameters: ci --force
  • Working Directory: $FileDir$

Now you can synchronize the code from AEM JCR to intelliJ IDE. 

Create additional AEM project files in CRXDE Lite

Create a template and page component for the echoproject by using CRXDE lite. Once done, you can synchronize these changes into IntelliJ. 

Add additional folders to the echoproject application

Add two folders under /apps/echoproject named templates and components. Under the components folder, add another folder names page. Ensure that your folder structure looks like the following illustration. 


To create an AEM application folder structure:

  1. Go to CRXDE Lite at http://localhost:4502/crx/de/index.jsp.
  2. Right-click the echoproject folder (or the parent folder), select Create, Create Folder.
  3. Enter the folder name into the Create Folder dialog box. 

Create a template for the echoproject

You can create a template by using CRXDE Lite. An AEM template enables you to define a consistent style for the pages in your application. A template comprises of nodes that specify the page structure. For more information about templates, see Templates.

To create a template, perform these tasks:

1. Go to CRXDE Lite at http://localhost:4502/crx/de/index.jsp.

2. Right-click the template folder (within your application), select Create, Create Template.

3. Enter the following information into the Create Template dialog box:

  • Label: The name of the template to create. Enter templateEcho. 
  • Title: The title that is assigned to the template.
  • Description: The description that is assigned to the template.
  • Resource Type: The component's path that is assigned to the template and copied to implementing pages. Enter echoproject/components/page/templateEcho.
  • Ranking: The order (ascending) in which this template will appear in relation to other templates. Setting this value to 1 ensures that the template appears first in the list.

5. Add a path to Allowed Paths. Click on the plus sign and enter the following value: /content(/.*)?. 

6. Click Next for Allowed Parents.
7. Select OK on Allowed Children.

Add a page component to the echoproject

Components are re-usable modules that implement specific application logic to render the content of your web site. You can think of a component as a collection of scripts (for example, JSPs, Java servlets, and so on) that completely realize a specific function. In order to realize this functionality, it is your responsibility as a CQ developer to create scripts that perform specific functionality. For more information about components, see Components.

By default, a component has at least one default script, identical to the name of the component. To create a render component, perform these tasks:

1. Go to CRXDE Lite.
3. Right-click /apps/echoproject/components/page, then select Create, Create Component.
4. Enter the following information into the Create Component dialog box:

  • Label: The name of the component to create. Enter templateEcho.
  • Title: The title that is assigned to the component.
  • Description: The description that is assigned to the template.
  • Super Type: foundation/components/page (in AEM 6, you specify this value for page components. In previous versions of AEM, this was not required.)

5. Select Next for Advanced Component Settings and Allowed Parents.
6. Select OK on Allowed Children.
7. Open the templateEcho.jsp located at: /apps/echoproject/components/page/templateEcho/templateEcho.jsp.
8. Enter the following JSP code.

<%@include file="/libs/foundation/global.jsp" %>
<cq:include script="/libs/wcm/core/components/init/init.jsp"/>
<title>AEM Echo Page</title>
<h2>This page invokes the AEM Echo Service</h2>
<% hello = sling.getService(;

<h3><%= "The Echo Service says:" +hello.echo("Hello There!")%> </h3>

Synchronize the AEM code in IntelliJ IDE

At the point, the code in AEM JCR is different from the code in IntelliJ. You can now synchronize the changes so they appear in IntelliJ IDE. Use the "vlt full check out" and download the code from CRX to IntelliJ IDE. Right click on "content" folder and do vault -> vlt full check out ( Check if you have the vault auth xml with CRX credentials here - C:\Users\<user>\.vault\auth.xml ).

The following illustration shows the menu that lets you synchronize the AEM JCR changes. 


You will see messages in the IntelliJ console window, as shown in this illustration. 


Now you will be able to view the template and page component that you created in CRXDE lite within IntelliJ, as shown in this illustration. 


When you open templateEcho.jsp in IntelliJ, you see the code that you added in CRXDE lite, as shown here. 


Debug the AEM application from the IntelliJ IDE

You can run the AEM application from IntelliJ. To run the application, you have start AEM in debug mode by using the following command from the folder where the AEM quick start is located:

java -Xmx512m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=30303,suspend=n -jar cq5-author-p4502.jar

Next edit IntelliJ to run the application using AEM. Once done, you can start the AEM in debug mode, as shown in this illustration. 



Once started, the AEM application is displayed. The HelloService is invoked and the JSP invokes the echo method, as shown in the following illustration. 


Set up a Web Facet in the Project

IntelliJ IDE needs to understand where to find the JSPs for debugging. As IDEA cannot interpret the content-package-maven-plugin settings, this needs to be configured manually.

  1. Go to File -> Project Structure.
  2. Select the "content" module.
  3. Click "+" above the list of modules and select "Web".
  4. As the Web Resource Directory, select the content/src/main/content/jcr_root subdirectory of your project as shown in the screen shot below.

Install the JSR45 support plugin 

  1. Go to the "Plugins" pane in the IntelliJ IDE settings.
  2. Navigate to the "JSR45 Integration" Plugin and select the check box next to it.
  3. Click "Apply".
  4. Restart IntelliJ IDEA when requested to.


Configure a Debug Profile 

  1. Go to "Run" -> "Edit Configurations".
  2. Hit the "+" and select "JSR45 Remote".
  3. In the configuration dialog, select "Configure" next to "Application Server" and configure a Generic server.
  4. Set the start page to an appropriate URL if you want to open a browser when you start debugging. In this example, specify http://localhost:4502/editor.html/content/Echo.html.
  5. Remove all "Before launch" tasks if you use vlt autosync, or configure appropriate Maven tasks if you don't.
  6. On the "Startup/Connection" pane, adjust the port if required.
  7. Copy the command line arguments that IntelliJ IDEA proposes

Start debugging the EchoProject

You are now all set up for debugging your JSPs in AEM.

  1. Select "Run" -> "Debug" -> Your Debug Profile.
  2. Set breakpoints in your component code.
  3. Access a page in your browser.

See also 

Congratulations, you have just created an AEM 6 application using IntelliJ IDE. Please refer to the AEM community page for other articles that discuss how to build AEM services/applications.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy