Expand my Community achievements bar.

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

Avatar

Level 4

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.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

9 Replies

Avatar

Level 4

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

Avatar

Level 4

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.

Avatar

Level 1

Hi Matt,

 

Did you got any solution for this, even i am facing such kind of issues.

I could able to resolve conflict issues in bundle but iam getting below error while establishing connectivity.

-----------------------------------------------------

javax/net/ssl/HttpsURLConnection

Cannot serve request to /bin/googlecloudconnection in com.test.package.core.servlets.GoogleCloudConnectivityServlet

Exception:

java.lang.NoClassDefFoundError: javax/net/ssl/HttpsURLConnection
	at com.google.api.client.http.javanet.NetHttpTransport.buildRequest(NetHttpTransport.java:153)
	at com.google.api.client.http.javanet.NetHttpTransport.buildRequest(NetHttpTransport.java:55)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:871)
	at com.google.auth.oauth2.ServiceAccountCredentials.refreshAccessToken(ServiceAccountCredentials.java:358)
	at com.google.auth.oauth2.OAuth2Credentials.refresh(OAuth2Credentials.java:165)
	at com.google.auth.oauth2.OAuth2Credentials.getRequestMetadata(OAuth2Credentials.java:151)
	at com.google.auth.http.HttpCredentialsAdapter.initialize(HttpCredentialsAdapter.java:96)
	at com.google.cloud.http.HttpTransportOptions$1.initialize(HttpTransportOptions.java:159)
	at com.google.cloud.http.CensusHttpModule$CensusHttpRequestInitializer.initialize(CensusHttpModule.java:109)
	at com.google.api.client.http.HttpRequestFactory.buildRequest(HttpRequestFactory.java:88)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:430)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:549)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:482)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:599)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:400)
	at com.google.cloud.storage.StorageImpl$4.call(StorageImpl.java:213)
	at com.google.cloud.storage.StorageImpl$4.call(StorageImpl.java:210)
	at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:105)
	at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
	at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
	at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:209)

-----------------------------------------------------

Thanks

Avatar

Level 4

Unfortunately, I never got this to work in AEM. I ended up side-stepping AEM, and developed a java app outside of AEM to handle the file uploads up to the Google cloud storage bucket.

Avatar

Level 1

Hi Guys, I have a similar problem I need to integrate google cloud datastore with AEM 6.5

I get unresolved dependencies and the bundle is never active.

Avatar

Community Advisor

Hi, Are you able to solve this? Even I am not able to integrate google calendar API in AEM and getting unresolved dependency error in OSGI console.

Avatar

Level 4

Hi @Matt-H- Were you able to solve this issue?  we are running into a similar issue.

Thanks,
Mrudul

Avatar

Level 4

Unfortunately, I never got this to work in AEM. I ended up side-stepping AEM, and developed a java app outside of AEM to handle the file uploads up to the Google cloud storage bucket.