javax.inject dependency error | Community
Skip to main content
richac96395021
Level 4
April 4, 2018

javax.inject dependency error

  • April 4, 2018
  • 3 replies
  • 5606 views

Hi Team,

We are facing the following error while installing the bundle in AEM 6.1

30.03.2018 09:06:20.286 *ERROR* [FelixDispatchQueue] com.training.project.core FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle com.training.project.core [512]: Unable to resolve 512.0: missing requirement [512.0] osgi.wiring.package; (&(osgi.wiring.package=javax.inject)(version>=0.0.0)))

org.osgi.framework.BundleException: Unresolved constraint in bundle com.training.project.core [512]: Unable to resolve 512.0: missing requirement [512.0] osgi.wiring.package; (&(osgi.wiring.package=javax.inject)(version>=0.0.0))

at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)

at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)

at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1368)

at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)

at java.lang.Thread.run(Thread.java:748)

30.03.2018 09:10:43.674 *ERROR* [FelixDispatchQueue] com.training.project.core FrameworkEvent ERROR (org.osgi.framework.BundleException: Unresolved constraint in bundle com.training.project.core [512]: Unable to resolve 512.0: missing requirement [512.0] osgi.wiring.package; (&(osgi.wiring.package=javax.inject)(version>=0.0.0)))

org.osgi.framework.BundleException: Unresolved constraint in bundle com.training.project.core [512]: Unable to resolve 512.0: missing requirement [512.0] osgi.wiring.package; (&(osgi.wiring.package=javax.inject)(version>=0.0.0))

at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4095)

at org.apache.felix.framework.Felix.startBundle(Felix.java:2114)

at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1368)

at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:308)

at java.lang.Thread.run(Thread.java:748)

We have handled this dependency by adding the following package in the project.core pom.xml:-

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

<dependency>

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

<artifactId>uber-jar</artifactId>

<version>6.2.0</version>

<!-- for AEM6.1 use this version     : <version>6.1.0</version> -->

<!-- for AEM6.1 SP1 use this version : <version>6.1.0-SP1-B0001</version> -->

<!-- for AEM6.1 SP2 use this version : <version>6.1.0-SP2</version> -->

<!-- for AEM6.2 use this version     : <version>6.2.0</version> -->

<classifier>obfuscated-apis</classifier>

<scope>provided</scope>

</dependency>

Following changes has been added to the project pom.xml

<dependency>

            <groupId>javax.inject</groupId>

            <artifactId>javax.inject</artifactId>

            <version>1</version>

            <scope>provided</scope>

        </dependency>

        <dependency>

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

               <artifactId>uber-jar</artifactId>

               <version>6.2.0</version>

               <!-- for AEM6.1 use this version     : <version>6.1.0</version> -->

               <!-- for AEM6.1 SP1 use this version : <version>6.1.0-SP1-B0001</version> -->

               <!-- for AEM6.1 SP2 use this version : <version>6.1.0-SP2</version> -->

               <!-- for AEM6.2 use this version     : <version>6.2.0</version> -->

               <classifier>obfuscated-apis</classifier>

               <scope>provided</scope>

           </dependency>

We have installed the bundle on UAT Author (AEM 6.1), the bundle works perfectly fine but the same does not work on Prod Author (AEM 6.1).

Please let me know any resolution on the same.

with regards,

Richa Chaubey

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Adobe Employee
April 4, 2018

Try removing the package version from import-package

<Import-Package>javax.inject</Import-Package>

richac96395021
Level 4
April 4, 2018

I tried removing the package version, but still does not work

smacdonald2008
Level 10
April 4, 2018

You said you were using 6.1 - yet in your POM you are showing this.

<version>6.2.0</version>

Change the version to 6.1.0 in the POM.

So place this in your Project's parent POM:

<dependency>

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

               <artifactId>uber-jar</artifactId>

               <version>6.1.0</version>

               <!-- for AEM6.1 use this version     : <version>6.1.0</version> -->

               <!-- for AEM6.1 SP1 use this version : <version>6.1.0-SP1-B0001</version> -->

               <!-- for AEM6.1 SP2 use this version : <version>6.1.0-SP2</version> -->

               <!-- for AEM6.2 use this version     : <version>6.2.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>

Then add these dependencies in your core POM:

<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>

That should build the OSGi bundle for 6.1.

smacdonald2008
Level 10
April 4, 2018

Try following this article and  make these changes for 6.1 -- Scott's Digital Community: Creating your first AEM 6.2 Project using Adobe Maven Archetype 10

Adobe Employee
April 4, 2018

I think this is a known issue with Maven archetype 10. (See [1])

To fix this,

1. Add dependencies [2] as below in pom.xml

2. Add the following line in core/pom.xml and recompile the code with Uber jar and let me know how this goes (See [3])

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

Try this exercise and help me with the feedback.

[1] - https://github.com/Adobe-Marketing-Cloud/aem-project-archetype/issues/59

[2] -

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

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

        <version>1.0</version>

        <scope>provided</scope>

    </dependency>

    <dependency>

        <groupId>javax.inject</groupId>

        <artifactId>javax.inject</artifactId>

        <version>1</version>

    </dependency>

[3] -

            <plugin>

                <groupId>org.apache.felix</groupId>

                <artifactId>maven-bundle-plugin</artifactId>

                <extensions>true</extensions>

                <configuration>

                    <instructions>

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

                        <!--

                        <Embed-Dependency>

                            artifactId1,

                            artifactId2;inline=true

                        </Embed-Dependency>

                        -->

                        <Sling-Model-Packages>

                            com.usbank.ecm.publicweb.aemcore.core

                        </Sling-Model-Packages>

smacdonald2008
Level 10
April 4, 2018

I am going to test the article i referenced on 6.1 and use the dependencies that i referenced.

smacdonald2008
Level 10
April 4, 2018

I got a Maven 10 Archetype working by using this in the Parent POM:

<dependency>

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

               <artifactId>uber-jar</artifactId>

               <version>6.1.0</version>

               <!-- for AEM6.1 use this version     : <version>6.1.0</version> -->

               <!-- for AEM6.1 SP1 use this version : <version>6.1.0-SP1-B0001</version> -->

               <!-- for AEM6.1 SP2 use this version : <version>6.1.0-SP2</version> -->

               <!-- for AEM6.2 use this version     : <version>6.2.0</version> -->

               <classifier>obfuscated-apis</classifier>

               <scope>provided</scope>

           </dependency>

This in the CORE POM:

<dependency>

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

            <artifactId>uber-jar</artifactId>

            <classifier>obfuscated-apis</classifier>

        </dependency>

It build the sample app and it executed successfully: