July 23, 2020
Estimated Post Reading Time ~

How to add AEM Dependency that is missing from public repository

So you just updated to the nice and shiny AEM 6.1, looking at new functionality and exploring around. Then you decide to tap into the new api documentation. Then reality comes back in, the boss wants to connect a new product in to AEM 6.1. Too easy! I'll use a custom cloud configuration. Google to the rescue... Adobe documentation here I come. Oh no! The documentation is a CRXDE Lite tutorial.

Following the tutorial and testing it out, the screen explodes into a torrent of letters and characters...stack trace! Who would have thought...

Turns out ConfigurationManager is turned off by default for security reasons http://localhost:4502/system/console/configMgr/com.day.cq.wcm.webservicesupport.impl.ConfigurationManagerImpl. Well I could enable it then the tutorial would work, but those Adobe guys probably have good reason to disable it.

I found that it is possible to get a ConfigurationManager instance through the ConfigurationManagerFactory. Well, I could put this into the tutorial but who likes scriptlets not Center of Excellence, he wrote this article on how to avoid using scriptlets.

After some changes and making the cloud configuration conform to sightly and connect to a WCMUse backend.

Using depfinder http://localhost:4502/system/console/depfinder to make sure I have the correct dependency for ConfgurationManagerFactory. The package is com.day.cq.wcm.webservicesupport and version 5.8.44. Get everything set up and attempt to build the project to AEM.

No dice! Maven yelling at me!

Turns out the Adobe public repo is missing that version. The highest version at the time of this article was 5.6.4
So now What? 
I found this nice article about how to add jars to the local maven repository (.m2 folder)
Okay, so I know what to do but how do I get the jar?

How to get a jar from an AEM instance
  1. Go to http://localhost:4502/system/console/bundles
  2. Search for webservice, click Day Communique 5 WCM Webservice Support
  3. Notice Bundle Location copies the path after jcrinstall:
  4. Open CRXDE Lite and add the copied path. You should see the name of the jar inside that path
  5. Now that the location is confirmed. Go to the terminal and vlt down the jar. In my case this is what I used: 
vlt --credentials admin:admin co --force http://localhost:4502/crx/-/jcr:root/libs/wcm/webservice-support/install

How to add missing AEM Dependency
This will add the jar to the local maven repository
   6. Now that we have the jar, drill down to the jar and use the maven in the terminal to add it to your local repo. In my case this is what I used. 

mvn install:install-file -Dfile=cq-wcm-webservice-support-5.8.44.jar -DgroupId=com.day.cq.wcm \ -DartifactId=cq-wcm-webservice-support -Dversion=5.8.44 -Dpackaging=jar

Don't feel like dealing with the details: check out lazy mode toward the bottom of the page Rebuilding the project now worked.

Hopefully, this will be useful to you and now you know why you should not always rely on public repositories.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.