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
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>
Related
I am trying to integrate spring-cloud-gcp-pub-sub-stream-binder in my spring boot project to consume events from gcp pub sub topic and getting the below error while running the project.
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner.provisionConsumerDestination(PubSubChannelProvisioner.java:81)
The following method did not exist:
'boolean com.google.pubsub.v1.TopicName.isParsableFrom(java.lang.String)'
The calling method's class, com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner, was loaded from the following location:
jar:file:/Users/pranay.garg/.m2/repository/com/google/cloud/spring-cloud-gcp-pubsub-stream-binder/3.3.0/spring-cloud-gcp-pubsub-stream-binder-3.3.0.jar!/com/google/cloud/spring/stream/binder/pubsub/provisioning/PubSubChannelProvisioner.class
The called method's class, com.google.pubsub.v1.TopicName, is available from the following locations:
jar:file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar!/com/google/pubsub/v1/TopicName.class
The called method's class hierarchy was loaded from the following locations:
com.google.pubsub.v1.TopicName: file:/Users/pranay.garg/.m2/repository/com/google/api/grpc/proto-google-cloud-pubsub-v1/1.84.0/proto-google-cloud-pubsub-v1-1.84.0.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes com.google.cloud.spring.stream.binder.pubsub.provisioning.PubSubChannelProvisioner and com.google.pubsub.v1.TopicName
I am using spring boot v2.6.1
and my dependencyManagement
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>libraries-bom</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-dependencies</artifactId>
<version>3.3.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2021.0.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
and my related dependencies
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream</artifactId>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>spring-cloud-gcp-pubsub-stream-binder</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-kafka</artifactId>
</dependency
I think it's a version compatibility issue where PubSubChannelProvisioner is trying to call a method in TopicName which is not present but I am not able to figure out the solution for this.
Let me know if you need any other information which might have been missed.
Any help is appreciated, thanks.
I believe GCP Adapter in s-c-function is using proto-google-cloud-pubsub v1.0.0 and in your case you are using 1.84. So perhaps we need to update.
Feel free to raise an issue - https://github.com/spring-cloud/spring-cloud-function/issues
I raised on issue on spring-cloud-gcp github repo and got the issue resolved. Turns out it was due to a version conflict in libraries-bom dependency management version solution
I'm running the Java client library from IP Info. When I try to executing the code:
IPinfo ipInfo = new IPinfo.Builder().setToken(apiKey).build();
IPResponse response = ipInfo.lookupIP(ipAddress);
I get a java.lang.NoSuchMethodError: okhttp3.Response.close()V exception.
I tried explicitly changing the version of OK Http 3 from 5.0.0-alpha.2 to 5.0.0-alpha.1 to 4.9.0 (tried many other versions too) but they all yield the same error.
What is causing this error? Which version should I use to gain access to the said method?
My POM file has the following dependencies:
<dependencies>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>8.40.14</version>
</dependency>
<dependency>
<groupId>co.ipdata.client</groupId>
<artifactId>ipdata-java-client</artifactId>
<version>0.2.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
</dependency>
<dependency>
<groupId>io.ipinfo</groupId>
<artifactId>ipinfo-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.0</version>
</dependency>
UPDATE:
Perhaps more intriguing, I noticed that when I open the said line with error in Eclipse
at io.ipinfo.api.request.IPRequest.handle(IPRequest.java:34)
It points to Line 34 in io.ipinfo.api.request; but there's absolutely no code on that line at all. The line simply contains the end of a curly brackets. See screenshot below:
Thanks to everyone for all the suggestions and input! I finally found the answer myself..
It turns out that this project dependent on a different project which included the following maven dependencies:
<dependency>
<groupId>com.squareup.retrofit</groupId>
<artifactId>retrofit</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.0.2</version>
</dependency>
I deleted those Maven dependencies and now everything works as expected.
Basically, I use Liquibase for most of my Java projects (at least where db migrations are needed) and it worked always on Java 8. I have a requirement now to migrate an existing project to Java 13. The project compiles with the Java 8 and also with Java 13 (see the configuration below), however, Liquibase Maven plug-in (mvn liquibase:diff) throws an ClassLoadingException:
org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [com.mypackage.TestEntity]: Could not load requested class : com.mypackage.TestEntity
here is the plugin configuration in my POM file:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${liquibase.maven.plugin.version}</version>
<configuration>
<propertyFile>src/main/resources/db-migrations/liquibase/liquibase.properties</propertyFile>
<changeLogFile>src/main/resources/db-migrations/liquibase/db-changelog-master.xml</changeLogFile>
<diffChangeLogFile>${changeset.output.dir}/${timestamp} - ${desc}.xml</diffChangeLogFile>
<logging>info</logging>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-hibernate5</artifactId>
<version>${liquibase-hibernate5.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${springboot.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${validation-api.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javassist.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
</dependencies>
</plugin>
and the liquibase.properties:
url=jdbc:postgresql://localhost:5432/user_registrations
username=postgres
password=somepwd
driver=org.postgresql.Driver
referenceUrl=hibernate:spring:com.mypackage?dialect=org.hibernate.dialect.PostgreSQL9Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
As I mentioned it at the beginning, the Java 13 build doesn't work:
<maven.compiler.release>13</maven.compiler.release>
<java.version>13</java.version>
All dependencies have the latest version.
Any idea what could be an issue here? Thanks for any input...
We created a Spring Boot 2.1.7.RELEASE app with an ElasticSearch 7.3.0 client.
When trying to run the Elastic client we get the following error for this line:
SearchResponse searchResponse = client.search(searchRequest, RequestOptions.DEFAULT);
Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z] with root cause
java.lang.NoSuchMethodError: org.elasticsearch.action.support.IndicesOptions.ignoreThrottled()Z
at org.elasticsearch.client.RequestConverters$Params.withIndicesOptions(RequestConverters.java:966)
at org.elasticsearch.client.RequestConverters.addSearchRequestParams(RequestConverters.java:417)
at org.elasticsearch.client.RequestConverters.search(RequestConverters.java:404)
at org.elasticsearch.client.RestHighLevelClient.lambda$search$2(RestHighLevelClient.java:932)
at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1450)
at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1424)
at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1394)
at org.elasticsearch.client.RestHighLevelClient.search(RestHighLevelClient.java:930)
We are using these dependencies:
<properties>
<spring-boot-version>2.1.7.RELEASE</spring-boot-version>
<elasticsearch.version>7.0.0</elasticsearch.version>
</properties>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring-boot-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<version>${spring-boot-version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>${spring-boot-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.3.0</version>
</dependency>
We found this post that caused us to add the elasticsearch.version property, but it didn't help.
We also run mvn dependency:tree -Dverbose to see if there is a conjunction of Elastic dependencies, but it seems that only the Elastic Client has Elastic related jar.
UPDATE
Following this post we tried to downgrade the Elastic client version to 7.1.1 but it didn't help
Following this answer here, we discovered that the Elastic server has a 6.5.4 version.
Changing the dependency to
<elasticsearch.version>6.5.4</elasticsearch.version>
Or
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
Solved the issue.
I'm writing a "Hello-World" application in Vertx2.
I have the following dependencies in pom.xml:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-platform</artifactId>
<version>2.0.0-beta1</version>
</dependency>
and run it as IntelliJ application with the following configuration:
I get the error:
Exception in thread "main" java.lang.NoSuchMethodError:
org.vertx.java.core.impl.VertxInternal.getOrAssignContext()Lorg/vertx/java/core/impl/DefaultContext;
Do you know what is the problem here?
Edit:
This project is for Vertx version 2 (not version 3). This is why the solution in this IntelliJ and Vertx: How to run org.vertx.java.deploy.impl.cli.Starter ? doesn't resolve the issue.
I found a solution to this problem. I just changed the version numbers for vertx-core and vertx-platform, and now it works.
The new dependencies in pom.xml are:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>2.1RC3</version>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-platform</artifactId>
<version>2.1.5</version>
</dependency>