Highlighted

Why won't Google Cloud Storage work in AEM (for me)?

Matt-H- 23-02-2020

I am trying to use the Google Cloud Storage Client Libraries for the Google Cloud Storage API within AEM 6.5. The eventual goal is for a job to export some AEM content straight into a Google bucket. But for now, I'm trying to run some tests, and it doesn't work. The bundle with the Google Cloud storage codel,refuses to activate due to the cloud storage not being able to be resolved.

 

com.google.cloud.storage -- Cannot be resolved

 

As per https://cloud.google.com/storage/docs/reference/libraries, in my main pom.xml file, I have this:

 

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>libraries-bom</artifactId>
      <version>3.2.0</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
...
  </dependencies>
</dependencyManagement>

 

And then in the bundles pom.xml file, I have

 

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

 

In my java file, I have

 

package com.company.lib;
import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.BucketInfo;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;

public class AuthExample {
  static void authImplicit() {
    try {
      StorageOptions so = StorageOptions.getDefaultInstance();
      //Storage storage = so.getService();
      //Storage storage = StorageOptions.getDefaultInstance().getService();
    } catch (Exception e) {
    }
  }
  public static void main(String[] args) throws IOException {
    if (args.length == 0) {
      authImplicit();
      return;
    }
    authImplicit();
  }
}

 

The package with this code compiles the bundle into existence, but the if the line StorageOptions so = StorageOptions.getDefaultInstance(); is there, the bundle doesn't install. It gives this error:

21.02.2020 18:16:33.054 *ERROR* qtp325298061-4006 org.apache.felix.http.jetty %bundles.pluginTitle: Cannot start (org.osgi.framework.BundleException: Unable to resolve com.company.CompanyLibBundle [520](R 520.132): missing requirement [com.company.CompanyLibBundle [520](R 520.132)] osgi.wiring.package; (osgi.wiring.package=com.google.cloud.storage) Unresolved requirements: [[com.company.CompanyLibBundle [520](R 520.132)] osgi.wiring.package; (osgi.wiring.package=com.google.cloud.storage)])
org.osgi.framework.BundleException: Unable to resolve com.company.CompanyLibBundle [520](R 520.132): missing requirement [com.company.CompanyLibBundle [520](R 520.132)] osgi.wiring.package; (osgi.wiring.package=com.google.cloud.storage) Unresolved requirements: [[com.company.CompanyLibBundle [520](R 520.132)] osgi.wiring.package; (osgi.wiring.package=com.google.cloud.storage)]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4368)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2281)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:984)
at org.apache.felix.webconsole.internal.core.BundlesServlet.doPost(BundlesServlet.java:359)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:563)
at org.apache.felix.webconsole.internal.servlet.OsgiManager$3.run(OsgiManager.java:465)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.felix.webconsole.internal.servlet.OsgiManager.service(OsgiManager.java:461)
at org.apache.felix.http.base.internal.handler.ServletHandler.handle(ServletHandler.java:123)
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:86)
at com.adobe.granite.license.impl.LicenseCheckFilter.doFilter(LicenseCheckFilter.java:308)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:142)
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:81)
at org.apache.sling.i18n.impl.I18NFilter.doFilter(I18NFilter.java:131)
at org.apache.felix.http.base.internal.handler.FilterHandler.handle(FilterHandler.java:142)
at org.apache.felix.http.base.internal.dispatch.InvocationChain.doFilter(InvocationChain.java:81)
at org.apache.felix.http.base.internal.dispatch.Dispatcher$1.doFilter(Dispatcher.java:146)
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1002)
at org.apache.sling.security.impl.ReferrerFilter.doFilter(ReferrerFilter.java:326)
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:136)
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008)
at org.apache.felix.http.sslfilter.internal.SslFilter.doFilter(SslFilter.java:97)
at org.apache.felix.http.base.internal.handler.PreprocessorHandler.handle(PreprocessorHandler.java:136)
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager$2.doFilter(WhiteboardManager.java:1008)
at org.apache.felix.http.base.internal.whiteboard.WhiteboardManager.invokePreprocessors(WhiteboardManager.java:1012)
at org.apache.felix.http.base.internal.dispatch.Dispatcher.dispatch(Dispatcher.java:91)
at org.apache.felix.http.base.internal.dispatch.DispatcherServlet.service(DispatcherServlet.java:49)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:873)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:542)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1701)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1668)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:370)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:267)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)

 

What am I doing wrong? What am I missing?

 

Thanks.

AEM 6.5 Google Cloud Storage maven osgi pom.xml

Re: Why won't Google Cloud Storage work in AEM (for me)?

Matt-H- 24-02-2020

As per https://www.albinsblog.com/2015/02/comgooglegsonversion223-cannot-be.html#.XlQM5ihKiHs, I have also tried adding to the pom.xml file:

 

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Activator>com.sample.activator.Activator</Bundle-Activator>
<Import-Package>*,com.sample.*</Import-Package>
<Export-Package>com.sample.*,com.google.cloud.*</Export-Package>
<Bundle-SymbolicName>com.sample</Bundle-SymbolicName>
<Bundle-Vendor>Sample</Bundle-Vendor>
<Bundle-Category>Sample</Bundle-Category>
<Embed-Directory>dependencies</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>

 

and then I tried

 

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>

 

Neither worked. And lastly, I tried installing the jar directly, which failed because of a server error:

 

java.io.IOException: Bundle-SymbolicName header missing, cannot install bundle

Re: Why won't Google Cloud Storage work in AEM (for me)?

Matt-H- 28-02-2020

I tried following the example shown here: https://wiki.eclipse.org/Creating_OSGi_Bundles_from_Third-Party_JARs to modify the MANIFEST.MF file and install the Google Cloud Storage jar. It was relatively successful, in that the google cloud jar installed and our custom bundle no longer failed to activate due to Google Cloud. But it instead failed to activate due to another incompatibility -

 

javax.annotation, version=[3.0,4) -- Cannot be resolved.

 

It's definitely related/connected to the Google Cloud jar/code, since it didn't exist at all before then. I briefly tried to do the same thing and make javax.annotation an installable jar, but it didn't work, and I tried tracing it in the Cloud code. But at this point, trying to track this down isn't worth it, so we've decided to go a different direction and not work with google cloud storage inside our AEM code.

If anyone has any ideas, they are welcome to comment.