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>

Sunday 23 September 2018

Upgrade AEM 6.2 to AEM 6.4

AEM instance can be upgraded to 6.4 version in two ways.

  1. New AEM 6.4 setup
  2. In-place upgrade
Let's c In-place upgrade process.

In-place upgradation Process:

  1. Start you AEM 6.2 instance.
  2. Check all consoles are working fine.
  3. Remove all custom code and configs.
  4. Check “quickstart.properties” file is present under /crx-quickstart/conf. If not, copy from other instance and paste it in above location.
  5. Run offline compaction to reduce repository size. Check how to run offline compaction.
  6. Goto packageshare and download the package 

    pre-upgrade-package-cq62-1.2.zip


  7. Navigate to package manager and install the 

    pre-upgrade-package-cq62-1.2.zip

  8.  Once package is installed, navigate to OSGI Config Manager. Search for "preupgrade". Look for com.adobe.aem.upgrade.prechecks.mbean.impl.PreUpgradeTasksMBeanImpl.
Lets see what these are parameters do:
VersionPurge: This can be used to purge page versions.
GenerateBundlesListFileTask: List of bundles will be checked and placed in some path. This path can be found in your log.
DisableReplication: Disable replication agents
WorkflowPurgeTask:  Purge workflow. I not used while performing upgrade as I don’t have any workflow purge settings.
com.day.cq.audit.impl.AuditLogMaintenanceTask: Audit log in logger.
NOTE: If you run any task which you not configured then pre-upgrade task gets fail.
10.Once all necessary settings are added , open JMX console and select PreUpgradeTasks”.

11. Open error.log and check below entries in logs

23.09.2018 11:30:55.155 *INFO* [sling-threadpool-afcaa079-0115-490c-885f-2041bf40c356-(apache-sling-job-thread-pool)-1-Pre Upgrade Tasks Queue(com/adobe/aem/preupgrade/job/RunAllPreUpgradeTasks)] 
com.adobe.aem.upgrade.prechecks.tasks.impl.RunAllPreUpgradeTasksImpl com.day.cq.wcm.core.impl.VersionPurgeTask task finished running successfully.
...............................................................................................................................................................................
..............................................................................................................................................................................
23.09.2018 11:31:05.455 *INFO* [sling-threadpool-afcaa079-0115-490c-885f-2041bf40c356-(apache-sling-job-thread-pool)-1-Pre Upgrade Tasks Queue(com/adobe/aem/preupgrade/job/RunAllPreUpgradeTasks)] 
com.adobe.aem.upgrade.prechecks.tasks.impl.RunAllPreUpgradeTasksImpl WorkflowPurgeTask task finished running successfully.
...............................................................................................................................................................................
..............................................................................................................................................................................
23.09.2018 11:31:16.118 *INFO* [sling-threadpool-afcaa079-0115-490c-885f-2041bf40c356-(apache-sling-job-thread-pool)-1-Pre Upgrade Tasks Queue(com/adobe/aem/preupgrade/job/RunAllPreUpgradeTasks)] 
com.adobe.aem.upgrade.prechecks.tasks.impl.RunAllPreUpgradeTasksImpl GenerateBundlesListFileTask task finished running successfully.
...............................................................................................................................................................................
..............................................................................................................................................................................
23.09.2018 11:31:21.229 *INFO* [sling-threadpool-afcaa079-0115-490c-885f-2041bf40c356-(apache-sling-job-thread-pool)-1-Pre Upgrade Tasks Queue(com/adobe/aem/preupgrade/job/RunAllPreUpgradeTasks)] 
com.adobe.aem.upgrade.prechecks.tasks.impl.RunAllPreUpgradeTasksImpl DisableReplicationAgentsTask task finished running successfully.
...............................................................................................................................................................................
..............................................................................................................................................................................
23.09.2018 11:31:21.229 *ERROR* [sling-threadpool-afcaa079-0115-490c-885f-2041bf40c356-(apache-sling-job-thread-pool)-1-Pre Upgrade Tasks Queue(com/adobe/aem/preupgrade/job/RunAllPreUpgradeTasks)] 
com.adobe.aem.upgrade.prechecks.tasks.impl.RunAllPreUpgradeTasksImpl RunAllPreUpgradeTasks task finished running successfully.
12. Stop AEM 6.2 server and remove files under crx-quickstart/launchpad/installer.
13. Place your AEM 6.4 jar on the same place where AEM 6.2.jar placed.
14. Run the below command:
D:\CQ5\CQ5\AEM6.2>java -Xmx4096m -jar AEM_6.4_Quickstart.jar -unpack
Once done successfully we will be getting below message
Quickstart files unpacked, server startup scripts can be found under //crx-quickstart/bin

15. Run below command to change repository to segment tar. 

D:\CQ5\CQ5\AEM6.2>java -Xmx4096m -jar AEM_6.4_Quickstart.jar -v -x 
crx2oak -xargs - -load-profile segment-no-ds

23.09.2018 12:17:34.203 INFO c.a.g.c.e.MigrationRunner: migration completed

 __   __         __        ___ ___  ___  __

/  ` /  \  |\/| |__) |    |__   |  |__  |  \

\__, \__/  |  | |    |___ |___  |  |___ |__/

16. Start AEM 6.4.
17. It starts new segment tar repository and also perform re-indexing. Grab some coffee and wait till you see the below message in log.

org.apache.jackrabbit.oak.plugins.index.IndexUpdate Reindexing completed

18. Navigate to product information console to see the product version.