Home » Java » Enterprise Java » AWS CodeBuild Error: Unable to access jarfile

About Steven Wall

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:

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:

[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.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!


1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design


and many more ....


Receive Java & Developer job alerts in your Area

I have read and agree to the terms & conditions


Notify of

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

Inline Feedbacks
View all comments