Java IoT connection kit won't build...

0

I have successfully created an IoT device and was able to make it work with Windows and Python SDK. I then wanted to see how the Java code worked so I selected Windows and the Java SDK and on this page https://us-east-2.console.aws.amazon.com/iot/home?region=us-east-1#/connectdevice/, clicked next and selected the device which I had already set up and have working in Python. I clicked Next Step and clicked the link to download the Java SDK. I extracted the Java SDK and started a windows Power Shell. I unzipped the downloaded SDK, changed directory to it, ran the change to the execution policy "Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process" and then ran start.ps1. The example fails to build with the error:

[INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.373 s [INFO] Finished at: 2022-04-28T15:29:22-07:00 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal on project aws-iot-device-sdk-java-samples: Could not resolve dependencies for project com.amazonaws:aws-iot-device-sdk-java-samples:jar:0.0.1-dev: Could not find artifact com.amazonaws:aws-iot-device-sdk-java:jar:0.0.1-dev in central (https://repo.maven.apache.org/maven2) -> [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

Any ideas how to fix this?

Lehrian
asked 2 years ago733 views
2 Answers
0
Accepted Answer

The following processes are performed in the PowerShell script.

  1. (If root-CA.crt file does not exist) Obtain root CA
  2. (If aws-iot-device-sdk-java directory does not exist) Get aws-iot-device-sdk-java from GitHub and build it
  3. connect to AWS IoT Core

In my environment, the tests performed in step 2 of the build procedure fail, so the required modules were not created.

I changed the PowerShell script so that the test is skipped.

mvn install --% -Dgpg.skip=true 

to

mvn install --% -Dgpg.skip=true -Dmaven.test.skip=true

After removing the aws-iot-device-sdk-java directory, I re-ran the PowerShell script and the module was correctly generated and connected to AWS IoT Core.

profile picture
answered 2 years ago
  • Thanks for this tip. I saw the test errors but assumed they could safely be ignored. That is not the case. I added -Dmaven.test.skip=true to the mvn install line but it didn't immediately solve the issue. I had to delete the existing directory and rerun the script so it would download everything fresh and then it started working.

0

I faced the same issue today in ubuntu ec2 instance. The issue turns out that in start.sh, we have the following commands which did not get executed

# install AWS Device SDK for Java if not already installed
if [ ! -d ./aws-iot-device-sdk-java-v2 ]; then
  printf "\nInstalling AWS SDK...\n"
  git clone https://github.com/aws/aws-iot-device-sdk-java-v2.git --recursive
  cd aws-iot-device-sdk-java-v2
  mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*"
  mvn clean install -Dmaven.test.skip=true
  cd ..
fi

I did these steps manually once and after that, it worked.

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions