import issue for Google pubsub publisher code in java - java

I was reading the google document, i wanted to push my message into pubsub topic.
reference link:
https://cloud.google.com/pubsub/docs/quickstart-client-libraries#pubsub-client-libraries-java
Added the pom dependency as mentioned:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-pubsub</artifactId>
<version>1.82.0</version>
</dependency>
Example class used:
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/pubsub/cloud-client/src/main/java/com/example/pubsub/PublisherExample.java
But after doing everything not sure why the import of all the class is not working through maven.
Error i have in IDE:
Also, when i checked my Java build path all the google related jars are look like this:
Add more on it, multiple time updated/clean/build the project, Restart the eclipse 100 times.
Literally I am not getting what to do now, can anybody help what I am missing here.
Appreciated your help in advance.

Related

Facing an issue "Could not find class [org.springframework.data.jdbc.repository.config.JdbcConfiguration] in spring-boot app

I have a code base which works perfectly on one of my machine but fails to run on another. While I am able to gather all dependencies without any issues I am getting error while running the main program.
While I am not able to copy paste the issue since its in RDP, please find below the stack trace. Any solutions would be of great help to resolve this issue.
Remove all other dependencies related to spring-boot-starter-jpa in pom.xml.
Add only one dependency below. That's enough.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.2.6.RELEASE</version> <!-- as mentioned (but optional if used at the parent level)-->
</dependency>
That's all.

The import com.amazonaws.services.s3.AmazonS3ClientBuilder cannot be resolved

I am trying to access my s3 buckets from my java application, trying to implement this
https://docs.aws.amazon.com/sdk-for-java/v1/developer-guide/examples-s3-buckets.html
I've added the lib/aws-java-sdk-1.8.6.jar to my lib folder and added the dependency in my pom.xml as well.
I still get this import error
"The import com.amazonaws.services.s3.AmazonS3ClientBuilder cannot be resolved"
for "import com.amazonaws.services.s3.AmazonS3ClientBuilder;"
Whereas the imports
"import com.amazonaws.services.s3.AmazonS3;" and "import
com.amazonaws.services.s3.model.Bucket;" gave no errors.
Any help would be appreciated. I found some people trying to implement for Android ran in similar issues but not this exactly
I was having the same issue, and after some research I realized that AmazonS3ClientBuilder is not part from AWS Android SDK instead of that the class is part of AWS JAVA SDK so you have to include this on your dependencies:
implementation 'com.amazonaws:aws-java-sdk:1.11.404'
Definitely the dependency as mentioned in Amazon documentation did
not work. The path to the dependency does not exist, in Maven central repository.
"software.amazon.awssdk" % "aws-java-sdk" % "2.0.0"
The following too, did not resolve com.amazonaws.services.s3.AmazonS3ClientBuilder, though the JAR path is correct in Maven central -
"software.amazon.awssdk" % "aws-sdk-java" % "2.1.3"
I had to fallback to the following as mentioned in the previous comment.
"com.amazonaws" % "aws-java-sdk" % "1.11.465"
As I mentioned in my comment - Amazon recommends moving to V2:
The AWS SDK for Java 2.x is a major rewrite of the version 1.x code base. It’s built on top of Java 8+ and adds several frequently requested features. These include support for non-blocking I/O and the ability to plug in a different HTTP implementation at run time.
All V2 examples have been thoroughly unit tested and work (V1 code examples are old).
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/example_code/s3
For people running Spring using Maven build, the pom.xml dependency you need to import com.amazonaws.services.s3.AmazonS3ClientBuilder; into the Java class is this:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.267</version>
</dependency>
The AWS Documentation is not correct, add this to your pom.xml file:
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-sqs</artifactId>
<version>1.11.1005</version>
</dependency>
The AWS Documentation is not correct, add this to your pom.xml file:
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
<version>2.15.32</version>
</dependency>

Class org.apache.cxf.jaxrs.client.WebClient in CXF 3.0.7

I am having trouble in figuring out which jar does WebClient class belongs.
In CXF 2.7 it was in cxf-bundle.jar, but in 3.0.7 I am unable to find it. I've been looking up jars for 2 hours but couldn't get anything.
Thanks!
I'll post my comment as answer:
Please take a look at:
org/apache/cxf/cxf-rt-rs-client/3.0.7/cxf-rt-rs-client-3.0.7.jar
I found this JAR by searching http://mvnrepository.com/ for WebClient-Artifact ID (which i found in the API-Docs for CXF):
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-client</artifactId>
<version>3.0.0-milestone1</version>
</dependency>
EDIT:
To find JAR's for specific packages, in most cases google is your friend:
Just google for (for example) org.apache.cxf.transport.servlet.CXFNonSpringServlet
But you can also search/analyze your local JAR's for this String (most ZIP-Tools support searching inside of ZIP/JAR-Files).
I was getting the error package org.apache.cxf.jaxrs.client does not exist,
Added dependecy
org.apache.cxf cxf-rt-rs-client 3.0.0-milestone1
issue resolved

Where is the Jetty ServletTester class packaged?

I am trying to follow this SO question which uses a Jetty ServletTester class.
I have spent all morning trying to locate the JAR that houses ServletTester to no avail. Even pulling down the aggregated "all JAR" doesn't turn up a *.testing package with that class in it. See for yourself, do a Maven/Gradle resolve for:
compile 'org.eclipse.jetty.aggregate:jetty-all-server:8.1.14.v20131031'
Even in their source code on GitHub it looks like there isn't a testing subproject, yet, in those JavaDocs above, it seems to exists somewhere...
Does anybody know where I can find the JAR that houses this class? If so, what is it, where/how do I acquire this JAR, and what did you do to figure this out (so I don't need to ask these types of questions again!)?
According to Maven Central, this class can be found in org.eclipse.jetty:test-jetty-servlet:8.1.16.v20140903:jar
Add the following dependency:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>test-jetty-servlet</artifactId>
<version>8.1.16.v20140903</version>
</dependency>
Also, you can use sites like Maven Central's find artifact by class name feature.

Broken example in Google Drive SDK quick start documentation

I need to develop an application that would be able to download a given document from Google Drive. I have found out that the recommended technology to use in the Java world is currently the Google Drive SDK.
As described by the quick start guide I have imported the required dependencies to my Maven project like this:
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev98-1.17.0-rc</version>
</dependency>
The official sample DriveCommandLine source code (to be found at the bottom of same page) refuses to compile with the following error messages:
The import com.google.api.client.json.jackson cannot be resolved (at DriveCommandLine.java, line 8),
JacksonFactory cannot be resolved to a type (at DriveCommandLine.java, line 27).
How do I fix it? I'm running Java version 1.7.
Apparently you need to import the following dependency as well in order for the code to work. It contains the JacksonFactory class.
<dependency>
<groupId>com.google.http-client</groupId>
<artifactId>google-http-client-jackson2</artifactId>
<version>1.16.0-rc</version>
</dependency>

Categories

Resources