Enterprise Java

AWS CodeBuild Error: Unable to access jarfile

Using AWS CodeBuild, I was using a buildspec that was to run an executable JAR file to execute JUnit tests. Here is my buildspec:

1
version: 0.2 env:   secrets-manager:     CLIENT_ID: AppSecrets/someapp:CLIENT_ID     CLIENT_SECRET: AppSecrets/someapp:CLIENT_SECRET phases:   install:     runtime-versions:       java: corretto11   build:     commands:       - echo $CLIENT_ID       - echo $CLIENT_SECRET       - java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package="com.wall.steve"

As you can see, I am making use of AWS Secrets Manager to get a couple properties that are passed as system variables to the JUnit execution.

When this Build would run it would fail. In the logs I would see the following error:

1
[Container] 2020/10/16 14:18:55 Running command echo $CLIENT_ID *** [Container] 2020/10/16 14:18:55 Running command echo $CLIENT_SECRET *** [Container] 2020/10/16 14:18:55 Running command java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package="com.wall.steve" Error: Unable to access jarfile from [Container] 2020/10/16 14:18:56 Command did not exit successfully java -jar -DclientId=$CLIENT_ID -DclientSecret=$CLIENT_SECRET junit-platform-console-standalone-1.7.0.jar -cp myapp.jar --select-package="com.wall.steve" exit status 1 [Container] 2020/10/16 14:18:56 Phase complete: BUILD State: FAILED

Answers on Stack Overflow on the “Unable to access jarfile” error mostly talked about access/permission on the JAR file itself. This was not my issue.

In my case, the error was caused because the values I had set in AWS Secrets Manager for the Client ID and Client Secret were not correct. Once I set the correct values, my Build passed!

Published on Java Code Geeks with permission by Steven Wall, partner at our JCG program. See the original article here: AWS CodeBuild Error: Unable to access jarfile

Opinions expressed by Java Code Geeks contributors are their own.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button