Maven dependency issue while integrating GCP with AEM | Adobe Higher Education
Skip to main content
Adobe Champion
June 1, 2022

Maven dependency issue while integrating GCP with AEM

  • June 1, 2022
  • 3 respostas
  • 3043 Visualizações

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.

 

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 

 

Este tópico foi fechado para respostas.

3 Respostas

Fanindra_Surat
Community Advisor
Community Advisor
June 1, 2022

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

 

Adobe Champion
June 1, 2022

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

 

SantoshSai
Community Advisor
Community Advisor
June 1, 2022

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

 

 


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.

Santosh Sai
SantoshSai
Community Advisor
Community Advisor
June 1, 2022

Hi @p_v_nair 

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



Regards,
Santosh

Santosh Sai
Adobe Champion
June 1, 2022

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

SantoshSai
Community Advisor
Community Advisor
June 1, 2022

@p_v_nair 

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

Santosh Sai
Level 3
June 6, 2022

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

Adobe Champion
June 6, 2022

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

SantoshSai
Community Advisor
Community Advisor
June 6, 2022

@mrudulmo 
What was the resolution? How did you managed it?

Santosh Sai