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?
Views
Replies
Total Likes
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
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
@P_V_Nair
The error you are facing
because Bundle-SymbolicName header missing, cannot install bundle - the jar file which you are trying to install doesn't have a Bundle-Symbolic Name.
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.
@SantoshSai Could you please let me know how you were able to fix that 1 issue?
@SantoshSai Thanks a lot for checking. Still didn’t find a fix for it
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
Views
Like
Replies