{"id":47249,"date":"2017-05-31T14:32:31","date_gmt":"2017-05-31T09:02:31","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=47249"},"modified":"2017-06-01T15:16:20","modified_gmt":"2017-06-01T09:46:20","slug":"how-to-upgrade-existing-code-base-to-latest-aem-version","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-upgrade-existing-code-base-to-latest-aem-version\/","title":{"rendered":"How to Upgrade Existing Code Base to Latest AEM Version?"},"content":{"rendered":"<p style=\"text-align: justify\"><span style=\"font-weight: 400\"><a title=\"Adobe Experience Manager (AEM)\" href=\"http:\/\/www.tothenew.com\/wcm\/web-content-management-services\">Adobe Experience Manager (AEM)<\/a> is an Enterprise Web Content Management System which is used in high impact environments hosting voluminous pages and serving many users.It also involves integration with custom applications and customization of existing AEM features. Because of these complexities, the upgradations of AEM from one version to another one needs to be properly planned and executed. The reason to upgrade a stable system and deal its complexities and issues involved with it can be quite debatable. Nonetheless, one of the last things anyone would like is to have an unsupported site which could run into any issue, plus to be always using a legacy version of AEM whereas the world is going gaga over new features provided by the latest version. So <\/span><span style=\"font-weight: 400\">upgrading AEM is a basic requirement. Though <\/span><a href=\"https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/deploy\/upgrade\/planning.html\"><span style=\"font-weight: 400\">Adobe documentation<\/span><\/a><span style=\"font-weight: 400\"> covers how to upgrade, but making the code compatible with the latest version is not discussed and is often ignored.<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">Recently I was involved in planning and execution of an existing AEM 6.0 code base to AEM 6.2. The critical step was to make the code base ready to be deployed to an AEM 6.2 instance. So through a couple of blogs, I want to focus on how to do the code base upgrade and what challenges are encountered during this process. <\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">Here are the\u00a0steps which I followed:<\/span><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft wp-image-49031 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/image6.png\" alt=\"image6\" width=\"508\" height=\"578\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/image6.png 508w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/image6-263x300.png 263w\" sizes=\"(max-width: 508px) 100vw, 508px\" \/><\/p>\n<p style=\"text-align: justify\">The approach taken\u00a0in a nutshell is \u2018try to make the code compilable on the upgraded version, test the functionalities and then fix the deprecations.&#8217; Here is a quick explanation of these steps, including the tips which worked for me in executing it.<\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 1: Deploy the existing code on new AEM instance<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">The first step would be to build and deploy the existing code base for older AEM version to new AEM version. For example, if we use MAVEN as a build tool then we can run the command\u00a0<\/span><span style=\"background-color: #f5f6f5\">\u00a0\u2018<\/span><em style=\"background-color: #f5f6f5\">mvn clean install -PautoInstallPackage<\/em><span style=\"background-color: #f5f6f5\">\u2019 on the code base on the latest AEM version instance to deploy the code.\u00a0<\/span>If the build shows errors related to jars, which are incompatible then Step 2 would be required.<\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 2: Fix Incompatible Jars &amp; Try to Compile Codebase<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">We need the dependencies update in pom.xml to make the code compatible with the upgrade. First of all, check for the latest version in <\/span><a href=\"https:\/\/repo.adobe.com\/nexus\/content\/repositories\/public\/com\/\"><span style=\"font-weight: 400\">Adobe\u2019s Maven Repository<\/span><\/a><span style=\"font-weight: 400\"> and validate if the required version is present or not. However, sometimes it would be required to get the version used in AEM installer (primarily because Adobe\u2019s repository doesn\u2019t get updated frequently). <\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">So the trick is to retrieve it from AEM\u2019s OSGI console. <\/span><span style=\"font-weight: 400\">Go to OSGI bundles (<\/span><i><span style=\"font-weight: 400\">http:\/\/&lt;host&gt;:&lt;port&gt;\/system\/console\/bundles<\/span><\/i><span style=\"font-weight: 400\">) and search for the dependency name (say Jackrabbit JCR Commons). Click on the dependency and make a note of the bundle id, i.e. the first column (let\u2019s say it is 102).<\/span><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-48225 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/osgi_console-1024x475.png\" alt=\"osgi_console\" width=\"625\" height=\"289\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/osgi_console-1024x475.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/osgi_console-300x139.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/osgi_console-624x289.png 624w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/osgi_console.png 1999w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">Now go to the crx-repository on the file system <\/span><i><span style=\"font-weight: 400\">\u2026.\/crx-quickstart-&gt;launchpad-&gt;felix-&gt;bundle-&lt;id&gt; (bundle-102)<\/span><\/i><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-48222 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/bundle_info-1024x295.png\" alt=\"bundle_info\" width=\"625\" height=\"180\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/bundle_info-1024x295.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/bundle_info-300x86.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/bundle_info-624x180.png 624w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/bundle_info.png 1935w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">If there is a need to validate whether it is the same bundle, then one can check the bundle.info file present under same folder (<\/span><i><span style=\"font-weight: 400\">bundle-102<\/span><\/i><span style=\"font-weight: 400\">).<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">So the bundle.jar can be used and referenced as an external jar dependency.<\/span><\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 3: Deploy &amp; Test the build<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">This\u00a0step\u00a0ensures that the application runs and the functionalities work properly\u00a0<\/span>after successful build and deployment.<\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 4: Check for deprecations in code base for both Java &amp; JSP files\u00a0<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">This step is required to fix the code which is deprecated after the upgrade. Having such a\u00a0coding does not raise any issue as the product upgrade is backwards compatible. However, it is always recommended to remove the deprecations in the code base. To identify these deprecations, I used Eclipse compiler settings to generate errors for any usage of Deprecated API.<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">Go to \u2018<\/span><i><span style=\"font-weight: 400\">Preferences -&gt; Java -&gt; Compiler -&gt; Errors\/Warnings -&gt; Deprecated and restricted API section<\/span><\/i><span style=\"font-weight: 400\">\u2019 and set the level to ERROR (can be warning too, I just felt that identifying errors would be a bit easy to manage). After this change, code base will recompile, and each use of deprecated method or API would show up as an error\/warning in the \u2018Problems\u2019 view.<\/span><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-48221 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/deprecated_apis-1024x807.png\" alt=\"deprecated_apis\" width=\"625\" height=\"492\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/deprecated_apis-1024x807.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/deprecated_apis-300x236.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/deprecated_apis-624x491.png 624w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/deprecated_apis.png 1432w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p style=\"text-align: justify\">Now, if there is a requirement to copy the entire error list from Eclipse, go to Problems view, click on the View Menu (the triangle icon) and change the number of visible items under Preferences. (by default, it is 100). Even type of problems can be filtered under\u00a0<span style=\"background-color: #f5f6f5\">Configure Contents to restrict this list.<\/span><\/p>\n<p class=\"aligncenter\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-48223 size-large\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/eclipse_problems-1024x908.png\" alt=\"eclipse_problems\" width=\"625\" height=\"554\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/eclipse_problems-1024x908.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/eclipse_problems-300x266.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/eclipse_problems-624x553.png 624w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/eclipse_problems.png 1523w\" sizes=\"(max-width: 625px) 100vw, 625px\" \/><\/p>\n<p class=\"aligncenter\" style=\"text-align: justify\">STEP 5: Create List of Deprecations &amp; Provide Recommended Solution<\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">To keep a better track of all the deprecations and fixes, I have created a Master Sheet which consists of deprecations and suggested solutions. It helped me with work distribution among multiple developers working on the same code base.<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">I copied the errors from Eclipse\u2019s Problems console into .xls, sorted them by unique depreciations and provided recommended solutions for each and every deprecation, taking Adobe\u2019s documentation as reference.<\/span><\/p>\n<p class=\"aligncenter\" style=\"text-align: justify\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-48224 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/master_upgrade_sheet.png\" alt=\"master_upgrade_sheet\" width=\"1999\" height=\"947\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2017\/05\/master_upgrade_sheet.png 1999w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/master_upgrade_sheet-300x142.png 300w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/master_upgrade_sheet-1024x485.png 1024w, \/blog\/wp-ttn-blog\/uploads\/2017\/05\/master_upgrade_sheet-624x295.png 624w\" sizes=\"(max-width: 1999px) 100vw, 1999px\" \/><\/p>\n<p style=\"text-align: justify\">I referred to the following AEM documentation links:<\/p>\n<p style=\"text-align: justify\"><a href=\"https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/develop\/ref\/javadoc\/deprecated-list.html#package\"><span style=\"font-weight: 400\">https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/develop\/ref\/javadoc\/deprecated-list.html#package<\/span><\/a><\/p>\n<p style=\"text-align: justify\"><a href=\"https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/develop\/ref\/diff-previous\/changes.html\"><span style=\"font-weight: 400\">https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/develop\/ref\/diff-previous\/changes.html<\/span><\/a><\/p>\n<p style=\"text-align: justify\"><a href=\"https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/release-notes\/deprecated-removed-features.html\"><span style=\"font-weight: 400\">https:\/\/docs.adobe.com\/docs\/en\/aem\/6-2\/release-notes\/deprecated-removed-features.html<\/span><\/a><\/p>\n<p style=\"text-align: justify\">Respective links are available for other AEM versions too.<\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 6: Fix the Deprecations in Codebase<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">The approach followed was to fix the unique deprecations first. Usually, if it works in one functionality, then it should work in other use cases too. Mostly the repairs recommended by Adobe work but there can be scenarios where they fail. So either one needs to figure out a workaround or keep the deprecated code in place, until the identification of a new recommendation.<\/span><\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">STEP 7: Deploy &amp; Test the Build<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">This step is simply to ensure that after successful build and deployment, the application is running and the functionalities are working fine. As stated above, it is highly possible that the recommended fixes by Adobe wouldn\u2019t work for all the use cases implemented in any custom application. So a thorough testing of depreciation fixes is required.<\/span><\/p>\n<h3 style=\"text-align: justify\"><span style=\"font-weight: 400\">What&#8217;s missing?\u00a0<\/span><\/h3>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">This blog doesn\u2019t cover another critical step of how to make the code compatible with<span style=\"color: #000000\"> the front <\/span>end, where let\u2019s say, AEM\u2019s out of the box (OOTB) Javascript(js)\u00a0are overlaid and customized. In my project, we did not do this in the first upgrade release, primarily because of less time in hand. If time isn\u2019t a constraint, then a quick comparison of overlaid js\u00a0with latest AEM\u2019s OOTB js should also be made.<\/span><\/p>\n<p style=\"text-align: justify\"><span style=\"font-weight: 400\">In my next blog, I would cover the most common deprecations fixed in an upgrade from AEM 6.0 to 6.2, along with the use cases where the recommended depreciation fixes did not work. \u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adobe Experience Manager (AEM) is an Enterprise Web Content Management System which is used in high impact environments hosting voluminous pages and serving many users.It also involves integration with custom applications and customization of existing AEM features. Because of these complexities, the upgradations of AEM from one version to another one needs to be properly [&hellip;]<\/p>\n","protected":false},"author":993,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":5},"categories":[1],"tags":[4847,1813,4051],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/47249"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/993"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=47249"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/47249\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=47249"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=47249"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=47249"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}