AWS package cannot be resolved by Felix Console | Community
Skip to main content
tonycarreira
New Participant
April 15, 2019
Solved

AWS package cannot be resolved by Felix Console

  • April 15, 2019
  • 16 replies
  • 12475 views

Hi guys,

I am using the most recent maven archtype and therefore have the following folder structure:

Project Name

-Core

-it.launcher

-it.tests

-it.apps

-ui.content

I am importing an AWS dependency on my Master POM and Core POM

Master POM

<dependencyManagement>

   <dependencies>

   <!--AWS Dependencies -->
   <dependency>

   <groupId>software.amazon.awssdk</groupId>

   <artifactId>bom</artifactId>

   <version>2.5.25</version>

   <type>pom</type>

   <scope>import</scope>

   </dependency>

   <dependency>

   <groupId>com.amazonaws</groupId>

   <artifactId>aws-java-sdk-cloudfront</artifactId>

   <version>1.11.534</version>

   </dependency>

Core POM

<dependencies>

   <!--AWS Dependency -->
   <dependency>

   <groupId>com.amazonaws</groupId>

   <artifactId>aws-java-sdk-cloudfront</artifactId>

   </dependency>

The class using the AWS functionality is a custom workflow step that I have put inside the Core folder. However, when I deploy this to AEM I am getting "Cannot be resolved". I understand that just simply adding the dependency to the POM only helps compiling the code however the OSGI container is not able to see the dependency.

How can I fix this in my current project structure? I've read a few comments telling us to create some sort of eclipse bundle, but is there a more practical way to sort out this issue? We need this to be part of our continuous integration pipeline.

Many thanks in advance

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

Ok, I finally managed to get it to work! It was based on Macdonalds original advice.

For all reading this, ignore the <artifactId>aws-java-sdk-osgi</artifactId> bundle because it has a lot of dependency faults and version issues. You will end up driving yourself mad chasing dependencies. For anyone wanting to incorporate AWS related stuff DO NOT follow the AWS tutorial here Using the SDK with Apache Maven - AWS SDK for Java  it will tell you to either install the "bom" package or the one that pulls all the dependencies <groupId>software.amazon.awssdk</groupId>. I just used the bit that interested me which was cloudfront, so I used the following dependency:

            <dependency>

                <groupId>com.amazonaws</groupId>

                <artifactId>aws-java-sdk-cloudfront</artifactId>

                <version>1.11.534</version>

            </dependency>

Then using that dependency only, I created a bundle in eclipse following the link Macdonald provided me Adobe Experience Manager Help | Submitting Adobe Experience Manager form data to Java Sling Servlets

The jar you need to build the bundle can be found in your .m2 folder.

It is very important that you remove all manifest related information from the bundle otherwise you will run into version problems.

Then deploy it to OSGI using the update button.

It should look something like this:

Bundle-Name: AWS-Cloudfront-AEM-Centrica-OSGI

Bundle-SymbolicName: AWS-Cloudfront-AEM-Centrica-OSGI

Bundle-Version: 1.0.0

Bundle-Vendor: Centrica

Automatic-Module-Name: AWS-AEM-Centrica-OSGI

Bundle-RequiredExecutionEnvironment: JavaSE-1.8

Export-Package: com.amazonaws, etc... etc... etc...

If you get the "cannot be resolved"  issue regarding any of the things I mention in the printscreens above, DO NOT CHASE THEM you will end up going down a rabit hole.

Thanks to all that tried to help and especially, huge thanks Macdonald!!!

16 replies

tonycarreira
New Participant
April 17, 2019

Thanks Macdonald. I have done that and now I can see the dependency in the depfinder:

The problem is my project still can't find those dependencies:

My POM currently looks like this:

<build>

   <plugins>

   <plugin>

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

   <artifactId>maven-scr-plugin</artifactId>

   </plugin>

   <plugin>

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

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

   <extensions>true</extensions>

   <configuration>

   <instructions>

   </instructions>

   </configuration>

   </plugin>

   </plugins>

</build>

If I add the following to the POM instructions in the POM

<build>

   <plugins>

   <plugin>

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

   <artifactId>maven-scr-plugin</artifactId>

   </plugin>

   <plugin>

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

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

   <extensions>true</extensions>

   <configuration>

   <instructions>

   <Embed-Dependency>aws-java-sdk-osgi,*;scope=compile</Embed-Dependency>

   <Import-Package>com.amazonaws.*,*</Import-Package>

   </instructions>

   </configuration>

   </plugin>

   </plugins>

</build>

I get even more errors... Does this mean I need to wrap those extra dependencies to my project bundle I created separately? Kinda feels like I am going down a rabbit hole haha

Or are the instructions to the pom not the correct one? Help....

smacdonald2008
New Participant
April 16, 2019

The nice thing about AEM is you can build an OSGi bundle that contains dependent JARS separate from your project. Any OSGi bundle that contains AWS JARs will resolve these Java packages for any OSGi bundle that requires them.

One way to build an OSGi bundle that contains other JARS is documented here - notice how we wrap the SIMPLE JSON JAR into a bundle.

Adobe Experience Manager Help | Submitting Adobe Experience Manager form data to Java Sling Servlets

tonycarreira
New Participant
April 16, 2019

Thank you Macdonald! How do I do that with my Core bundle?

Thanks

smacdonald2008
New Participant
April 16, 2019

Try getting the JARs that expose these packages and wrap them into an OSGi bundle and deploy to AEM. That way - you know for sure these Java Packages are in the OSGi service container.

tonycarreira
New Participant
April 16, 2019

Thank you so much for the prompt answer. Unfortunately it did not work. My Core Pom is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<!-- | Copyright 2014 Adobe Systems Incorporated | | Licensed under the Apache

License, Version 2.0 (the "License"); | you may not use this file except

in compliance with the License. | You may obtain a copy of the License at

| | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable

law or agreed to in writing, software | distributed under the License is

distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY

KIND, either express or implied. | See the License for the specific language

governing permissions and | limitations under the License. -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>

        <groupId>com.company</groupId>

        <artifactId>CC-aem</artifactId>

        <version>${companyCurrent}</version>

        <relativePath>../pom.xml</relativePath>

    </parent>

    <artifactId>CC-aem.core</artifactId>

    <packaging>bundle</packaging>

    <name>Comapny CMS (AEM6) - Core</name>

    <description>Core bundle for Company CMS (AEM6)</description>

    <build>

        <plugins>

            <plugin>

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

                <artifactId>maven-scr-plugin</artifactId>

            </plugin>

            <plugin>

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

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

                <extensions>true</extensions>

                <configuration>

                    <instructions>

                        <!-- <Embed-Dependency> artifactId1, artifactId2;inline=true </Embed-Dependency> -->

                    </instructions>

                </configuration>

            </plugin>

        </plugins>

    </build>

    <profiles>

        <!-- Development profile: install only the bundle -->

        <profile>

            <id>autoInstallBundle</id>

            <activation>

                <activeByDefault>false</activeByDefault>

            </activation>

            <build>

                <plugins>

                    <plugin>

                        <groupId>org.apache.sling</groupId>

                        <artifactId>maven-sling-plugin</artifactId>

                        <configuration>

                            <slingUrlSuffix>/apps/company/install/</slingUrlSuffix>

                            <failOnError>true</failOnError>

                        </configuration>

                    </plugin>

                </plugins>

            </build>

        </profile>

    </profiles>

    <dependencies>

        <!--AWS Dependency -->

        <dependency>

            <groupId>com.amazonaws</groupId>

            <artifactId>aws-java-sdk-cloudfront</artifactId>

        </dependency>

        <!-- OSGi Dependencies -->

        <dependency>

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

            <artifactId>org.apache.felix.scr</artifactId>

        </dependency>

        <dependency>

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

            <artifactId>org.apache.felix.scr.annotations</artifactId>

        </dependency>

        <dependency>

            <groupId>biz.aQute</groupId>

            <artifactId>bndlib</artifactId>

        </dependency>

        <dependency>

            <groupId>org.osgi</groupId>

            <artifactId>org.osgi.core</artifactId>

        </dependency>

        <dependency>

            <groupId>org.osgi</groupId>

            <artifactId>org.osgi.compendium</artifactId>

        </dependency>

        <!-- Other Dependencies -->

        <dependency>

            <groupId>org.slf4j</groupId>

            <artifactId>slf4j-api</artifactId>

        </dependency>

        <dependency>

            <groupId>javax.jcr</groupId>

            <artifactId>jcr</artifactId>

        </dependency>

        <dependency>

            <groupId>javax.servlet</groupId>

            <artifactId>servlet-api</artifactId>

        </dependency>

        <dependency>

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

            <artifactId>aem-api</artifactId>

        </dependency>

        <dependency>

            <groupId>junit</groupId>

            <artifactId>junit</artifactId>

        </dependency>

        <dependency>

            <groupId>org.mockito</groupId>

            <artifactId>mockito-all</artifactId>

        </dependency>

        <dependency>

            <groupId>junit-addons</groupId>

            <artifactId>junit-addons</artifactId>

        </dependency>

        <dependency>

            <groupId>org.slf4j</groupId>

            <artifactId>slf4j-log4j12</artifactId>

            <!-- the binding version needs to match the slf4j api -->

            <version>1.5.11</version>

            <scope>test</scope>

        </dependency>

        <dependency>

            <groupId>org.projectlombok</groupId>

            <artifactId>lombok</artifactId>

            <version>1.18.6</version>

            <scope>provided</scope>

        </dependency>

    </dependencies>

</project>

Gaurav-Behl
New Participant
April 15, 2019

Include  "bom" and "aws-java-sdk-cloudfront"  in Embed-Dependency

example:

<plugin>

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

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

<extensions>true</extensions>

<configuration>

<instructions>

<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>

<Bundle-Name>${project.name}</Bundle-Name>

<Embed-Dependency>bom,aws-java-sdk-cloudfront,*;scope=compile</Embed-Dependency>

<Import-Package>*</Import-Package>

</instructions>

</configuration>

</plugin>

If that doesn't work, please share your pom.xml's  maven-bundle-plugin configuration