<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhijeetkumar Ak on Medium]]></title>
        <description><![CDATA[Stories by Abhijeetkumar Ak on Medium]]></description>
        <link>https://medium.com/@abhijeetkumar.ak47?source=rss-c16dd55ba0c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kVsv5af6fTWniRihxJRImg.jpeg</url>
            <title>Stories by Abhijeetkumar Ak on Medium</title>
            <link>https://medium.com/@abhijeetkumar.ak47?source=rss-c16dd55ba0c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:50:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhijeetkumar.ak47/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why Some SVGs Sync to Dynamic Media and Others Don’t]]></title>
            <link>https://medium.com/@abhijeetkumar.ak47/why-some-svgs-sync-to-dynamic-media-and-others-dont-dca8aca0c595?source=rss-c16dd55ba0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dca8aca0c595</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[aemaacs]]></category>
            <category><![CDATA[aem-features]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[dynamicmedia]]></category>
            <dc:creator><![CDATA[Abhijeetkumar Ak]]></dc:creator>
            <pubDate>Thu, 03 Sep 2026 11:40:15 GMT</pubDate>
            <atom:updated>2026-09-03T11:51:50.563Z</atom:updated>
            <content:encoded><![CDATA[<p>A 1,197 asset failure that AEM never told us about</p><p>Two SVG logos sat in the same DAM folder. Same uploader. Uploaded within the same second, in the same batch, exported from the same version of Illustrator.</p><p>Two SVG logos were uploaded in the same folder and processed in same batch yet the issue appears</p><p>One SVG delivered from Dynamic Media while the other didn’t exist there at all returning a content path . absolutely making head scratch.</p><p>No asset showed a single error in the AEM authoring UI. Both reported dam:assetState: processed. Both SVGs looked completely fine in the Assets console.</p><p>Post reprocessing i will see the error on the asset is Process failed</p><figure><img alt="SVG processing failed" src="https://cdn-images-1.medium.com/max/1024/1*SU4VLwzT63e8dQ1wWWSXXg.png" /></figure><p>By the time I finished, 1,197 SVGs across the instance turned out to be in the same broken state — and the reason had nothing to do with file size, upload batch, or Dynamic Media configuration.</p><h3>The symptom</h3><p>The trigger was mundane: an audit to confirm every asset that <em>should</em> be in Dynamic Media actually was. Raster formats came back clean. SVGs came back inconsistent in a way that looked random.</p><p>Well random is almost never random. But finding the pattern required looking somewhere the UI doesn’t take you.</p><h3>The failure is silent, and that’s the real problem</h3><p>Here is the part worth internalizing even if you never touch an SVG.</p><p>When a Dynamic Media upload fails, AEM does <strong>not</strong> change dam:assetState. The asset still reads processed. The Assets console shows a normal thumbnail. Nothing is flagged, nothing is queued for retry, no notification fires.</p><p>The only evidence is a property most people never look at:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3QKTVedV3Zcb4wRrppW1A.png" /><figcaption>Asset processed and scene7Failure</figcaption></figure><pre>jcr:content/dam:scene7Failure</pre><p>Its value on all 1,197 assets was identical:</p><pre>&lt;path&gt; was not processed because of an upload error.<br>;Invalid href/xlink references in SVG. Only DM URLs are supported.</pre><p>One error message. 1197 assets. Zero visibility.</p><p>Look at what surrounds that failure on the same node:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x3QKTVedV3Zcb4wRrppW1A.png" /><figcaption>Asset processed and scene7Failure</figcaption></figure><p><em>Nine rows apart on the same node: </em><em>processed, and the error explaining that it wasn&#39;t.</em></p><p>Three things worth pulling out:</p><ul><li><strong>dam:runDMProcess: true</strong> — Dynamic Media processing was requested and did run. This asset didn&#39;t slip past the pipeline; it entered, was rejected, and the rejection was recorded nowhere anyone looks.</li><li><strong>dam:processingAttempts: 1</strong> — one attempt, no retry. Nothing in AEM treats this as recoverable.</li><li><strong>dam:processingRenditions</strong> — thumbnails and cq5dam.web.1280.1280.jpeg all generated successfully. Standard DAM processing worked perfectly. Only the DM upload failed, which is precisely why the console looks healthy.</li></ul><p>To find them yourself, run this in Query Builder (/libs/cq/search/content/querydebug.html):</p><pre>path=/content/dam<br>type=dam:Asset<br>property=jcr:content/dam:scene7Failure<br>property.operation=exists<br>property.value=true<br>p.limit=-1<br>p.hits=selective<br>p.properties=jcr:path jcr:content/metadata/dc:format jcr:content/metadata/dam:scene7FileStatus jcr:content/dam:scene7Failure<br>p.guessTotal=true</pre><p>If that returns anything, you have DM ingestion failures nobody has been told about.</p><h3>What we ruled out first</h3><p>Before landing on the answer, we killed the obvious candidates. This matters, because each one is the explanation someone will confidently offer you in a stand-up.</p><h4>Some of the hypothesis which i made and what went wrong in that:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KedeCzGiK6xZlUS6gmdMWQ.png" /><figcaption>Hypothesis to validate befiore putting to team</figcaption></figure><h3>The actual issue</h3><p>After trying multiple things tried to randomly opened the image as a text. Guess what they all share one thing:</p><pre>&lt;image width=&quot;240&quot; height=&quot;80&quot;<br>  xlink:href=&quot;data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...&quot; /&gt;</pre><p><strong>An embedded base64 raster image.</strong></p><p>That’s the whole answer. Dynamic Media Image Serving accepts SVG as source data, and it permits images <em>inside</em> SVG via the &lt;image&gt; element — but with a hard constraint. The xlink:href attribute must resolve to a valid Image Serving request. Foreign URLs aren&#39;t allowed.</p><p>A data:image/png;base64,… URI is neither a valid Image Serving request nor a permitted URL. Scene7 rejects the file at upload, before any processing happens.</p><p>The correlation in our test folder was exact:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eCAcEvPS8_d9dc-wPJ_ZNQ.png" /><figcaption>SVGs failure</figcaption></figure><p>100% and 100%. No overlap, no exceptions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZlyVh7NVbyOtXomdft8MSw.png" /><figcaption>3.3 KB SVG successfully processed</figcaption></figure><p><em>The right-hand panel is the one to keep. The smallest failing file was smaller than everything that succeeded, below:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BWsnDCveR9WOMlnw7Rzclg.png" /><figcaption>Small 3 KB image getting processed as it is not Base64 rasterised.</figcaption></figure><p>Adobe documents the constraint in the <a href="https://experienceleague.adobe.com/en/docs/dynamic-media-developer-resources/image-serving-api/image-serving-api/http-protocol-reference/syntax-and-features/r-svg-support">Image Serving API SVG support</a> reference. It’s accurate — it just doesn’t connect to anything in the AEM UI, so nobody reads it until after the fact.</p><h3>The twist: these were never really vector files</h3><p>The construction pattern behind the failures turned out to be consistent, and it reframes the whole problem.</p><p>Somebody received a partner logo as a bitmap, pasted it into Illustrator, and exported SVG. The resulting file has a path count of about three — just the in-house wordmark, which <em>was</em> vector. The partner’s mark is a base64 PNG riding inside an SVG wrapper.</p><p>So these files gave up the benefits of vector before Dynamic Media ever saw them:</p><ul><li><strong>No scaling advantage.</strong> The embedded bitmap pixelates exactly like any raster image.</li><li><strong>Serious bloat.</strong> Median failing file: <strong>37 KB</strong>, against <strong>12 KB</strong> for the genuine vector files in the same folder. 65 files exceeded 100 KB. Two exceeded 1 MB — the worst was <strong>1.46 MB</strong>, for a logo.</li></ul><p>Those were shipping to every homepage visitor. The DM sync failure was arguably the least expensive symptom.</p><h3>Why “just fix the sync” is the wrong instinct</h3><p>This is where the investigation changed direction, and it’s the part I’d most want a person to sit with.</p><p>The moment when you find 1,197 failed ,instinc is to make them succeed. Re-upload, re-sync, clear the backlog. But look at what Dynamic Media actually does with SVG:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mMPHhKHihLfn0LMTV8h9EQ.png" /></figure><p>Routing SVG through /is/image <strong>discards the vector advantage</strong>, because DM rasterizes it on the way out. A successful sync would hand you a rasterized copy of an already-rasterized logo. Two lossy steps instead of one, and still no Smart Crop, still no dynamic renditions.</p><p>For logos, delivering SVG straight from AEM is simply the better outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*swt2ueIIKMBLC-jdEOJ4eg.png" /></figure><p><em>Both branches end somewhere unsatisfying — which is the argument for keeping SVG out of Dynamic Media altogether.</em></p><p>Which means the right fix isn’t technical at all. It’s a policy decision: <strong>exclude SVG from Dynamic Media entirely.</strong> That single call converts 1,197 failures into a documented exclusion and closes the backlog without touching a single asset.</p><p>The artwork problem is real and worth fixing — request true vector from partners, or convert to PNG/WebP where that isn’t realistic, since DM handles those properly. But that’s an artwork problem, not a Dynamic Media problem, and conflating the two is what keeps the ticket open for months.</p><h3>Quick Tip: A Query Builder trap, while you’re in here</h3><p>Worth its own warning, because it will quietly hand you a wrong answer.</p><p>Do <strong>not</strong> use property.operation=exists with property.value=false scoped at /content/dam:</p><pre># DON&#39;T DO THIS at /content/dam scope<br>property=jcr:content/metadata/dam:scene7File<br>property.operation=exists<br>property.value=false</pre><p>That predicate can’t be served from the damAssetLucene index. Oak falls back to traversal and <strong>silently truncates</strong>. In our case it returned 24 hits. The true figure was 5,418.</p><p>It doesn’t error. It doesn’t warn. It returns a plausible-looking number that is wrong by two orders of magnitude — and if you’re building an audit on top of it, you’ll report that number to stakeholders.</p><p>Two ways around it:</p><ul><li>Scope exists=false queries to one top-level folder at a time, or</li><li>Prefer the exists=true form, which is index-backed and safe at any scope</li></ul><p>And always set p.guessTotal=true. Without it, total just echoes p.limit back at you.</p><h3>What to take away</h3><ol><li><strong>Dynamic Media ingestion fails silently.</strong> dam:assetState will lie to you. dam:scene7Failure is the property that tells the truth — audit it periodically.</li><li><strong>When failures look random, find the discriminator before theorizing.</strong> Diff a file that worked against one that didn’t. The answer was in plain text inside the files the entire time.</li><li><strong>“Make the error go away” isn’t the same as “fix the problem.”</strong> DM rasterizes SVG. Succeeding at that sync would have gained nothing.</li><li><strong>Check whether your published pages reference these assets</strong> via /is/image or /is/content. If they do, those logos are currently broken or falling back in production — and that&#39;s the part your users can see.</li></ol><p><em>If you’ve hit the inverse problem — assets that appear in Dynamic Media when you’re certain nothing was published there — that’s usually Web-Optimized Image Delivery wearing a </em><em>/adobe/dynamicmedia/deliver/ URL that only looks like Dynamic Media. Different post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dca8aca0c595" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Non-AEM Web Apps with AEM as a cloud Service]]></title>
            <link>https://medium.com/@abhijeetkumar.ak47/real-world-challenges-of-integrating-non-aem-web-apps-with-aem-6678c8549d99?source=rss-c16dd55ba0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6678c8549d99</guid>
            <category><![CDATA[aemasacloudservice]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[adobe]]></category>
            <dc:creator><![CDATA[Abhijeetkumar Ak]]></dc:creator>
            <pubDate>Sun, 19 Jan 2025 10:55:50 GMT</pubDate>
            <atom:updated>2025-01-22T08:26:11.662Z</atom:updated>
            <content:encoded><![CDATA[<p>In my recent AEM development project, I faced the challenge of integrating a non-AEM web application with AEM to both save and retrieve data. This kind of integration is often tricky, with several hurdles to overcome.</p><p>In this article, I’ll walk through the key challenges I encountered and the solutions that helped streamline the process.</p><h3><strong>Connect to AEM as a cloud service.</strong></h3><p>With AEM as a cloud service the integration have changed . To integrate we do need to have access to developer console.</p><h3>Simplified Steps:</h3><ol><li><strong>Go to Environments Overview</strong><br> Navigate to the <strong>Environments Overview</strong> page in AEM. This dashboard lets you manage environments, integrations, and more.</li><li><strong>Open the Menu</strong><br> Click the three dots (ellipsis) in the top-right corner to open a dropdown menu.</li><li><strong>Select Developer Console</strong><br> From the dropdown, choose <strong>Developer Console</strong>. This is where you manage integrations and technical accounts.</li><li><strong>Access Integrations</strong><br> In the Developer Console, locate the <strong>Integrations</strong> section to find or create technical accounts.</li><li><strong>Choose or Create a Technical Account</strong></li></ol><ul><li>If a technical account exists, select it.</li><li>If not, and you have admin permissions, click <strong>Create New Technical Account</strong> to set up a new one.</li></ul><p><strong>Pro Tip:</strong> If you don’t have admin access, you’ll need to ask your AEM admin for help. Creating a technical account usually requires some elevated permissions, so don’t hesitate to reach out to them!</p><h3><strong>Generate access token</strong></h3><p>To gain access to AEM, we do need an access token or what we called as Bearer Authentication token , which we need to pass as a header while making the call.</p><p>To generate access token i did follow several steps, which will be there in separate blog, for now reference this <a href="https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/implementing/developing/generating-access-tokens-for-server-side-apis">article </a>from adobe.</p><h3>Testing Your server</h3><p>Before proceeding to the development, you would like to test the functionality of your application locally or by making an API call. For that we don’t need to pass or generate access token. We can simply generate a local token from AEM developer console -&gt; integrations and pass it as a header in POSTMAN API call. I had tested my server working by following the same way.</p><p>Now that you have tested your API call, you can make the same call in node module or in JS file(i made ajax call). You would expect that the operation works smoothly. but wait here comes the AEM security features in picture and your request goes into errors as i mentioned below.</p><p><strong>Problems i encountered</strong></p><ol><li>CORS Error.</li><li>CSRF Filter blocking the servlet path.</li><li>Sling referrer filter blocking the call.</li></ol><p><strong>How to resolve CORS error in AEM</strong></p><p>when i made API call from the browser , in console i got to see CORS error in below format</p><pre>Access to image at &#39;https://example.com/image.jpg&#39; from origin &#39;http://yourdomain.com&#39; has been blocked by CORS policy: No &#39;Access-Control-Allow-Origin&#39; header is present on the requested resource.</pre><figure><img alt="Allow web app url in CORS filter" src="https://cdn-images-1.medium.com/max/1024/1*nFgcoK2xIMnvMLVBV7ZzVQ.png" /></figure><p>For AEM as a cloud service we need to make a new OSGi config in config.author folder.</p><blockquote>here path is ui.config\src\main\content\jcr_root\apps\wknd\osgiconfig\config.author\com.adobe.granite.cors.impl.CORSPolicyImpl~wknd.cfg.json</blockquote><p>I added web app url as a variable in the config as in image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7AZpNathsFMFYph1QQZ45A.png" /><figcaption>OSGi config created for CORS</figcaption></figure><h4>Additional Tip: Resolving CORS Issues with CSRF Token Header</h4><p>If you encounter a CORS error in the browser console stating that the csrf-token header is not allowed, you can resolve it by adding the required headers to the CORS policy configuration.</p><p>Here’s how to configure it in AEM:</p><ol><li><strong>Locate the Configuration File</strong><br>Update the file:<br>com.adobe.granite.cors.impl.CORSPolicyImpl~wknd.cfg.json.</li></ol><p><strong>2. Add Allowed Headers</strong><br> Include the csrf-token header in the allowedheaders property.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F6t8vO_qdk1NZNgBkOPITA.png" /><figcaption>Add csrf-token in exposed headers of CORS Policy</figcaption></figure><p>Post this CORS issue was gone, and we were able to hit the url. But we ended up in second blocker which is</p><p><strong>CSRF Filter blocking the servlet path</strong></p><p>Being new to integration , i was unaware of this config. So, what happens is when we hit the servlet from external system AEM does block the POST method by default as AEM takes it as an compromise to security. To ensure we are able to hit the servlet path with POST method outside AEM, it is required to explicitly allow the servlet path in CSRF Filter config.</p><p>Solution: Navigate to OSGi console→ CSRF filter configuration(/system/console/configMgr → Adobe Granite CSRF Filter).</p><figure><img alt="Allow servlet path in OSGi config -&gt; Adobe Granite CSRF Filter" src="https://cdn-images-1.medium.com/max/1024/1*M2-2-FLenaAXq7BGsQf8cw.png" /></figure><p>As mentioned above, for AEM as a cloud service we again need to put OSGi config in config.author which does allow servlet path.</p><p>Config path -&gt; ui.config\src\main\content\jcr_root\apps\wknd\osgiconfig\config.author\com.adobe.granite.csrf.impl.CSRFFilter.cfg.json</p><figure><img alt="OSGi config created for CSRF filter allowing servlet path to make POST call." src="https://cdn-images-1.medium.com/max/1024/1*40NGhBzpFI29gpmOP5ecew.png" /><figcaption>OSGi config created for CSRF filter allowing servlet path to make POST call.</figcaption></figure><blockquote>Note: Whenever we create a config which is present by default in AEM. We do override the existing properties.</blockquote><blockquote>Notice above filter.excluded.paths — I added all paths along with OOTB one.</blockquote><h3>Additional Tip: Resolving CORS Issues with CSRF Token Header</h3><p>If you encounter a CORS error in the browser console stating that the csrf-token header is not allowed, you can resolve it by adding the required headers to the CORS policy configuration.</p><p>Here’s how to configure it in AEM:</p><ol><li><strong>Locate the Configuration File</strong><br>Update the file:<br>com.adobe.granite.cors.impl.CORSPolicyImpl~wknd.cfg.json.</li></ol><p><strong>2. Add Allowed Headers</strong><br> Include the csrf-token header in the allowedheaders property.</p><p><strong>Sling Referrer filter blocking POST request</strong></p><p>After we configure the CSRF filter we expect the request to go and functionality to work smooth, but wait…..new Surprise !! we still get 403 or forbidden in the network response.</p><p>org.apache.sling.security.impl.ReferrerFilter is the culprit behind this</p><blockquote>The logs says POST is blocked from ‘https://website.net’.</blockquote><p>To enable this we need to include application/host url in the allowed hosts at OSGi config -&gt; config.author to allow the given host in org.apache.sling.security.impl.ReferrerFilter as below.<br>Do allow it in format of <strong>$[env:WEBAPP_URL]:443.</strong></p><figure><img alt="provided webapp url in allow.hosts for org.apache.sling.security.impl.ReferrerFilter" src="https://cdn-images-1.medium.com/max/1024/1*T6gCu8qtj0je7Bx6xbt7gQ.png" /></figure><p>As usual, for AEM as a cloud service we again need to put OSGi config in config.author which does allow servlet path.</p><blockquote>Config path -&gt; ui.config\src\main\content\jcr_root\apps\wknd\osgiconfig\config.author\org.apache.sling.security.impl.ReferrerFilter.cfg.json.</blockquote><p>After we complete all these we should be good to make a POST call from our hosted application to AEM servlet to retrieve/save the data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6678c8549d99" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Add Third Party Jar in AEM]]></title>
            <link>https://medium.com/@abhijeetkumar.ak47/add-third-party-jar-in-aem-a3ae9c749f10?source=rss-c16dd55ba0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3ae9c749f10</guid>
            <category><![CDATA[third-party]]></category>
            <category><![CDATA[aemasacloudservice]]></category>
            <category><![CDATA[aem-developer]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[jar]]></category>
            <dc:creator><![CDATA[Abhijeetkumar Ak]]></dc:creator>
            <pubDate>Fri, 10 Jan 2025 09:53:25 GMT</pubDate>
            <atom:updated>2025-01-19T10:37:09.987Z</atom:updated>
            <content:encoded><![CDATA[<p>While developing a component/ services in AEM, we often come across requirements which do require us to add extra dependency in module to get the work done.</p><p>We generally do add those dependencies in core/pom.xml.</p><pre>&lt;!-- https://mvnrepository.com/artifact/org.jsoup/jsoup --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.jsoup&lt;/groupId&gt;<br>    &lt;artifactId&gt;jsoup&lt;/artifactId&gt;<br>    &lt;version&gt;1.18.2&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>But even after adding those dependency we get error post building the bundle. The Bundle stays in installed state. We do get error like the bundle` is not resolved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*CNFQc0eZ_98tjAzvAqW9Ow.png" /><figcaption>JSoup not getting resolved</figcaption></figure><h3>JSOUP not getting resolved in AEM. Why?</h3><p>Often wonders why we see error like this. The underlying reason is AEM does not include JSOUP in<em> AEM runtime</em> by default. What happens is when we add some dependency in pom.xml, the build looks for the bundles which is exporting those jar files within AEM . if it fails to find out bundle exporting the said bundle it does gives the error as<strong> </strong><strong>jsoup.jar not getting resolved. </strong>Some other dependency like<a href="https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core/2.18.2"> jackson-core</a> can be included in project directly by simply adding dependency in pom.xml because it is included in AEM runtime.</p><p>Wondering what is Adobe runtime?</p><p>Adobe Runtime refers to the pre-installed JAR files that come bundled with AEM. These runtime JARs provide libraries and services required for AEM tofunction along with commonly used jars.</p><p>In an AEM instance, you can find these JAR files located at:<br>/crx-quickstart/launchpad</p><pre>&lt;!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;<br>    &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;<br>    &lt;version&gt;2.18.2&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p><strong>How to include JSoup or third party jar in AEM ?</strong></p><p>As mentioned above, <em>AEM runtime</em> does not include JSoup jar by default. So if we need to use Jsoup in an AEM Project we need to explicitly add it from a different Maven repository in all/pom.xml.</p><p>To do so we need to embed jsoup as a dependency in all/pom.xml as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*kN0mgP8-530HJJsBte_g5Q.png" /><figcaption>Embed JSoup in all/pom.xml</figcaption></figure><p>Also add JSoup dependency in all/pom.xml so that it is visible and get deployed in the AEM project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f2CwtyAhDaz6x72Ym5npKw.png" /><figcaption>Add JSoup dependency in all/pom.xml.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hN4IBso3F85MvxYEOrcifg.png" /><figcaption>JSoup is added as a jar in AEM bundles console.</figcaption></figure><p>Now Post doing above operation we shall be good to use jsoup in the project.</p><p>We can do same steps for any third party jars which gives xxx-xx.jar or <em>io-jsonwebtoken</em> not getting resolved.</p><p>Conclusion</p><p>Some of the jars, maven dependencies are not available in adobe runtime , so we need to include those package in all/pom.xml as embed and also add it as dependency in the same pom file.</p><p>Voila ! You have learned how to integrate 3rd party jar in AEM project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3ae9c749f10" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Reference annotation in AEM? Deep Dive: How It Works]]></title>
            <link>https://medium.com/@abhijeetkumar.ak47/what-is-reference-annotation-in-aem-deep-dive-how-it-works-2004c2b11ac2?source=rss-c16dd55ba0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2004c2b11ac2</guid>
            <category><![CDATA[ideas]]></category>
            <category><![CDATA[sling]]></category>
            <category><![CDATA[annotations]]></category>
            <category><![CDATA[osgi]]></category>
            <category><![CDATA[aem]]></category>
            <dc:creator><![CDATA[Abhijeetkumar Ak]]></dc:creator>
            <pubDate>Wed, 25 Sep 2024 09:29:38 GMT</pubDate>
            <atom:updated>2024-09-25T20:14:50.843Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a fundamental concept in software development called Dependency injection, it does allow components to be decoupled and work independently. In <strong>Adobe Experience Manager </strong>, which is built on top of <strong>Sling and OSGi</strong>, dependency injection is handled by the OSGi container(s).OSGi container makes sure that multiple services or components interact with each other seamlessly. It does handles the instantiation of services and their lifecycle</p><p><strong>Dependency Handling in AEM</strong></p><blockquote>In AEM dependency injection is handled by using @reference annotations. So when we use reference annotations in AEM, we are calling the default constructor of the service. which, in turn returns the object of the instance which is already present in Bundle context.</blockquote><pre>@Component(<br>    service = Servlet.class,<br>    property = {<br>        &quot;sling.servlet.paths=/bin/test&quot;<br>    }<br>)<br>public class TestServlet extends SlingAllMethodsServlet {<br><br>    @Reference<br>    private ExistingService myService;<br><br>    @Override<br>    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException {<br>        myService.doProcess();<br>        LOGGER.info(&quot;Processed myService&quot;);<br>    }<br>}</pre><p><strong>What happens when we create a component in AEM?</strong></p><p>When a service is registered in OSGi using component or service annotations, it is registered as a singleton instance in bundle context. This is because OSGi operates on a service registry model where only one instance of the service is created and shared among all the components that reference it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3a_9dETYKJeS-AoI-rRmfw.png" /><figcaption>Snippet from OSGi release docs.</figcaption></figure><p>whenever we use @Reference annotation to inject a service in our services, we typically get the same instance of that service across the components which are using . The @Reference annotation can only be used in a class that is annotated with @Component. That is, only a Declarative Services component can use @Reference to bind to an OSGi service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3JLyVzDPpxwH2arNB6MFxw.png" /><figcaption>Resource Resolver being instantiated at class level</figcaption></figure><p>So usually when we create a object of a session or Resolver outside method i.e. on class level in services, <em>we do get a code severity that the instantiation is not thread safe</em>. Since this same resolver is already existing and might be used by other services referencing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nY4-KWZFhv4fonxY_8WyfA.png" /><figcaption>service information. source : <a href="https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.servicereferences">https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.servicereferences</a></figcaption></figure><p>When we do create/instantiate resolver here, suppose this resolver do have write access while the other service referencing it does not need to have write permission. In this case it will create a security issue as other service might commit some changes to the repo which is unwanted given the scenario.<br>Same goes with session, as other service using it can commit something to session which will create conflicts. Instead, create the objects within method scopes.<br>For other type of scope provided in AEM look <a href="https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.scope">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*xNFAM_jOY6CIX54Bo8UbhQ.png" /><figcaption>Diagram describing bundle flow source : <a href="https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#d0e11621">https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#d0e11621</a></figcaption></figure><p>Described above scenario to support the statement that the service instantiation is singleton in AEM. When we use reference in service, we are just getting the already existing object of service, rather than creating a new object of service.</p><p>This makes service management efficient and reduces memory overhead. However, OSGi also provides mechanisms like prototype scope if you need multiple instances of a service for specific cases.</p><p>Resource : <a href="https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.servicereferences">https://docs.osgi.org/specification/osgi.core/8.0.0/framework.service.html#framework.service.servicereferences</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2004c2b11ac2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Difference between Inject and ValueMapValue]]></title>
            <link>https://medium.com/@abhijeetkumar.ak47/difference-between-inject-and-valuemapvalue-ac15fb45b46c?source=rss-c16dd55ba0c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac15fb45b46c</guid>
            <category><![CDATA[aemaacs]]></category>
            <category><![CDATA[sling]]></category>
            <category><![CDATA[aem-tutorial]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[aem-training]]></category>
            <dc:creator><![CDATA[Abhijeetkumar Ak]]></dc:creator>
            <pubDate>Tue, 16 Apr 2024 12:53:38 GMT</pubDate>
            <atom:updated>2024-04-16T12:53:38.548Z</atom:updated>
            <content:encoded><![CDATA[<p>Many a times when we develop a sling model in AEM we come across a point where we decide what annotation to be used for Value mapping.<br>We many a times use @inject annotation. and somewhere we see @ValueMapValue being used. So which one is correct, and how does it affects performance in AEM page. Lets find out.</p><p><strong>@Inject</strong></p><p>Inject works normally as we see in case of spring framework, where @Inject is used to inject the required dependency for the code.<br>In AEM it also does the same, but here it face conflict because in AEM, we do have multiple injectors. So, here Sling bundle iterates over the injectors and inject whichever it matches first as you can see in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*sQfxdad8kiSXd68-NErmLw.png" /></figure><p>@<strong>ValueMapValue</strong></p><p>It is a specific injector which does only value mapping and not any other heavy lifting injection in the model. It does injection of the values from the node/resource which is being used.</p><p><strong>Problem:<br></strong>The major problem occurs when you have two injections with the same name, Let’s assume we have a multifield with field ‘players’. and one more dropdown with name ‘players’. So here the injector( @Inject ) will get confused which one to map with multifield and which one with select value. It will simply inject the value which comes up first, in this case ‘valuemap’ and not with multifield.<br>The iteration is time consuming, thereby slows the model performance.</p><p>So it is recommended to use specific injection annotation i.e injectors while writing a sling model.</p><figure><img alt="List of sling injectors available" src="https://cdn-images-1.medium.com/max/623/1*sQfxdad8kiSXd68-NErmLw.png" /></figure><p>Note: This is my personal opinion. Please feel free to point out if something is not here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac15fb45b46c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>