Default Sling Script Error

Avatar

Avatar
Validate 1
Level 2
berni7473
Level 2

Likes

6 likes

Total Posts

26 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
berni7473
Level 2

Likes

6 likes

Total Posts

26 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
berni7473
Level 2

07-02-2019

Hi everyone,

I am doing an update for a component in which I need to add a new class in the backend. On adding the class and making the required updates in the pom.xml files I am still getting the following error :

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: No use provider could resolve identifier com.aem.community.core.demoClass

I also tried changing the name of the class and adding the packages in the pom. I even tried changing the artifactid from uppercase to lowercase however the error still persists :

org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: org.apache.sling.scripting.sightly.SightlyException: Compilation errors in org/apache/sling/scripting/sightly/apps/DeviceSupportPage/components/content/helloworld/helloworld_html.java:

Line 28, column 1289 : Only a type can be imported. com.aem.community.core.Democlass resolves to a package

Line 55, column 2410 : Democlass cannot be resolved to a type

Can anyone please guide me on this as to why such an error comes on drag and drop of the component?

Thanks and Regards,

Bernadine Soman

smacdonald2008Feike Visser

Replies

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

07-02-2019

I would expect DemoClass.

Can you share your HTL code?

Avatar

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Employee
Feike_Visser1
Employee

Likes

247 likes

Total Posts

970 posts

Correct reply

221 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
Feike_Visser1
Employee

07-02-2019

this error 'No use provider could resolve identifier com.aem.community.core.demoClass' normally means:

- class can't be found

- bundle is not active

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,409 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,409 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

07-02-2019

AGree with Feike - make sure you are referencing the correct fully qualified class name in the HTL code and the bundle that contains this class is in ACTIVE State.

Avatar

Avatar
Give Back
Level 1
AasishJain
Level 1

Like

1 like

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile

Avatar
Give Back
Level 1
AasishJain
Level 1

Like

1 like

Total Posts

2 posts

Correct reply

0 solutions
Top badges earned
Give Back
Boost 1
View profile
AasishJain
Level 1

05-03-2021

Please check the imports for the new class which you created.

 

I was getting the same error when I was creating a sling model (@Model(adaptables =Resource.class))and after analysing the code I found that there was an import 

import javax.annotation.Resource which was not correct. I replaced it with the correct one 
import org.apache.sling.api.resource.Resource and the issue got fixed.