6.2 Sling model Inject annotation | Community
Skip to main content
Level 4
Jun 13, 2016 1:53 PM UTC
Solved

6.2 Sling model Inject annotation

I've just updated from 6.1 to 6.2 and suddenly my sling models are causing problems. It seems like javax.inject is no longer available and so my bundle wont start. I have tried adding to my top level pom a dependancy but it is still not happy.

Error:

javax.inject,version=[0.0,1) -- Cannot be resolved

Dependancy added:

            <dependency>

                <groupId>javax.inject</groupId>

                <artifactId>javax.inject</artifactId>

            </dependency>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Jun 14, 2016 6:25 AM UTC

Hi,

Please add:-

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

1. Go to depfinder:- http://localhost:4502/system/console/depfinder 

2. add "javax.inject.Inject"

Result will be:- 

I hope this will help you.

 

Thanks and Regards

Kautuk Sahni

Kautuk Sahni

8 replies

Jaggu_Accenture
Level 2
Jan 22, 2018 5:55 PM UTC

I got the solutions, please find add the below code in core pom.xml file(i.e. find <instructions> and next to add <Import-Package>javax.inject;version=0.0.0,*</Import-Package>). The below solutions is required because in aem 6.2 default javax.inject is there so we just need to import this.

<instructions>

<Import-Package>javax.inject;version=0.0.0,*</Import-Package>

Translate
venkat_krishnat
Employee
Nov 8, 2017 12:11 PM UTC

The link shared by Scott actually contains the solution for this problem. Adding the below so that it can save some time to straight way have the fix.

Problem:

created a AEM project using Maven archetype and when installing to AEM 6.3 I find the below error.

  1. javax.inject,version=[0.0,1) -- Cannot be resolved

Solution:

Adding below to the core pom.xml

<dependency>

<groupId>com.adobe.aem</groupId>

<artifactId>uber-jar</artifactId>

<classifier>obfuscated-apis</classifier>

        </dependency>

  

        <dependency>

<groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-atinject_1.0_spec</artifactId>

        </dependency>

Adding below to main pom.xml

<dependency>

<groupId>com.adobe.aem</groupId>

<artifactId>uber-jar</artifactId>

<version>6.3.0</version>

<classifier>obfuscated-apis</classifier>

<scope>provided</scope>

</dependency>

           <dependency>

<groupId>org.apache.geronimo.specs</groupId>

<artifactId>geronimo-atinject_1.0_spec</artifactId>

<version>1.0</version>

<scope>provided</scope>

</dependency>

Translate
smacdonald2008
Level 10
Nov 28, 2016 11:19 PM UTC
ksuren
Level 3
Nov 28, 2016 10:34 PM UTC

kautuksahni wrote...

Hi,

Please add:-

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

1. Go to depfinder:- http://localhost:4502/system/console/depfinder 

2. add "javax.inject.Inject"

Result will be:- 

I hope this will help you.

 

Thanks and Regards

Kautuk Sahni

 

 

 

 

I'm able to find javax.inject.Inject as shown in the screenshot, what do i need to do then? I cannot see my project's package here in the list though? And the error still persists. My bundle is not Active.

Translate
Level 3
Nov 8, 2016 9:39 PM UTC
New Participant
Oct 24, 2016 11:37 AM UTC

I think this has to do with some dependency referencing specific to AEM 6.2.

A solution can be found here http://www.codermag.net/2016/10/javax-inject-version-cannot-be-resolved-in-AEM.html

Translate
Sutty100Author
Level 4
Jun 14, 2016 7:03 AM UTC

Got it thanks, wasn't aware of the dependency finder tool so thanks for that as well! 

Translate
kautuk_sahni
kautuk_sahniAccepted solution
Employee
Jun 14, 2016 6:25 AM UTC

Hi,

Please add:-

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

1. Go to depfinder:- http://localhost:4502/system/console/depfinder 

2. add "javax.inject.Inject"

Result will be:- 

I hope this will help you.

 

Thanks and Regards

Kautuk Sahni

Translate
Kautuk Sahni