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>
Related
Since upgrading to MacOS 12, when I run owlapi-dependent projects that are compiled with Maven, the Guice library which owlapi depends on, throws several different types of exceptions at start time. What can I do to resolve this?
For example:
Exception in thread "main" java.lang.NoSuchMethodError: com.google.inject.internal.BytecodeGen.getClassLoader(Ljava/lang/Class;)Ljava/lang/ClassLoader;
com.google.inject.internal.MessageProcessor visit
INFO: An exception was caught and reported. Message: java.lang.NoSuchMethodException: uk.ac.manchester.cs.owl.owlapi.OWLOntologyFactoryImpl.<init>()
com.google.inject.CreationException: Unable to create injector, see the following errors:
1) An exception was caught and reported. Message: Injection failed for interface OWLOntologyFactory
at [unknown source]
1 error
======================
Full classname legend:
======================
OWLOntologyFactory: "org.semanticweb.owlapi.model.OWLOntologyFactory"
========================
End of classname legend:
========================
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:576)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:163)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
at com.google.inject.Guice.createInjector(Guice.java:87)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at org.semanticweb.owlapi.apibinding.OWLManager.<clinit>(OWLManager.java:42)
... 2 more
Here are the dependencies in the pom file I'm using:
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>jfact</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.7</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.6.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-rio</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>ch.securityvision</groupId>
<artifactId>xattrj</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
Thr guice dependency was removed from the 5.x branch of owlapi a few years ago. Try updating owlapi to 5.1.20 and removing the explicit guice dependency in your pom. This should exclude all guice references. If necessary, exclude it from the jfact dependency as well (I have not tried jfact with any java version past 8 but i would expect it to work, it doesn't have any features that are known to be incompatible with newer jdks.
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.
I'm trying to use Unirest in my program but I keep getting this error java.lang.NoSuchMethodError: com.google.gson.Gson.newBuilder()Lcom/google/gson/GsonBuilder;
I have tried using different maven versions of Gson but I still continue to get this seror
Edid added my pom.xml, I tried deleted my .m2 but I am still having this problem
<dependencies>
<!-- https://mvnrepository.com/artifact/com.konghq/unirest-java -->
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.7.00</version>
<classifier>standalone</classifier>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.twitter4j</groupId>
<artifactId>twitter4j-core</artifactId>
<version>[4.0,)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>Spigot8</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/spigot-1.8.8-R0.1-SNAPSHOT-latest.jar</systemPath>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>LATEST</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>compile</scope>
</dependency>
</dependencies>```
Could be a conflict between the GSON versions in your POM file versus what is in your container (Tomcat/JBoss) etc. Inspect the JARS in WEB-INF/lib. If there are two different versions, then delete the one which is not the same as the one currently in your maven project's POM file. I had a similar issue - my project was using gson-2.6.3.jar but a conflicting gson-2.1.jar also existed in WEB-INF/lib. I deleted gson-2.1.jar and this resolved my problem
This issue is possibly due to conflicts in Gson versions.
Go to your repository if you are on windows:
C:\Users\User_name.m2\repository\com\google\code\gson
or on Mac:-
/.m2/repository/com/google/code/gson
Delete all the existing folders.
Now, add below maven dependency in your pom file:
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
Re-build your maven project and try to run.
It seems like a dependencies issue.
Please make sure your dependencies are correct. Unirest 3.7.00 uses Gson 2.8.6
https://mvnrepository.com/artifact/com.konghq/unirest-java/3.7.00
Also, if you don't use Gson separately you don't need to specify it. Just add a dependency for unirest-java as it's described in Maven repository:
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.7.00</version>
</dependency>
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>
I am getting the error for sikuli constructor: cannot initiate the type screenhere org.sikuli.api.Screen is imported but failing to initiate
In pom.xml i have used the following dependency:
<dependency>
<groupId>org.sikuli</groupId>
<artifactId>sikuli-api</artifactId>
<version>1.2.0</version>
</dependency>
Use this dependency it should work:
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
</dependency>