IllegalArgumentException on trying out 'Quickstart: Run a Gmail App in Java' - java

I created a project using maven and followed the steps. But when i run the code i get the following error.
Exception in thread "main" java.lang.IllegalArgumentException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:76)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.getDetails(GoogleClientSecrets.java:80)
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow$Builder.<init>(GoogleAuthorizationCodeFlow.java:195)
at com.vertoanalytics.external.mailfetcher.GmailApiQuickstart.main(GmailApiQuickstart.java:41)
When I google it there are some ides about not having latest packges can cause this problem. Here is my meven dependency list related to the project
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.18.0-rc</version>
</dependency>
<dependency>
<groupId>com.google.oauth-client</groupId>
<artifactId>google-oauth-client</artifactId>
<version>1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-gmail</artifactId>
<version>v1-rev7-1.19.0</version>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson</artifactId>
<version>1.18.0-rc</version>
</dependency>
do i miss anything ?

Related

java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference

I'm working on my first Java project with maven. I compiled the code but get the following error when trying to execute the jar:
java.lang.NoClassDefFoundError: com/fasterxml/jackson/core/type/TypeReference
I have the following dependencies:
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.3.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20211205</version>
</dependency>
</dependencies>
I've tried adding jackson-core as a separate dependency but this won't fix the issue.

Error while loading package in Intellij after adding Maven dependencies (Scala)

I'm using intelij ultimate trial. I'm new to programming and a friend recommended I learn functional programming before object oriented programming. Searching the web I decided to learn Scala. The problem is I can't even set up IDE environment. I copied the dependencies but I'm unsure what they do. I'm just following along a coursera course right now. I don't know what the issue is. I don't know if I provided enough information. I used an online IDE when I was learning python
Currently using:
SDK 2.13.4
JDK 1.8
I've tried:
changing JDK to 11.0, 11.03, 13.0, and 15.0. I also changed SDK 2.11, 2.12.9,2.13.5 witch each JDK
Maven dependencies I'm using:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.scalaj</groupId>
<artifactId>scalaj-http_2.13</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.15</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.13</artifactId>
<version>2.6.11</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.13</artifactId>
<version>2.6.11</version>
</dependency>
<dependency>
<groupId>io.socket</groupId>
<artifactId>socket.io-client</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>com.corundumstudio.socketio</groupId>
<artifactId>netty-socketio</artifactId>
<version>1.7.18</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>15.0.1</version>
</dependency>
<dependency>
<groupId>org.scalafx</groupId>
<artifactId>scalafx_2.13</artifactId>
<version>15.0.1-R21</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.13</artifactId>
<version>3.0.9</version>
</dependency>
<dependency>
<groupId>com.typesafe.play</groupId>
<artifactId>play-json_2.13</artifactId>
<version>2.9.2</version>
</dependency>
Specific error I'm receiving:
Error:scalac: error while loading package, class file '/Users/panda/.m2/repository/org/scala-lang/scala-library/2.13.4/scala-library-2.13.4.jar(scala/collection/immutable/package.class)' is broken
(class java.lang.RuntimeException/error reading Scala signature of package.class: Scala signature package has wrong version
expected: 5.0
found: 5.2 in package.class)

cucumber.runtime.CucumberException: No backends were found

I am trying to run a BDD test with cucumber in a Maven project.
When I try to run BDDdemo.feature , I get the following error
Exception in thread "main" cucumber.runtime.CucumberException: No backends were found. Please make sure you have a backend module on your CLASSPATH.
at cucumber.runtime.Runtime.<init>(Runtime.java:81)
at cucumber.runtime.Runtime.<init>(Runtime.java:70)
at cucumber.runtime.Runtime.<init>(Runtime.java:66)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main.main(Main.java:18)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)
Environments
openjdk version : 13.0.1
Apache Maven : 3.6.3
TestNG : 6.14.3
cucumber : 1.2.6
IDE : IntelJ IDEA
dependencies
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-testng</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.6</version>
<!--<type>pom</type>-->
</dependency>
<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>5.3.0</version>
</dependency>
I have tried the all solutions in stack overflow regarding this issue. But nothing worked for me.
Can anyone help me with this ?
I'm assuming that, according to your pom.xml snippet, you are using TestNG and Junit. Thus, you need to add both cucumber-testng (it's already there) and cucumber-junit (it's missing) as cucumber backends. Please consider adding this other dependency entry to dependencies section on your pom.xml:
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.6</version>
</dependency>
PS: all the dependencies you listed seems to be test-scoped, so, consider add <scope>tests</scope> to each one of them to avoid unnecessarily adding those libraries to your final package (in case you are packaging a JAR).

How to run my map-reduce program with AWS?

I`m trying to run a map-reduce program using Hadoop framework.
I need to run the program on an AmazonElasticMapReduce instance but I keep getting the following error:
Exception in thread "main" java.lang.NoSuchMethodError: com.amazonaws.transform.JsonErrorUnmarshaller: method (Ljava/lang/Class;)V not found
I tried to fix my pom file and adding the AWS SDK, changing its versions and adding the core separately.
my pom.xml file:
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-ec2</artifactId>
<version>1.10.2</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.10.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-emr</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.5</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
<version>1.11.5</version>
</dependency>
me trying to create the instance:
AWSCredentials creds = new PropertiesCredentials(new FileInputStream(propertiesFilePath));
AmazonElasticMapReduce mapReduce = new AmazonElasticMapReduceClient(creds);
I expect the program to run on AWS instance (and probably get a bunch more error in my code that I can debug).

Could not initialize com.ibm.mq.MQEnvironment

I've upgraded my maven dependencies for IBM MQ from these(version: 6.0.2.5):
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq</artifactId>
<version>${ibm-mq-version}</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mqjms</artifactId>
<version>${ibm-mq-version}</version>
</dependency>
<dependency>
<groupId>com.ibm.disthub2</groupId>
<artifactId>dhbcore</artifactId>
<version>DH610-Gold</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mqetclient</artifactId>
<version>${ibm-mq-version}</version>
</dependency>
To that(version: 7.5.0.5):
<dependency>
<groupId>com.ibm</groupId>
<artifactId>mq-jms-all</artifactId>
<version>${ibm-mq-version}</version>
</dependency>
Now, everytime I try to run my project, I get the following error:
nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.ibm.mq.MQEnvironment
The maven-dependency is imported correctly and is also visible in Eclipse in the maven-dependencies-tab. Also i see the com.ibm.mq.jar in the classpath.
I've googled a lot and the only real solution, which worked for some people was, to add the connector.jar. But I'm already using the jar:
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector</artifactId>
<version>${connector-version}</version>
</dependency>
Am I missing something?
IBM MQ from these(version: 6.0.2.5):
To that(version: 7.5.0.5):
IBM moved the MQException to the 'com.ibm.mq.jmqi.jar' file.
As per the the MQ Knowledge Center, you need the following jar files for MQ JMS programming:
com.ibm.mq.commonservices.jar
com.ibm.mq.headers.jar
com.ibm.mq.pcf.jar
com.ibm.mq.jmqi.jar
connector.jar
jms.jar
dhbcore.jar
rmm.jar
jndi.jar
ldap.jar
fscontext.jar
providerutil.jar
CL3Export.jar
CL3Nonexport.jar
Exactly the same problem and this fixed it
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector</artifactId>
<version>${connector-version}</version>
</dependency>
These are my dependencies.
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.commonservices</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.headers</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.jmqi</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.jms.Nojndi</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mqjms</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.soap</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.headers</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.pcf</artifactId>
<version>7.0.1.4</version>
</dependency>
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.dhbcore</artifactId>
<version>7.0.1</version>
</dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>CL3Nonexport</artifactId>
<version>${webspheremq.version}</version>
</dependency>
<dependency>
<groupId>com.ibm</groupId>
<artifactId>com.ibm.mqetclient</artifactId>
<version>7.0.1</version>
</dependency>
For Eclipse (Dynamic Web Project (Servlet)) you need copy files:
com.ibm.mq.commomservices.jar
com.ibm.mq.defaultconfig.jar
com.ibm.mq.headers.jar
com.ibm.mq.jar
com.ibm.mq.jmqi.jar
com.ibm.mq.jms.Nojndi.jar
com.ibm.mq.pcf.jar
com.ibm.mqetclient.jar
com.ibm.mqjms.jar
connector.jar
dhbcode.jar
fscontext.jar
jms.jar
to /WebContext/WEB-INF/lib, then add them into Project (Project -> Properties -> Java Build Path -> Add External JARs).
After all, go through these steps:
close project
close Eclipse
open Eclipse
open project.
Good Luck!

Categories