Showing posts with label Maven. Show all posts
Showing posts with label Maven. Show all posts

Saturday, 27 October 2018

Plugin org.apache.maven.plugins:maven-dependency-plugin:2.10 or one of its dependencies could not be resolved

I tried to create AEM 6.4 project using maven archetype 10. When tried to build the project got below error.

[ERROR] Plugin org.apache.maven.plugins:maven-dependency-plugin:2.10 or one of its dependencies could not be resolved:
 Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.10: 
 Could not transfer artifact org.apache.maven.plugins:maven-dependency-plugin:pom:2.10 from/to central 
 ( Access denied to: https://repo.maven.apac ency-plugin-2.10.pom , ReasonPhrase:Forbidden. -> [Help 1]


Check if you can download the jar from browser

If you are able to download the jar then your browser has connectivity to central but maven doesn't. So try using a proxy in settings.xml

If above didn't work try to build using command
mvn clean install -s

Saturday, 22 July 2017


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.

Saturday, 1 July 2017

Failed to execute goal org.apache.felix:maven-scr-plugin

I have created maven archetype 10 project for AEM 6.1 and jdk 1.8. When I ran mvn clean install I ran in to below errors.

1) When maven-scr-plugin (1.11.0) and org.apache.felix.scr.annotations (1.9.0)
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.11.0:scr (generate-scr-descriptor) on project digital-spearhead-core: Execution generate-scr-descriptor of goal org.apache.felix:maven-scr-plugin:1.11.0:scr failed. IllegalArgumentException -> [Help 1]

2) When maven-scr-plugin (1.12.0) and org.apache.felix.scr.annotations (1.9.0)
[ERROR] Failed to execute goal org.apache.felix:maven-scr-plugin:1.12.0:scr (generate-scr-descriptor) on project aem-sample-core: SCR Descriptor parsing had failures (see log) -> [Help 1]

Use correct maven-scr-plugin and org.apache.felix.scr.annotations versions.  I have used maven-scr-plugin (1.20.0) and org.apache.felix.scr.annotations (1.9.0), now build is success.

Wednesday, 21 June 2017

Bundle is not uploading after maven build

Check first if bundle is installed in /system/console/bundles. check if jar files is present in /apps/app-name/install folder. If bundle is not present then change the filter.xml as shown below.

Under the path definition /apps/<appname>, define the following include and exclude rules
  • include pattern="/apps/<appname>(/.*)?"
  • exclude pattern="/apps/<appname>/install(/.*)?"
Note: these rules ensure that your bundle will be reinstalled upon every reinstall of the package.
<?xml version="1.0" encoding="UTF-8"?>
<workspaceFilter version="1.0">
    <filter root="/apps/app-name">
<include pattern="/apps/app-name(/.*)?" />
<exclude pattern="/apps/app-name/install(/.*)?" />
<filter root="/etc/designs/app-name">
<filter root="/apps/sling/servlet/errorhandler/500.jsp" />

Saturday, 17 June 2017

Changing a .content.xml file locally is not reflecting in CRX after maven build

If .content.xml file is changed locally and changes are not reflecting in crx then check maven-resources-plugin.

Add below plugin in pom.xml of UI module.(aem-sample/aem-content-ui/pom.xml).


For maven-resources-plugin check that its copying your .content.xml to target folder and for content-package-maven-plugin check that correct filter values are set.
We can also verify by extracting the generated package and check if it has the changes or not or look at a vault-work directory in target and get to the directory in which you have changed the .content.xml, verify if it has changes. If your changes are there in vault-works then the maven-resources-plugin is working absolutely fine and the issue may be with the content-package-maven-plugin.

If bundle is not installed check this post.

Tuesday, 2 May 2017

Create AEM porject structure using Lazybones

Lazybones is a command line tool to create AEM project structure. Adobe is recommending its customers to create AEM project structure using Lazybones instead of traditional Maven archetype 10. As when we create a aem project using Maven archetype it is not easy to customize, it provides lots of sample content and packages like test, launcher. Which might not be required for your project, on contrary lazybones bones is very interactive , flexible and easy to customize according to your project need. Adobe consulting Services (ACS) provides a aem multi module template using which you can create AEM projects, which includes lot of default config options and also provides an option to include the ACS commons package as a sub package.
The aim of this tutorial is to learn what is lazybones and how we can use it to create an aem skeleton project structure, as Adobe consulting Services (ACS) has updated the template version and provided the support for AEM 6.3 also i am going to create project structure for AEM 6.3, for learning i am using windows machine so we are going to install lazybones on windows, but you can install it on linux and other operating systems also.
Lazybones Overview:- Lazybones is a command line tool and is build in two parts. First lazybones command line tool and second project templates. This command line tool allows you to create a new project structure for any framework or library for which the tool has a template. Currently ACS has contributed one template for creating AEM multi module project, which we are going to use in this tutorial. You can also contribute templates by sending pull requests to this GitHub project or publishing the packages to the relevant Bintray repository.

Monday, 24 April 2017

AEM OSGI component is not visible

When new AEM project is created we may find OSGI components are not displayed in /system/console/components or in or in bundle.

To avoid this add the below plugin in the parent pom.xml and rebuild the project


Tuesday, 18 April 2017

Deploy AEM bundles and packages using Maven

Setup Maven

You can use Maven to build an OSGi bundle that uses the QueryBuilder API and is deployed to Experiene 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"

Monday, 17 April 2017

Cannot create maven project

When trying to create maven project using multi module content package archetype we may get exception

Maven command to create project:

mvn archetype:generate -DarchetypeRepository= -DarchetypeArtifactId=multimodule-content-package-archetype -DarchetypeVersion=1.0.2 -DgroupId=com.mycompany.myproject.htl -DartifactId=htl -Dversion=1.0-SNAPSHOT -Dpackage=com.mycompany.myproject.htl -DappsFolderName=myproject -DartifactName="My Project" -DcqVersion="5.6.1" -DpackageGroup="My Company"


Caused by: org.apache.maven.plugin.MojoFailureException: The desired archetype does not exist (


Check the settings.xml under .m2 folder.

Thursday, 13 April 2017

Lazybones - Project Creation Tool

Lazybones was born out of frustration that Ratpack does not and will not have a command line tool that will bootstrap a project. It's a good decision for Ratpack, but I'm lazy and want tools to do the boring stuff for me.
The tool is very simple: it allows you to create a new project structure for any framework or library for which the tool has a template. You can even contribute templates by sending pull requests to this GitHub project or publishing the packages to the relevant Bintray repository (more info available below).
The concept of Lazybones is very similar to Maven archetypes, and what Yeoman does for web applications. Lazybones also includes a sub templates feature that resembles the behaviour of Yeoman's sub-generators, allowing you to generate optional extras (controllers, scaffolding etc.) inside a project.

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

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.

Wednesday, 7 September 2016

Issues while Migrating from Java6 to Java8 in AEM 6.1

Recently while working on AEM 6.1, I had to move from Java 6 to Java 8. Simply changing the Java version in POM led to some issues with OSGi services. Specifically, those services that were using @Reference annotation were not getting active and remained in “satistied” state.
Here are all the steps I followed firstly to change Java version and then fixing above mentioned issue:
1. To build an AEM project with Java8 as runtime environment, following configuration is required in pom.xml. The Compiler Plugin is added to the parent POM, it is used to compile the sources of your project.

Friday, 22 April 2016

Creating your first AEM Service using an Adobe Maven Archetype project

In some business use cases, you create an OSGi bundle when creating an Adobe Experience Manager (AEM) application. Although there are different ways to create an OSGi bundle, a recommended way is to use Maven and the Adobe Maven Archetype. This development article walks you through creating a basic OSGi bundle that contains a simple service namedKeyService. All this service does is accept an input value and sets a key value. It also exposes a method that returns the key value and the value can be displayed within an AEM web page.

Friday, 13 November 2015

Maven Plugin to Install Bundle Directly Into OSGI in AEM/Adobe CQ5

Use the following plugin in your POM to install bundle directly into OSGI console.


Create an Adobe CQ Maven archetype project

To create an Adobe CQ archetype project, perform these steps:

1. Open the command prompt and go to your working directory (D:\smaple-cq-project).
2. Run the following Maven command:

mvn archetype:generate 
3. When prompted for additional information, specify these values:
groupId: com.test
artifactId: cq-test-project
version: 1.0-SNAPSHOT : 1.0.0
package: com.aem.code
appsFolderName: AEM-Training
artifactName: AEM Training
componentGroupName - AEM62
contentFolderName - aemtraining
cssId - AEMtrainginCss62
packageGroup: AEM
siteName - AEMTraining
confirm: Y
4. Once done, you will see a message like:

How to setup Maven in your development environment

You can use Maven to build an OSGi bundle. 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:

  1. Unzip the distribution archive, i.e. to the directory you wish to install Maven 3.1.1. These instructions assume you chose C:\Program Files\Apache Software Foundation. The subdirectory apache-maven-3.1.1 will be created from the archive
  2. Add the M2_HOME environment variable by opening up the system properties (WinKey + Pause), selecting the "Advanced" tab, and the "Environment Variables" button, then adding the M2_HOME variable in the user variables with the value C:\Program Files\Apache Software Foundation\apache-maven-3.1.1. Be sure to omit any quotation marks around the path even if it contains spaces. Note: For Maven   2.0.9, also be sure that the M2_HOME doesn't have a '\' as last character.
  3. In the same dialog, add the M2 environment variable in the user variables with the value %M2_HOME%\bin.
  4. Optional: In the same dialog, add the MAVEN_OPTS environment variable in the user variables to specify JVM properties, e.g. the value -Xms256m -Xmx512m. This environment variable can be used to supply extra options to Maven.
  5. In the same dialog, update/create the Path environment variable in the user variables and prepend the value %M2% to add Maven available in the command line.
  6. In the same dialog, make sure that JAVA_HOME exists in your user variables or in the system variables and it is set to the location of your JDK, e.g. C:\Program Files\Java\jdk1.5.0_02 and that %JAVA_HOME%\bin is in your Path environment variable.
  7. Open a new command prompt (Winkey + R then type cmd) and run mvn --version to verify that it is correctly installed.