Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Problem - Sling Model not getting invoked

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

05-10-2017

The sling models which were created was not getting invoked . A similar question annotations - AEM Osgi Sling Model @PostConstruct never called - Stack Overflow .

Adding this here so that in future anyone facing the same issue should get the answer immediately

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

05-10-2017

Solution :-

1) First go to http://localhost:4502/system/console/status-adapters  and check if your model is registered correctly

           - if the model is not showing up, then please go and check the <Sling-Model-Packages> property of the maven-bundle-plugin.

For eg:-

  In my project I had the Sling-Model-Packages declared as below

1319067_pastedImage_0.png

But I added one of the model in the below package

1319078_pastedImage_3.png

     So if you see , my sling-model-packages will be referenced only from com.xxx.aem.website.core , but here my model was added to com.xxx.aem.website.models which will never get referenced

Thanks to https://stackoverflow.com/a/41909690/8671041

Answers (5)

Answers (5)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

06-10-2017

Thanks for posting this. I will update the article we have on Sling Models to include this great information.

Avatar

Avatar
Level 1
manishpaul
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile

Avatar
Level 1
manishpaul
Level 1

Likes

0 likes

Total Posts

1 post

Correct Reply

0 solutions
View profile
manishpaul
Level 1

07-06-2021

Another way to expose your sling models is by creating the `package-info.java file in your package where the sling model exists.


For example, if your sling model is inside com.aem.core.models.components  then create the package-info.java file like this-

@Version("1.0")
package com.aem.core.models.components;
import org.osgi.annotation.versioning.Version; 

 

This will enable the bnd-maven-plugin to pick this sling model up.

 

https://github.com/adobe/aem-project-archetype/issues/221

Avatar

Avatar
Validate 1
Level 2
Prabhat_Jain
Level 2

Likes

10 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
Prabhat_Jain
Level 2

Likes

10 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Prabhat_Jain
Level 2

25-09-2018

It is solved now the issue is with caps in package name

Avatar

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile

Avatar
Establish
MVP
Veena_Vikram
MVP

Likes

470 likes

Total Posts

1,039 posts

Correct Reply

121 solutions
Top badges earned
Establish
Coach
Contributor 2
Seeker
Ignite 5
View profile
Veena_Vikram
MVP

21-09-2018

Is your java package structure right ? TouchUIMultiField.core.models.StudentsModel ?

See if this helps Java Use-API: No use provider could resolve identifier

Avatar

Avatar
Validate 1
Level 2
Prabhat_Jain
Level 2

Likes

10 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
Prabhat_Jain
Level 2

Likes

10 likes

Total Posts

23 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
Prabhat_Jain
Level 2

21-09-2018

My sling model is registered but then also I am getting error

1576050_pastedImage_1.png

1576051_pastedImage_0.png

HTL Code:

<div>

    <b>Students Information</b>

    <br><br>

    <div data-sly-use.studentModel="TouchUIMultiField.core.models.StudentsModel" data-sly-unwrap>

        <div data-sly-test="${!studentModel || wcmmode.edit}">

            Add students using component dialog

        </div>

        <div data-sly-test="${studentModel.studentList}">

            <div data-sly-list.student="${studentModel.studentList}">

                <div>

                    <div>Student Name: ${student.studentName}</div>

                    <div>Student Roll Number: ${student.studentRollNumber}</div>

                    <br>

                    <div data-sly-list.subject="${student.subjectList}" style="margin-left:40px">

                        <div>Subject No.: ${subjectList.count}</b></div>

                        <div>Name: ${subject.subjectName}</b></div>

                        <div>Grade: ${subject.subjectGrade}</div>

                        <div>Marks: ${subject.subjectMarks}</div>

                        <div>Teacher: ${subject.subjectTeacher}</div>

                        <br>

                    </div>

                </div>

            </div>

        </div>

    </div>

</div>