2

Is there any other work around to fix the javax.inject,version=[0.0,1) -- Cannot be resolved issue in OSGI bundle

I have tried all the approaches provided in the below forum. but still my bundle doesn't resolve.

I am using AEM 6.2 + Java version: 1.8.0_121 + Apache Maven 3.3.9 and archetypeVersion=10

And my code can be found at my GDrive

http://help-forums.adobe.com/content/adobeforums/en/experience-manager-forum/adobe-experience-manager.topic.html/forum__fikl-ive_just_updatedfro.html

Javax inject

VAr
  • 2,551
  • 1
  • 27
  • 40
  • What does your AEM instance show in Package Dependencies (http://localhost:4502/system/console/depfinder) for javax.inject? – Imran Saeed Apr 10 '17 at 10:24
  • 1
    @i.net it is ` org.apache.geronimo.specs geronimo-atinject_1.0_spec 1.0 provided ` – VAr Apr 10 '17 at 14:20

2 Answers2

6

In core pom.xml file add Import-Package tag for "javax.inject" with "version=0.0.0,*" inside "org.apache.felix" plugin tag like below [Tested on AEM 6.2 working perfect]

<plugin>
  <groupId>org.apache.felix</groupId>
  <artifactId>maven-bundle-plugin</artifactId>
  <extensions>true</extensions>
  <configuration>
    <instructions>
      <!--
       <Embed-Dependency>
          artifactId1,artifactId2;inline=true
       </Embed-Dependency>
      -->
      <!-- Import any version of javax.inject, to allow running on multiple versions of AEM -->
      <Import-Package>javax.inject;version=0.0.0,*</Import-Package>

      <Sling-Model-Packages>
        com.next.sample_test_impl.core
      </Sling-Model-Packages>
    </instructions>
  </configuration>
</plugin>
ArpitBora
  • 590
  • 9
  • 24
3

Remove below dependency

<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
<version>1.0</version>
<scope>provided</scope>

from parent and child(bundle) pom.xml,because javax.inject.inject is exported by this dependency as well .So your code is considering this dependency but not

     <dependency>
           <groupId>org.apache.geronimo.specs</groupId>
           <artifactId>geronimo-atinject_1.0_spec</artifactId>
           <version>1.0</version>
           <scope>provided</scope>
       </dependency>

So if u will remove the sling.model.api dependency,it will take its correct dependency. enter image description here

Shivani Garg
  • 735
  • 13
  • 37
  • 1
    Thank you, after so many rebuilds with modification of pom files finally found it works with `org.apache.slingorg.apache.sling.models.api org.apache.sling org.apache.sling.models.impl javax.inject javax.inject ` as mandatory in build and remaining `uber-jar` and `geronimo-atinject_1.0_spec` jars as optional. even both together works. – VAr Apr 10 '17 at 14:43
  • @VAr it works for me only with o‌​rg.apache.sling.mode‌​ls.api and javax.inject dependencies. – Dmytro Bilko Apr 23 '17 at 18:01