Unable to import annotations package
I am trying to write data to a JCR node from a custom form component in AEM 6.4.2, slightly following this tutorial: Adobe Experience Manager Help | Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver meth…
In order to write data to the JCR, I need to obtain a Session object which I can get through a ResourceResolverFactory object that's declared with an @Reference annotation. To use the @Reference annotation, I need to import org.apache.felix.scr.annotations.Reference in my Java code. I've included the dependencies listed in the tutorial in my parent/pom.xml file and rebuilt the project with the following maven command:
mvn clean install -PautoInstallAllPackage
Despite including and building those dependencies, I get this error in my Java file:
Caused by: org.apache.sling.scripting.sightly.SightlyException: Compilation errors in apps/project/components/content/foo/Foo.java:
Line 28, column 846 : Only a type can be imported. org.apache.felix.scr.annotations.Reference resolves to a package
What could be causing this problem? Is there a way to verify that the dependencies are installed on the system? I also tried using the newer OSGi R7 annotations instead of the older Felix ones and I run into the same issue. Can someone help me resolve this issue? Thanks.