Apache Sling javax.inject version error while building AEM Projects

If you encounter an issue where a sling bundle cannot be activated and in the “Installed” state due to a “javax.inject” version error, it can be taken care of by updating the AEM project’s core POM file .

javax.inject error in AEM when the sling project bundle cant be activated
javax.inject error in AEM when the sling project bundle cant be activated

Update the AEM project by adding the following under <configuration><instructions> </instructions> </configuration> node of the project’s core POM file:

<Import-Package>javax.inject;version=0.0.0,com.day.cq.replication;version=”[6.0.0,7)”,
org.apache.sling.event.jobs;version=”[1.5,2]”,
com.day.cq.workflow;version=”[1.0,2)”,
com.day.cq.workflow.exec;version=”[1.0,2)”,
com.day.cq.workflow.metadata;version=”[1.0,2)”,
org.apache.sling.models.annotations;version=”[1.1,2)”,
com.day.cq.commons.jcr;version=”[5.7.0,7.0.0)”,*</Import-Package>

Update the project by running Maven > Update Project prior to deploying it to your AEM Server.This will resolve any dependency issues with javax.inject” versioning in AEM.

Be First to Comment

Leave a Reply

Your email address will not be published.