Getting started with AWS SDK for Java - java

I'm very new to the AWS SDK for Java. I'm trying to get started with the AWS SDK for Java 2.x following the documentation here (https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html#get-started-projectsetup)
But when I tried to create a project as mentioned here using the following command
mvn -B archetype:generate \-DarchetypeGroupId=org.apache.maven.archetypes \-DgroupId=com.example.myapp \-DartifactId=myapp
I'm getting an error:
PS C:\Users\robert\Desktop> mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.example.myapp -DartifactId=myapp
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.100 s
[INFO] Finished at: 2021-08-09T12:26:24-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:\Users\robert\Desktop). Please verify you invoked Maven from
the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectExceptio
How to create a maven project and get started with aws sdk?

Do you have / chars in the command. If so, you need to use this command:
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=com.example.myapp -DartifactId=myapp
I'm using JDK 1.8 and this command is successful.

In Powershell you can't have the period (dot or full stop character) in your command line arguments. The instructions on that page lack this information and assume either a Unix-like environment or the cmd environment. You should run:
mvn -B archetype:generate "-DarchetypeGroupId=org.apache.maven.archetypes" "-DgroupId=com.example.myapp" -DartifactId=myapp

Related

AWS SAM Unable to access Maven package published on Github Package

I have successfully published a Maven Package to Github Packages.
Looks like this on the Github packages page:
<dependency>
<groupId>com.conectar.meetings</groupId>
<artifactId>github-meetings-serverless-lib</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
But when I try to use this package in my AWS SAM application, I get an error trying to install it.
It fails on the build step of my SAM app even though I supply the GITHUB_TOKEN as an env var:
- name: SAM Build for Prod Environment
run: |
cd $GITHUB_WORKSPACE
sam build --parameter-overrides EnvStage=prod TableName=${{ secrets.PROD_DB_TABLENAME }} && sam package --s3-bucket ${{ secrets.PROD_AWS_DEPLOY_BUCKET }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
Here's the build error:
Downloaded from central: https://repo.maven.apache.org/maven2/software/amazon/ion/ion-java/1.0.2/ion-java-1.0.2.jar (565 kB at 333 kB/s)
Downloaded from central: https://repo.maven.apache.org/maven2/org/apache/httpcomponents/httpclient/4.5.12/httpclient-4.5.12.jar (778 kB at 458 kB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.056 s
[INFO] Finished at: 2021-03-12T12:55:57Z
[INFO] ------------------------------------------------------------------------
Error: Failed to execute goal on project CreateMeeting: Could not resolve dependencies for project CreateMeeting:CreateMeeting:jar:1.0: Could not find artifact com.conectar.meetings:github-meetings-serverless-lib:jar:0.0.1-SNAPSHOT -> [Help 1]
Error:
Error: To see the full stack trace of the errors, re-run Maven with the -e switch.
Error: Re-run Maven using the -X switch to enable full debug logging.
Error:
Error: For more information about the errors and possible solutions, please read the following articles:
Error: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Error: Process completed with exit code 1.
Why can't it find the artifact?
I expect it to use the GITHUB_TOKEN to authenticate the build, but it seems to not be using that.
The package is published in the same repo where Github action is also running.
How do I make AWS SAM know about this Github Package?

Maven Sonarqube plugin: Unable to execute SonarQube: Fail to get bootstrap index from server

I'm having an headache setting up the sonarqube maven plugin for a project.
So I have a sonarqube instance let's say on https://sonarqube.mycompany.software. I test many projects on this instance, it's working well since months.
I also have other projects that use the maven plugin (but use another docker image to run)
I start a new project, and of course I want to add to my automatic pipeline that checks the code with sonarqube.
Everything runs perfectly when I execute the maven plugin on my machine, with the OpenJdk-8:
$ mvn org.jacoco:jacoco-maven-plugin:0.8.5:prepare-agent clean test package
$ mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew
[... Lots of output ...]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 16.891 s
[INFO] Finished at: 2020-05-07T18:03:00+02:00
[INFO] ------------------------------------------------------------------------
Then I try to execute the exact same command with docker on the server (where the pipeline will run), using the maven:3.6.3-jdk-8 image, I get this error:
$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8 mvn sonar:sonar -Dsonar.projectKey=projectname -Dsonar.host.url=https://sonarqube.mycompany.software -Dsonar.login=youwishyouknew
[INFO]
[INFO] ---------------------------< software.mycompany:projectname >----------------------------
[INFO] Building projectname 2.3.0
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- sonar-maven-plugin:3.7.0.1746:sonar (default-cli) # projectname ---
[INFO] User cache: /root/.sonar/cache
[ERROR] SonarQube server [https://sonarqube.mycompany.software] can not be reached
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.286 s
[INFO] Finished at: 2020-05-07T16:06:22Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project projectname: Unable to execute SonarQube: Fail to get bootstrap index from server: Broken pipe (Write failed) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
When I Execute this, absolutely nothing is happening in the Sonarqube logs (nothing moves at all in any log, while when I run it on my machine I find everything I expect to find.)
Furthermore, if I try to curl the sonarqube server from the docker image, it works! Tried with ping too.
$ docker run -v `pwd`/m2cache:/root/.m2 -v `pwd`/sonarcache:/root/.sonar/cache -v`pwd`:`pwd` -w`pwd` maven:3.6.3-jdk-8 curl https://sonarqube.mycompany.software
<!doctype html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" charset="UTF-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"><link rel="apple-touch-icon" href="/apple-touch-icon.png"><link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png"><link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
[... And a lot more output ... ]
It responds with the sonarqube index page as I expect.
As far as I can see, there is no proxy setting in the docker maven image.
This is quite frustrating.
Has anybody any clue on what is going on here and how to fix this?
[EDIT] So I've tried many things, and one worked: using another docker image. In particular, I've tried all the available maven jdk-8 images available here: https://hub.docker.com/_/maven, and one actually worked, while all other failed: maven:3.6.3-ibmjava-8.
It looks like a java-8 related problem, since all JDK 11 images instead do work as expected. Unfortunately the project is in Java 8 and everything breaks when upgrading the JVM :-)
I leave this here as a work-around, but still, I would like to know why it fails with other docker images and how to fix this in the future.
I had this issue too with maven and gradle sonarqube analysis, i have only this issue with jdk8-u252+.
Maven 3.6.3 official image have jdk8-u262.
For me, with maven 3.5.2 it's ok (jdk-u232).
For the root cause, it could be the javax.net.ssl new features shipped in u252 : https://www.oracle.com/java/technologies/javase/8u251-relnotes.html

Issue installing jhipster-registry

Excuse my lack of technicality concerning this matter, as i am a solely beginner.
so I'm trying to install a microservice application, so in order to do that , I need to install both gateway and microservice app and linked them through jhipster-registry(correct me if I'm wrong please).
now I've installed both of these apps succesfully. for the gateway I get this message message well presented through html "Your request cannot be processed" when i navigate to the localhost provided by the gateway console while getting this :
---------------------------------------------------------
Application 'gateway2' is running! Access URLs:
Local: http://localhost:8080/
External: http://192.168.56.1:8080/
Profile(s): [dev, swagger]
----------------------------------------------------------
2020-05-03 07:08:14.483 INFO 7600 --- [ restartedMain] com.mservice.app.Gateway2App :
----------------------------------------------------------
Config Server: Not found or not setup for this application
----------------------------------------------------------
same "Config Server" message I've gotten in the microservice app after the mvnw command
issue was when i run mvnw in this jhipster-registry folder I get this error in the end, now I've gone through some github issue and found contributors advising to run maven globaly sort of see if it's an environment issue, well nothing changed about the error.
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 54.986 s
[INFO] Finished at: 2020-05-03T07:00:00Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project jhipster-registry: Fatal error compiling: invalid flag: --release -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
maybe useful informations : I'm using JWT security, PosgreSQL database(and it's succesfully linked), havent implemented any entity in neither of the apps, I'm not using any docker
and if I'm understanding something worng, please point it out I would love for it to make sense.

CircleCI and Could not find goal 'go' in plugin org.apache.maven.plugins:maven-dependency-plugin:3.0.2

I try to run tests on multi modular spring project with leverage of CircleCI
I don't know why it's happen but when I try to run my spring boot project on CircleCI I get
[INFO] Reactor Summary for sfg-pet-clinic 0.0.5-SNAPSHOT:
[INFO]
[INFO] sfg-pet-clinic ..................................... SKIPPED
[INFO] pet-clinic-data .................................... SKIPPED
[INFO] pet-clinic-web ..................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.602 s
[INFO] Finished at: 2018-11-11T19:25:39Z
[INFO] ------------------------------------------------------------------------
[ERROR] Could not find goal 'go' in plugin org.apache.maven.plugins:maven-dependency-plugin:3.0.2 among available goals analyze, analyze-dep-mgt, analyze-duplicate, analyze-only, analyze-report, build-classpath, collect, copy, copy-dependencies, display-ancestors, get, go-offline, help, list, list-repositories, properties, purge-local-repository, resolve, resolve-plugins, sources, tree, unpack, unpack-dependencies -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoNotFoundException
Exited with code 1
but when I do tests manually, via Intellij everything is fine
this is my config.yml
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/openjdk:8-jdk
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/postgres:9.4
working_directory: ~/repo
environment:
# Customize the JVM maximum heap limit
MAVEN_OPTS: -Xmx3200m
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: mvn dependency:go -DskipTests
- run: mvn dependency:go-offline
- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}
# run tests!
- run: mvn integration-test
mvn dependency doesn't have a goal named 'go'. So the below line will fail.
run: mvn dependency:go -DskipTests
Please refer https://maven.apache.org/plugins/maven-dependency-plugin/

MojoExecutionException when trying to profile netbeans project

There's about a million bug reports regarding the issue on NetBeans bug tracker but none of them brought me a resolution.
The issue is that when I try to profile my program, like this:
I get this:
cd C:\MYSELF\programing\java\AutoCall\AutoClient; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_31" cmd /c "\"\"C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\maven\\bin\\mvn.bat\" -Dexec.args=\"-agentpath:C:/Users/Jakub/AppData/Roaming/NetBeans/7.4/lib/deployed/jdk16/windows-amd64/profilerinterface.dll=C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\lib,5140,10 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\\MYSELF\\programing\\java\\AutoCall\\AutoClient\\nbproject\\private\\profiler -classpath %classpath cz.autoclient.Main\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_31\\bin\\java.exe\" -DnetbeansProjectMappings= -Dmaven.ext.class.path=C:\\Users\\Jakub\\AppData\\Roaming\\NetBeans\\7.4\\maven-nblib\\netbeans-eventspy.jar org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...
------------------------------------------------------------------------
Building Auto Client 3.0
------------------------------------------------------------------------
--- exec-maven-plugin:1.2.1:exec (default-cli) # autoclient ---
Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 14)
Profiler Agent Error: Timed out trying to establish connection with client
Profiler Agent: Initializing...
Profiler Agent: Options: >C:\Users\Jakub\AppData\Roaming\NetBeans\7.4\lib,5140,10<
Profiler Agent: Initialized successfully
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 12.012s
Finished at: Sun Jan 03 20:57:36 CET 2016
Final Memory: 5M/75M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project autoclient: Command execution failed. Process exited with an error: -1 (Exit value: -1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
This error seems to happen at random - I had several successful profiling sessions, then it happened again.
I was having the same problem, when I tryed to start the netbeans profile to analyze memory, I got the follow message:
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project saf-desktop: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec are missing or invalid -> [Help 1]
So, instead to run de profile mode, I started the application normally and then, I atached the profile mode in the currenty runnig main application.
Increase the timeout. Run netbeans with the following argument:
netbeans64.exe -J-Dprofiler.agent.connect.timeout=60
See https://blogs.oracle.com/nbprofiler/entry/tweaking_profiler_timeouts

Categories

Resources