private org.apache.sling.api.resource.Resource were not able to be injected | Community
Skip to main content
Level 2
October 28, 2016
Solved

private org.apache.sling.api.resource.Resource were not able to be injected

  • October 28, 2016
  • 4 replies
  • 1613 views

Hi Team

        I am using sling models with sightly. I am trying to inject resource to my model as below. All the models are throwing same error saying Resource was not able to be injected. This was working sometimes before. Now for some reason I am getting this error. Could you please help

 

@Model(adaptables = Resource.class)
public class PdfDownloadModel {
    private final Logger LOG = LoggerFactory.getLogger(getClass());

    @Inject
    private Resource resource;

 

 

ERROR

org.apache.sling.models.impl.ModelAdapterFactory Required properties [private org.apache.sling.api.resource.Resource com.core.pdfdownload.models.PdfDownloadModel.resource] on model class class com.core.pdfdownload.models.PdfDownloadModel were not able to be injected.

Thanks in Advance

Veena

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 Veena_Vikraman

Hi All

    It seems like my AEM instance got corrupted due to some compaction I have done. I have got a new Jar and setup the code and its working perfectly fine with my existing code base. 

    Thanks for all your help and time 

 

Thanks

Veena

4 replies

Feike_Visser1
Adobe Employee
Adobe Employee
October 28, 2016

You can better use @self to point to the resource

Veena_VikramanAuthorAccepted solution
Level 2
November 7, 2016

Hi All

    It seems like my AEM instance got corrupted due to some compaction I have done. I have got a new Jar and setup the code and its working perfectly fine with my existing code base. 

    Thanks for all your help and time 

 

Thanks

Veena

Feike_Visser1
Adobe Employee
Adobe Employee
November 7, 2016

Still I would use @Self in your case

Level 2
November 7, 2016

Sure Feike. I will refactor the code to use @self :) Thanks for pointing out to me :)

 

Thanks

Veena