AEM 6.5 - New Project with a Servlet - Dependencies not resolved | Community
Skip to main content
Level 2
February 15, 2022
Solved

AEM 6.5 - New Project with a Servlet - Dependencies not resolved

  • February 15, 2022
  • 2 replies
  • 4543 views

Hi community!

 

I'm entering on the AEM world by following the Adobe Tutorials. I'm with Servlets right now and I found a stopper and after searching in google for hours I don´t know how to go on... these are the steps I followed.

 

1) new project

mvn -B archetype:generate -Padobe-public -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=23 -D appTitle="ProyectoFormacionv2" -D appId="trainingProjv2" -D groupId="com.adobe.aem.training.projectv2" -D artifactId="aem-training-project-v2" -D version="0.0.1-SNAPSHOT"

 

2) add new servlet on the core project

@8220494(service=Servlet.class,
property={
Constants.SERVICE_DESCRIPTION + "=Servlet to Render Product Data",
"sling.servlet.methods=" + HttpConstants.METHOD_GET,
"sling.servlet.paths="+ "/bin/productData"
})
public class ResourceToJSONServlet extends SlingSafeMethodsServlet {

...

 

3) run clean install autoInstallPackage adobe-public

[INFO] aem-training-project-v1 ............................ SUCCESS [ 1.110 s]
[INFO] ProyectoFormacion - Core ........................... SUCCESS [ 10.182 s]
[INFO] ProyectoFormacion - UI Frontend .................... SUCCESS [ 29.758 s]
[INFO] ProyectoFormacion - Repository Structure Package ... SUCCESS [ 4.128 s]
[INFO] ProyectoFormacion - UI apps ........................ SUCCESS [ 17.462 s]
[INFO] ProyectoFormacion - UI content ..................... SUCCESS [ 10.935 s]
[INFO] ProyectoFormacion - UI config ...................... SUCCESS [ 1.445 s]
[INFO] ProyectoFormacion - All ............................ SUCCESS [ 0.796 s]
[INFO] ProyectoFormacion - Integration Tests .............. SUCCESS [ 22.549 s]
[INFO] ProyectoFormacion - Dispatcher ..................... SUCCESS [ 0.378 s]
[INFO] ProyectoFormacion - UI Tests ....................... SUCCESS [ 0.637 s]
[INFO] ProyectoFormacion - Project Analyser ............... SUCCESS [01:20 min]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS

 

But the bundle is in Installed state with this warning on the bundle console:

 

Imported packages:

com.adobe.aem.training.project.core.filters,version=[1.0,2) from aem-training-project-v1.core (590)
com.adobe.aem.training.project.core.listeners,version=[1.0,2) from aem-training-project-v1.core (590)
com.adobe.aem.training.project.core.schedulers,version=[1.0,2) from aem-training-project-v1.core (590)
com.adobe.aem.training.project.core.servlets,version=[1.0,2) from aem-training-project-v1.core (590)
com.day.cq.search,version=[1.5,2) -- Cannot be resolved
com.day.cq.search.result,version=[1.2,2) from com.day.cq.cq-search (391)
com.day.cq.wcm.api,version=[1.29,2) -- Cannot be resolved
javax.annotation,version=0.0.0 from org.apache.geronimo.specs.geronimo-annotation_1.3_spec (3)
javax.jcr,version=[1.1,2) from org.apache.sling.jcr.jcr-wrapper (141)
javax.servlet,version=[3.1,4) from org.apache.felix.http.servlet-api (52)
org.apache.sling.api,version=[2.3,3) from org.apache.sling.api (77)
org.apache.sling.api.request,version=[2.5,3) -- Cannot be resolved
org.apache.sling.api.resource,version=[2.13,3) -- Cannot be resolved
org.apache.sling.api.servlets,version=[2.3,3) -- Cannot be resolved
org.apache.sling.commons.json,version=[2.0,3) from org.apache.sling.commons.json (135)
org.apache.sling.models.annotations,version=[1.5,2) from org.apache.sling.models.api (543)
org.apache.sling.models.annotations.injectorspecific,version=[1.1,2) from org.apache.sling.models.api (543)
org.apache.sling.settings,version=[1.4,2) -- Cannot be resolved
org.osgi.service.event,version=[1.4,2) from org.apache.felix.eventadmin (40)

 

<aem.sdk.api>2022.1.6228.20220123T154100Z-220100</aem.sdk.api>

Maven 3.6.3

JDK 11

 

Can anybody help me? 

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by JacoboAdolfo

In the pom.xml file of the core project I don't see the dependencies of your image, these are the dependencies of my core/pom.xml:

 

<dependencies>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-sdk-api</artifactId>
</dependency>


<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
<!-- Required to be able to support injection with @1961677 and @2434638 -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.impl</artifactId>
<version>1.4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<artifactId>org.apache.sling.api</artifactId>
<version>2.24.0</version>
<groupId>org.apache.sling</groupId>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>org.apache.sling.settings</artifactId>
<version>1.4.2</version>
<groupId>org.apache.sling</groupId>
<scope>provided</scope>
</dependency>
</dependencies>

 

I did not add any dependency because in the adobe training video the instructor did not add any, but the instructor used archetype 14.

 

Do I have to add dependencies? which ones? 

 

Maybe the maven instruction to create the project is wrong? 

 

Thanks for you support.


At least I added several dependencies to the core project:

 

<dependencies>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<scope>test</scope>
</dependency>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.event</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.log</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.resource</artifactId>
</dependency>
<!-- Other Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<classifier>apis</classifier>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
</dependency>
<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

 

And into the parent pom.xml references to dependencyManagement:

<dependencyManagement>
<dependencies>
<!-- OSGi Dependencies -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.versioning</artifactId>
<version>1.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.annotation.bundle</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.metatype.annotations</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.cm</artifactId>
<version>1.6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.event</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.log</artifactId>
<version>1.4.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.resource</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
<version>1.9.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlets.annotations</artifactId>
<version>1.2.4</version>
<scope>provided</scope>
</dependency>
<!-- Logging Dependencies -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
<!-- Adobe AEM Dependencies -->
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>uber-jar</artifactId>
<version>6.5.0</version>
<classifier>apis</classifier>
<scope>provided</scope>
</dependency>
<!-- Apache Sling Dependencies -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.models.api</artifactId>
<version>1.3.6</version>
<scope>provided</scope>
</dependency>
<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<scope>provided</scope>
</dependency>
<!-- JCR -->
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<!-- Taglibs -->
<dependency>
<groupId>com.day.cq.wcm</groupId>
<artifactId>cq-wcm-taglib</artifactId>
<version>5.7.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.core</artifactId>
<version>${core.wcm.components.version}</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.content</artifactId>
<type>zip</type>
<version>${core.wcm.components.version}</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.config</artifactId>
<type>zip</type>
<version>${core.wcm.components.version}</version>
</dependency>
<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.examples</artifactId>
<type>zip</type>
<version>${core.wcm.components.version}</version>
</dependency>


<!-- Testing -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.4.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit-addons</groupId>
<artifactId>junit-addons</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.wcm</groupId>
<artifactId>io.wcm.testing.aem-mock.junit5</artifactId>
<version>2.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>uk.org.lidalia</groupId>
<artifactId>slf4j-test</artifactId>
<version>1.0.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

 

I got these dependencies from another project. Now all is OK and the servlet works nice.

 

The tutorial from Adobe video training was very confusing, there is no reference to add these dependencies.

 

Thanks for the provided help.

 

Regards.

2 replies

milind_bachani
Adobe Employee
Adobe Employee
February 15, 2022

Hi @jacoboadolfo ,

This comes because your dependencies are not getting resolved.

 

Can you help me with following details :
1. AEM version being used 

1a. Any service packs installed 
2. mvn archetype version used 

3. What is the scope defined as for the maven project 


you can also check dependencies using dependency finder :
 http://<host>:<port>/system/console/depfinder


Thanks.

 

Level 2
February 15, 2022

1. AEM 6.5

1a. > http://localhost:4502/system/console/productinfo

Installed Products: Adobe Experience Manager (6.5.0)

I don´t see anything related with service packs.

 

I made the project using mvn command:

mvn -B archetype:generate -Padobe-public -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=35 -D appTitle="ProyectoFormacionv1" -D appId="trainingProjv1" -D groupId="com.adobe.aem.training.projectv1" -D artifactId="aem-training-project-v1" -D version="0.0.1-SNAPSHOT"

 

archetypeVersion=35

 

Sorry, but I don´t understand what are requesting me at point 3 "What is the scope defined as for the maven project".

 

Thanks for your help.

 

DEBAL_DAS
New Member
February 15, 2022

Here is the info associated with scope https://howtodoinjava.com/maven/maven-dependency-scopes/#:~:text=Maven%20provides%20six%20scopes%20i.e.,test%20%2C%20system%20%2C%20and%20import%20.

 

In pom.xml file you will be getting scope information like the below one -

 

Debal Das, Senior AEM Consultant
April 21, 2023

Hi,

 

I am also facing the same issue. Any resolution for the above issue?

Level 2
April 24, 2023

I fixed it by upgrading my AEM 6.5 local instance to the lastest AEM Service Pack. Once installed, in the bundle manager page I started the bundle and it started properly.

 

Good luck, thanks.