Expand my Community achievements bar.

Getting an error while creating a custom component using sling model in AEM

Avatar

Level 1

Getting the below error while creating a custom component in AEM 6.4 using sling model.

Error Message:

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.scripting.sightly.SightlyException: Compilation errors in org/apache/sling/scripting/sightly/apps/slingexample/components/content/slingcomponent/slingcomponent_html.java: 
Line 28, column 1288 : Only a type can be imported. com.adobe.aem.core.models.SlingModel resolves to a package
Line 41, column 1795 : SlingModel cannot be resolved to a type

Parent POM:

<?xml version="1.0" encoding="UTF-8"?>

<!-- | Copyright 2015 Adobe Systems Incorporated | | Licensed 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

| | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable

law or agreed to in writing, software | distributed under the License is

distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY

KIND, either express or implied. | See the License for the specific language

governing permissions and | limitations under the License. -->

<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>slingexample</groupId>

<artifactId>slingexample</artifactId>

<packaging>pom</packaging>

<version>1.0-SNAPSHOT</version>

<description>slingexample</description>

<modules>

<module>core</module>

<module>ui.apps</module>

<module>ui.content</module>

<module>it.tests</module>

<module>it.launcher</module>

</modules>

<properties>

<aem.host>localhost</aem.host>

<aem.port>4502</aem.port>

<aem.publish.host>localhost</aem.publish.host>

<aem.publish.port>4503</aem.publish.port>

<sling.user>admin</sling.user>

<sling.password>admin</sling.password>

<vault.user>admin</vault.user>

<vault.password>admin</vault.password>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

</properties>

<build>

<plugins>

<!-- Maven Release Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-release-plugin</artifactId>

<version>2.5.3</version>

<configuration>

<scmCommentPrefix>[maven-scm] :</scmCommentPrefix>

<preparationGoals>clean install</preparationGoals>

<goals>install</goals>

<releaseProfiles>release</releaseProfiles>

</configuration>

</plugin>

<!-- Maven Source Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-source-plugin</artifactId>

<version>3.0.1</version>

<inherited>true</inherited>

</plugin>

<!-- Maven Jar Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-jar-plugin</artifactId>

<version>3.0.2</version>

</plugin>

<!-- Maven Enforcer Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-enforcer-plugin</artifactId>

<executions>

<execution>

<id>enforce-maven</id>

<goals>

<goal>enforce</goal>

</goals>

<configuration>

<rules>

<requireMavenVersion>

<version>[3.3.9,)</version>

</requireMavenVersion>

<requireJavaVersion>

<message>Project must be compiled with Java 8 or higher</message>

<version>1.8.0</version>

</requireJavaVersion>

</rules>

</configuration>

</execution>

</executions>

</plugin>

<!-- Maven Compiler Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<configuration>

<source>1.8</source>

<target>1.8</target>

</configuration>

</plugin>

<!-- Maven IntelliJ IDEA Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-idea-plugin</artifactId>

<version>2.2.1</version>

<configuration>

<jdkLevel>1.8</jdkLevel>

<linkModules>true</linkModules>

<downloadSources>true</downloadSources>

</configuration>

</plugin>

<!-- Maven Eclipse Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-eclipse-plugin</artifactId>

<version>2.10</version>

<configuration>

<downloadSources>true</downloadSources>

</configuration>

</plugin>

</plugins>

<pluginManagement>

<plugins>

<!-- Maven Clean Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-clean-plugin</artifactId>

<version>3.0.0</version>

</plugin>

<!-- Maven Resources Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-resources-plugin</artifactId>

<version>3.0.2</version>

</plugin>

<!-- Maven Compiler Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.6.1</version>

</plugin>

<!-- Maven Installer Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-install-plugin</artifactId>

<version>2.5.2</version>

</plugin>

<!-- Maven Surefire Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.20</version>

</plugin>

<!-- Maven Failsafe Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-failsafe-plugin</artifactId>

<version>2.20</version>

</plugin>

<!-- Maven Deploy Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-deploy-plugin</artifactId>

<version>2.8.2</version>

</plugin>

<!-- Apache Sling Plugin -->

<plugin>

<groupId>org.apache.sling</groupId>

<artifactId>maven-sling-plugin</artifactId>

<version>2.2.0</version>

<configuration>

<slingUrl>http://${aem.host}:${aem.port}/system/console</slingUrl>

<useProxy>false</useProxy>

<deploymentMethod>WebConsole</deploymentMethod>

</configuration>

</plugin>

<!-- HTL Maven Plugin -->

<plugin>

<groupId>org.apache.sling</groupId>

<artifactId>htl-maven-plugin</artifactId>

<version>1.0.6</version>

<configuration>

<failOnWarnings>true</failOnWarnings>

</configuration>

<executions>

<execution>

<goals>

<goal>validate</goal>

</goals>

</execution>

</executions>

</plugin>

<!-- Jackrabbit FileVault Package Plugin -->

<plugin>

<groupId>org.apache.jackrabbit</groupId>

<artifactId>filevault-package-maven-plugin</artifactId>

<version>1.0.1</version>

<configuration>

<filterSource>src/main/content/META-INF/vault/filter.xml</filterSource>

</configuration>

</plugin>

<!-- Content Package Plugin -->

<plugin>

<groupId>com.day.jcr.vault</groupId>

<artifactId>content-package-maven-plugin</artifactId>

<version>1.0.2</version>

<configuration>

<targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL>

<useProxy>false</useProxy>

<failOnError>true</failOnError>

<userId>${vault.user}</userId>

<password>${vault.password}</password>

</configuration>

</plugin>

<!-- Apache Felix Bundle Plugin -->

<plugin>

<groupId>org.apache.felix</groupId>

<artifactId>maven-bundle-plugin</artifactId>

<version>3.3.0</version>

<inherited>true</inherited>

</plugin>

<!-- Maven Enforcer Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-enforcer-plugin</artifactId>

<version>1.4.1</version>

</plugin>

<!-- Maven Dependency Plugin -->

<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-dependency-plugin</artifactId>

<version>3.0.0</version>

</plugin>

<!-- Build Helper Maven Plugin -->

<plugin>

<groupId>org.codehaus.mojo</groupId>

<artifactId>build-helper-maven-plugin</artifactId>

<version>3.0.0</version>

</plugin>

<!--This plugin's configuration is used to store Eclipse m2e settings

only. It has no influence on the Maven build itself. -->

<plugin>

<groupId>org.eclipse.m2e</groupId>

<artifactId>lifecycle-mapping</artifactId>

<version>1.0.0</version>

<configuration>

<lifecycleMappingMetadata>

<pluginExecutions>

<pluginExecution>

<pluginExecutionFilter>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-enforcer-plugin</artifactId>

<versionRange>[1.0.0,)</versionRange>

<goals>

<goal>enforce</goal>

</goals>

</pluginExecutionFilter>

<action>

<ignore />

</action>

</pluginExecution>

<pluginExecution>

<pluginExecutionFilter>

<groupId>

org.apache.maven.plugins

</groupId>

<artifactId>

maven-dependency-plugin

</artifactId>

<versionRange>

[2.2,)

</versionRange>

<goals>

<goal>copy-dependencies</goal>

<goal>unpack</goal>

</goals>

</pluginExecutionFilter>

<action>

<ignore />

</action>

</pluginExecution>

<pluginExecution>

<pluginExecutionFilter>

<groupId>

org.codehaus.mojo

</groupId>

<artifactId>

build-helper-maven-plugin

</artifactId>

<versionRange>

[1.5,)

</versionRange>

<goals>

<goal>

reserve-network-port

</goal>

</goals>

</pluginExecutionFilter>

<action>

<ignore />

</action>

</pluginExecution>

</pluginExecutions>

</lifecycleMappingMetadata>

</configuration>

</plugin>

</plugins>

</pluginManagement>

</build>

<profiles>

<!-- ====================================================== -->

<!-- A D O B E P U B L I C P R O F I L E -->

<!-- ====================================================== -->

<profile>

<id>adobe-public</id>

<activation>

<activeByDefault>true</activeByDefault>

</activation>

<properties>

<releaseRepository-Id>adobe-public-releases</releaseRepository-Id>

<releaseRepository-Name>Adobe Public Releases</releaseRepository-Name>

<releaseRepository-URL>https://repo.adobe.com/nexus/content/groups/public</releaseRepository-URL>

</properties>

<repositories>

<repository>

<id>adobe-public-releases</id>

<name>Adobe Public Repository</name>

<url>https://repo.adobe.com/nexus/content/groups/public</url>

<releases>

<enabled>true</enabled>

<updatePolicy>never</updatePolicy>

</releases>

<snapshots>

<enabled>false</enabled>

</snapshots>

</repository>

</repositories>

<pluginRepositories>

<pluginRepository>

<id>adobe-public-releases</id>

<name>Adobe Public Repository</name>

<url>https://repo.adobe.com/nexus/content/groups/public</url>

<releases>

<enabled>true</enabled>

<updatePolicy>never</updatePolicy>

</releases>

<snapshots>

<enabled>false</enabled>

</snapshots>

</pluginRepository>

</pluginRepositories>

</profile>

<!-- Development profile: install only the bundle -->

<profile>

<id>autoInstallBundle</id>

<!-- To enable this feature for a bundle, the maven-sling-plugin (without

configuration) needs to be included: <plugin> <groupId>org.apache.sling</groupId>

<artifactId>maven-sling-plugin</artifactId> </plugin> -->

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<build>

<pluginManagement>

<plugins>

<plugin>

<groupId>org.apache.sling</groupId>

<artifactId>maven-sling-plugin</artifactId>

<executions>

<execution>

<id>install-bundle</id>

<goals>

<goal>install</goal>

</goals>

</execution>

</executions>

</plugin>

</plugins>

</pluginManagement>

</build>

</profile>

<profile>

<id>autoInstallPackage</id>

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<build>

<pluginManagement>

<plugins>

<plugin>

<groupId>org.apache.jackrabbit</groupId>

<artifactId>filevault-package-maven-plugin</artifactId>

<executions>

<execution>

<id>create-package</id>

<goals>

<goal>package</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<groupId>com.day.jcr.vault</groupId>

<artifactId>content-package-maven-plugin</artifactId>

<executions>

<execution>

<id>install-package</id>

<goals>

<goal>install</goal>

</goals>

<configuration>

<targetURL>http://${aem.host}:${aem.port}/crx/packmgr/service.jsp</targetURL>

<useProxy>false</useProxy>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</pluginManagement>

</build>

</profile>

<profile>

<id>autoInstallPackagePublish</id>

<activation>

<activeByDefault>false</activeByDefault>

</activation>

<build>

<pluginManagement>

<plugins>

<plugin>

<groupId>org.apache.jackrabbit</groupId>

<artifactId>filevault-package-maven-plugin</artifactId>

<executions>

<execution>

<id>create-package</id>

<goals>

<goal>package</goal>

</goals>

</execution>

</executions>

</plugin>

<plugin>

<groupId>com.day.jcr.vault</groupId>

<artifactId>content-package-maven-plugin</artifactId>

<executions>

<execution>

<id>install-package-publish</id>

<goals>

<goal>install</goal>

</goals>

<configuration>

<targetURL>http://${aem.publish.host}:${aem.publish.port}/crx/packmgr/service.jsp</targetURL>

<useProxy>false</useProxy>

</configuration>

</execution>

</executions>

</plugin>

</plugins>

</pluginManagement>

</build>

</profile>

</profiles>

<!-- ====================================================================== -->

<!-- D E P E N D E N C I E S -->

<!-- ====================================================================== -->

<dependencyManagement>

<dependencies>

<!-- OSGi Dependencies -->

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.core</artifactId>

<version>6.0.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.cmpn</artifactId>

<version>6.0.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>com.adobe.cq</groupId>

<artifactId>core.wcm.components.core</artifactId>

<version>2.2.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-lang3</artifactId>

<version>3.6</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.annotation</artifactId>

<version>6.0.1</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>

<!-- Adobe AEM Dependencies -->

<dependency>

<groupId>com.adobe.aem</groupId>

<artifactId>uber-jar</artifactId>

<version>6.4.0</version>

<classifier>apis</classifier>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-atinject_1.0_spec</artifactId>

<version>1.0</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>com.adobe.cq</groupId>

<artifactId>core.wcm.components.all</artifactId>

<type>zip</type>

<version>2.2.0</version>

</dependency>

<!-- Apache Sling Dependencies -->

<dependency>

<groupId>org.apache.sling</groupId>

<artifactId>org.apache.sling.models.api</artifactId>

<version>1.3.8</version>

<scope>provided</scope>

</dependency>

<!-- Servlet API -->

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>servlet-api</artifactId>

<version>2.5</version>

<scope>provided</scope>

</dependency>

<dependency>

<groupId>javax.inject</groupId>

<artifactId>javax.inject</artifactId>

<version>1</version>

</dependency>

<dependency>

<groupId>javax.servlet.jsp</groupId>

<artifactId>jsp-api</artifactId>

<version>2.1</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>

<!-- Testing -->

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.12</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-simple</artifactId>

<version>1.7.21</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.mockito</groupId>

<artifactId>mockito-core</artifactId>

<version>2.7.22</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>junit-addons</groupId>

<artifactId>junit-addons</artifactId>

<version>1.4</version>

<scope>test</scope>

</dependency>

<dependency>

<groupId>org.apache.sling</groupId>

<artifactId>org.apache.sling.testing.sling-mock</artifactId>

<version>2.2.18</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>

</project>


Core POM file:

<?xml version="1.0" encoding="UTF-8"?>

<!-- | Copyright 2017 Adobe Systems Incorporated | | Licensed 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

| | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable

law or agreed to in writing, software | distributed under the License is

distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY

KIND, either express or implied. | See the License for the specific language

governing permissions and | limitations under the License. -->

<project xmlns="http://maven.apache.org/POM/4.0.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>

<groupId>slingexample</groupId>

<artifactId>slingexample</artifactId>

<version>1.0-SNAPSHOT</version>

<relativePath>../pom.xml</relativePath>

</parent>

<artifactId>slingexample.core</artifactId>

<packaging>bundle</packaging>

<name>slingexample - Core</name>

<description>Core bundle for slingexample</description>

<build>

<plugins>

<plugin>

<groupId>org.apache.sling</groupId>

<artifactId>maven-sling-plugin</artifactId>

</plugin>

<plugin>

<groupId>org.apache.felix</groupId>

<artifactId>maven-bundle-plugin</artifactId>

<extensions>true</extensions>

<executions>

<execution>

<id>bundle-manifest</id>

<phase>process-classes</phase>

<goals>

<goal>manifest</goal>

</goals>

</execution>

</executions>

<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.adobe.aem.core

</Sling-Model-Packages>

</instructions>

</configuration>

</plugin>

</plugins>

</build>

<dependencies>

<!-- OSGi Dependencies -->

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.core</artifactId>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.cmpn</artifactId>

</dependency>

<dependency>

<groupId>org.osgi</groupId>

<artifactId>osgi.annotation</artifactId>

</dependency>

<!-- Other Dependencies -->

<dependency>

<groupId>org.slf4j</groupId>

<artifactId>slf4j-api</artifactId>

</dependency>

<dependency>

<groupId>com.adobe.cq</groupId>

<artifactId>core.wcm.components.core</artifactId>

</dependency>

<dependency>

<groupId>org.apache.commons</groupId>

<artifactId>commons-lang3</artifactId>

</dependency>

<dependency>

<groupId>javax.jcr</groupId>

<artifactId>jcr</artifactId>

</dependency>

<dependency>

<groupId>javax.inject</groupId>

<artifactId>javax.inject</artifactId>

</dependency>

<dependency>

<groupId>javax.servlet</groupId>

<artifactId>servlet-api</artifactId>

</dependency>

<dependency>

<groupId>com.adobe.aem</groupId>

<artifactId>uber-jar</artifactId>

<classifier>apis</classifier>

</dependency>

<dependency>

<groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-atinject_1.0_spec</artifactId>

</dependency>

<dependency>

<groupId>org.apache.sling</groupId>

<artifactId>org.apache.sling.models.api</artifactId>

</dependency>

<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

</dependency>

<dependency>

<groupId>org.mockito</groupId>

<artifactId>mockito-core</artifactId>

</dependency>

<dependency>

<groupId>junit-addons</groupId>

<artifactId>junit-addons</artifactId>

</dependency>

<dependency>

<groupId>org.apache.sling</groupId>

<artifactId>org.apache.sling.testing.sling-mock</artifactId>

</dependency>

<dependency>

<groupId>uk.org.lidalia</groupId>

<artifactId>slf4j-test</artifactId>

</dependency>

</dependencies>

</project>

SlingModel.java

package com.adobe.aem.core.models;

import javax.annotation.Resource;

import javax.annotation.PostConstruct;

import javax.inject.Inject;

import javax.inject.Named;

import org.apache.sling.models.annotations.Model;

import org.apache.sling.models.annotations.DefaultInjectionStrategy;

@Model(adaptables=Resource.class, defaultInjectionStrategy=DefaultInjectionStrategy.OPTIONAL)

public class SlingModel {

@Inject

private String name;

@Inject

private String description;

@PostConstruct

protected void init() {

}

public String getName() {

return name;

}

public String getDescription() {

return description;

}

}

slingcomponent.html

<div data-sly-use.objname="com.adobe.aem.core.models.SlingModel">

<h4>Name: ${objname.name}</h4>

<h6>Description: ${objname.description}</h6>

</div>




12 Replies

Avatar

Employee Advisor

Can you check [1], it explains how to use sling models in AEM. Try to check if you missed any step/configuration.

[1] Adobe Experience Manager Help | Getting Started with AEM Sites Chapter 6 - Creating a new AEM Compon...

Avatar

Level 10

Here is an example of using Sling Model to create an HTL component that works - you do not have to spend hours creating the Weekend Tutorial:

Adobe Experience Manager Help | Creating a HTL Repeating Data Set 6.4 Component that uses Sling Mode...

Avatar

Level 10

Here is a more complex example of creating a HTL component using a more detailed SLING MODEL -

Creating a custom Touch UI Grid Component for Adobe Experience Manager

Hope this helps.

Avatar

Level 1

I was able to get this touchmulti component working. I tried to create a copy of the helloworld component and was able to get that also working. What was the issue with my original Project? Is it because of the archetype? I see this uses archetype 13 whereas mine was 15.

Avatar

Community Advisor

as per my understanding it should not be archetype issue.

because I am working in AEM 6.3 and archetype 17. and we are able to work in sling models properly with core components.

Also I am not able to find the dependency of sling models here:

org.apache.sling.models.impl:

In core pom:

<dependency>

   <groupId>org.apache.sling</groupId>

   <artifactId>org.apache.sling.models.impl</artifactId>

   <scope>test</scope>

</dependency>

<dependency>

   <groupId>org.apache.sling</groupId>

   <artifactId>org.apache.sling.api</artifactId>

   <version>2.4.2</version>

</dependency>

Parent POM:

<dependency>

   <groupId>org.apache.sling</groupId>

   <artifactId>org.apache.sling.models.impl</artifactId>

   <version>1.3.0</version>

   <scope>test</scope>

</dependency>

Avatar

Level 1

I have never used this dependency before (org.apache.sling.models.impl). But I did try it by adding these dependencies mentioned, however I still get the error.

But I tried to create another Project with archetype 13 and the sling model worked fine.

Avatar

Level 1

Is there any significance on the package name? Whenever I create a Project with package name as com.adobe.aem, it resolves to this error irrespective of the Archetype. I tried to create projects with archetype 13 and 15 under another package name and it works fine.

Avatar

Level 1

I tried this, but I'm getting the same error. The hello world component which is in the package works fine. When I create a copy of that and create another Model, I get this error.

Avatar

Level 10

What archetype version did you follow? I can see that you've manually edited the version numbers of specific libraries.

Refer GitHub - adobe/aem-project-archetype: Maven template to create a new Adobe Experience Manager (AEM) ...

Pick a version based on your AEM/SP and it should work fine.

Avatar

Level 1

Archetype 15 was used. I changed uber-jar version to 6.4 and added commons-lang3 and geronimo-atinject_1.0_spec dependencies into the POM file

Avatar

Community Advisor

please check if you bundle is active or not?

if not active and you are not seeing any error in red, then try to click on dependencies and check those are active or not?