Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Maven dependency issue while integrating GCP with AEM

Avatar

Adobe Champion

Hi,

 

We are working on a POC to call a google cloud storage API from AEM to retrieve an image file following the documentation - https://www.baeldung.com/java-google-cloud-storage . My class is as below ,currently in the early stages to establish the connectivity.

 

import java.io.IOException;

import com.google.api.gax.paging.Page;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;

public class GoogleCloudConnector {
public static void main(String[] args) throws IOException {
System.out.println("This is main");

StorageOptions.Builder b = StorageOptions.newBuilder().setProjectId("lt-test-lwr");
Storage storage = b.build().getService();
Page<Bucket> buckets = storage.list();
for (Bucket bucket : buckets.iterateAll()) {
System.out.println(bucket.toString());
}

}
}

 

The maven dependency I have added for using this API is as below.

<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>2.6.1</version>
</dependency>

 

But, I am getting dependency error and my bundle is not getting active.

 

P_V_Nair_0-1654100318372.png

Can someone help understand, why we get this error even after adding the required maven dependency in AEM project? Has anyone successfully integrated Google cloud platform with AEM and any insights here?

@Vijayalakshmi_S 

 

13 Replies

Avatar

Community Advisor

Hi @P_V_Nair - The google could storage jar that you are using is a third-party jar and is not available in the OSGI. By adding an entry in the pom file, you are only making sure that the jar is available during local development and compile-time; but for the same to work in the context of OSGI, the jar should be available as a bundle in the OSGI. To achieve this you can follow the following articles:

https://www.linkedin.com/pulse/how-add-third-party-bundle-you-aem-package-veena-vikraman

https://myaemlearnings.blogspot.com/2021/08/embedding-third-party-dependencyosgi.html

 

Thanks,

Fani

 

Avatar

Adobe Champion

Hi @Fanindra_Surat , Thank you for your reply. But isn't it possible to add a third party jar to maven pom.xml using bnd plugin import or embed packages , instead of going through these steps to import the third party jar to OSGI as another bundle? I tried directly adding the jar to osgi using felic console, but it gave 

HTTP ERROR 500 Server Error

 

Avatar

Community Advisor

@P_V_Nair 

The error you are facing

 Screen Shot 2022-06-01 at 4.09.21 PM.png

because Bundle-SymbolicName header missing, cannot install bundle -  the jar file which you are trying to install doesn't have a Bundle-Symbolic Name.

Avatar

Community Advisor

Hi @P_V_Nair - You can use the bnd maven plugin too, but the instruction you may want to use is -includeresource. More detailed steps on using this plugin for embedding third-party jar is at the link https://myaemlearnings.blogspot.com/2021/12/embed-third-party-dependency-using-bnd.html

 

 

Avatar

Community Advisor

The maven archetype which i have(check below screenshot) is based in maven bundle plugin - based on it can able to resolve one issue but not completely.

Avatar

Adobe Champion

@SantoshSai Could you please let me know how you were able to fix that 1 issue?

Avatar

Community Advisor

Hi @P_V_Nair 

Facing similar issue even after following steps mentioned above - embedding external jar to bundle 

Screen Shot 2022-06-01 at 4.05.32 PM.png

Regards,
Santosh

Avatar

Adobe Champion

@SantoshSai Thanks a lot for checking. Still didn’t find a fix for it

Avatar

Community Advisor

@P_V_Nair 

May I know what archetype you have currently? or send me a snap for module architecture eg. 

Screen Shot 2022-06-01 at 4.30.00 PM.png

Avatar

Level 4

Hi @P_V_Nair 

Add the dependency (google-cloud-storage.jar) in Include-Resource attribute of bnd-maven-plugin, in your core pom.xml 
And add the same in Bundle-ClassPath attribute as well. 
Also, make sure you exclude other dependencies of (!com.google.api.*) in the Import-Package attribute of bnd-maven-plugin

Thanks,
Mrudul

Avatar

Adobe Champion

Thank you @mrudul That fixed the issue and the bundle is active now.