Monday 29 October 2018

Annotation @reference is disallowed for this location

Issue: 
Annotation @reference is disallowed for this location.

Solution: 
There are multiple ways to use @Reference annotations in OSGi annotations.

Option 1: 
@Reference
MyService myService;

Option 2:
private MyService myService;
@Reference
public void bindMyService(MyService myService) {
     this.myService = myService;
}
public void unbindMyService(MyService myService) {
     this.myService = myService;
}

To avoid this error use option 2.

Saturday 27 October 2018

Plugin org.apache.maven.plugins:maven-dependency-plugin:2.10 or one of its dependencies could not be resolved

I tried to create AEM 6.4 project using maven archetype 10. When tried to build the project got below error.

Error:
[ERROR] Plugin org.apache.maven.plugins:maven-dependency-plugin:2.10 or one of its dependencies could not be resolved:
 Failed to read artifact descriptor for org.apache.maven.plugins:maven-dependency-plugin:jar:2.10: 
 Could not transfer artifact org.apache.maven.plugins:maven-dependency-plugin:pom:2.10 from/to central 
 ( https://repo.maven.apache.org/maven2): Access denied to: https://repo.maven.apac he.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.10/maven-depend ency-plugin-2.10.pom , ReasonPhrase:Forbidden. -> [Help 1]

Solution:

Check if you can download the jar from browser http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar.

If you are able to download the jar then your browser has connectivity to central but maven doesn't. So try using a proxy in settings.xml









If above didn't work try to build using command
mvn clean install -s



Saturday 6 October 2018

com.adobe.cq.sightly,version=[2.5,3) -- Cannot be resolved

If you are migrating to AEM 6.3/AEM 6.4 then you may face the below issue

com.adobe.cq.sightly,version=[2.5,3) -- Cannot be resolved

Solution:

Add correct uber-jar version in pom.xml
<dependency>
<groupId>com.adobe.aem</groupId> <artifactId>uber-jar</artifactId> <version>6.4.0</version> <classifier>apis</classifier> <scope>provided</scope> </dependency>

If still issue exists, then add below in import package
<Import-Package>com.adobe.cq.sightly;version=2.5.3,*</Import-Package>