0

I'm trying to launch a simple Java (Maven) Spring Boot application on GAE that communicates with an PostrgreSql server (also on the Cloud Platform) however I keep running into missing dependencies.

I had these dependencies in my pom:

    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter</artifactId>
      <version>1.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
      <version>1.1.3.RELEASE</version>
    </dependency>

But whenever I deployed the app to GAE and the FlyWay the following was thrown:

java.lang.ClassNotFoundException: com.google.appengine.api.ThreadManager

I mainly followed the Baeldung tutorial here: https://www.baeldung.com/spring-boot-google-app-engine.

Then I found this answer: AppEngine ClassNotFoundException: com.google.appengine.api.datastore.DatastoreServiceFactory Which led me to adding the appengine dependency:

    <dependency>
      <groupId>com.google.appengine</groupId>
      <artifactId>appengine-api-1.0-sdk</artifactId>
      <version>1.9.77</version>
    </dependency>

Which then throws:

ClassNotFoundException: com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential$AppEngineCredentialWrapper

Which then led me to adding the client dependency.. and so on.. and so on..

My complete set of dependencies is now:

    <dependency>
      <groupId>com.google.cloud</groupId>
      <artifactId>google-cloud</artifactId>
      <version>0.47.0-alpha</version>
    </dependency>
    <dependency>
      <groupId>com.google.appengine</groupId>
      <artifactId>appengine-api-1.0-sdk</artifactId>
      <version>1.9.77</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter</artifactId>
      <version>1.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.cloud</groupId>
      <artifactId>spring-cloud-gcp-starter-sql-postgresql</artifactId>
      <version>1.1.3.RELEASE</version>
    </dependency>

And that.. leads back to the exception above:

ClassNotFoundException: com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential$AppEngineCredentialWrapper

So it is probably a dependency problem but I cannot for the life of my find any documentation about which dependencies you need to add to get a simple Spring Boot application running to a PostgreSQL server.

I'm about to throw in the towel... It might be a lack of sleep though

Methkal Khalawi
  • 2,368
  • 1
  • 8
  • 13
mathiasb
  • 194
  • 4
  • 11

1 Answers1

0

You are missing the App Engine plugin in your pom.xml :

<build>
  <plugins>
    <plugin>
      <groupId>com.google.cloud.tools</groupId>
      <artifactId>appengine-maven-plugin</artifactId>
      <version>1.3.2</version>
    </plugin>
  </plugins>
</build>

And for the exception you get, I do not know exactly where are you using this but you can add the dependency :

<dependency>
<groupId>com.google.auth</groupId>
  <artifactId>google-auth-library-oauth2-http</artifactId>
  <version>0.18.0</version>
</dependency>
Andrei Tigau
  • 2,010
  • 1
  • 6
  • 17
  • Thanks for the reply; I already tried that, to no avail. (the appengine was already there). I'm not using the oauth2 myself but when I deploy to the GAE and visit the link generated (https://xxxx-something.appspot.com) it throws the exceptions – mathiasb Nov 20 '19 at 19:53
  • Can you check this [Github repo](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/cloud-sql/postgres/servlet) and tell me if this helps you. Though, it's a Tomcat app, I don't think it's much of work to change it to Spring App?. It's a simple app that connect your Java App Engine to PostgreSQL instance. – Methkal Khalawi Nov 27 '19 at 13:16