DVA-C02 Deployment Practice Question
A developer is using AWS CodeBuild to build a Java application. The build succeeds locally but fails in CodeBuild with the error 'BUILD FAILED: Unable to find a Java installation.' The buildspec.yml file includes a 'runtime-versions' section specifying Java 11. The CodeBuild project uses the 'aws/codebuild/amazonlinux2-x86_64-standard:4.0' image. What is the MOST likely cause of the failure?
⚠ Common exam trap
Candidates often assume 'java: 11' is a valid runtime identifier, but CodeBuild requires the exact runtime name (e.g., 'corretto11' or 'openjdk11'), and a formatting error in runtime-versions leads to a missing Java installation rather than a syntax error.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
The runtime-versions section in buildspec.yml is not correctly formatted.
The error 'Unable to find a Java installation' indicates that the CodeBuild environment does not have Java available at runtime. When using a standard managed image like 'aws/codebuild/amazonlinux2-x86_64-standard:4.0', Java must be explicitly declared in the 'runtime-versions' section of buildspec.yml. The most likely cause is that the 'runtime-versions' section is incorrectly formatted (e.g., using 'java: 11' instead of the correct 'java: corretto11'), causing CodeBuild to skip installing Java.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
The runtime-versions section in buildspec.yml is not correctly formatted.
Why this is correct
The runtime-versions section in buildspec.yml is crucial for specifying the language runtime environment, such as Java, that CodeBuild should provision. If this section contains incorrect YAML syntax or an unsupported version string, CodeBuild will fail to properly install or configure the specified Java Development Kit (JDK). This misconfiguration prevents the build environment from having the necessary Java runtime, leading to errors when build commands attempt to invoke Java or Maven.
- ✗
The CodeBuild project does not have sufficient permissions to download Java.
Why it's wrong here
CodeBuild project permissions, managed by the service role, primarily govern access to AWS resources like S3 buckets for source/artifact storage or ECR for Docker images. The process of installing Java within the build environment typically relies on the capabilities of the underlying CodeBuild Docker image, which either has Java pre-installed or uses internal package managers. Therefore, a lack of IAM permissions on the CodeBuild service role would not directly prevent the installation or availability of Java itself.
- ✗
The buildspec.yml file is not in the root of the source directory.
Why it's wrong here
By default, CodeBuild expects the buildspec.yml file to reside in the root directory of the source code repository. If the buildspec.yml is located elsewhere and its path is not explicitly configured in the CodeBuild project settings, CodeBuild will fail to find the build specification. This would result in a build failure indicating a missing buildspec.yml file, rather than an issue specifically related to Java installation or runtime availability.
- ✗
The build commands reference a non-existent Maven dependency.
Why it's wrong here
Errors related to non-existent Maven dependencies typically occur during the `mvn compile` or `mvn package` phases, *after* Java and Maven themselves have been successfully initialized and are operational. If the core issue is that Java is not installed or configured correctly, Maven would not even be able to start, resulting in a Java-related error message rather than a specific dependency resolution failure. Therefore, a Java installation problem precedes and is distinct from a Maven dependency issue.
Go deeper
Related to this question
About these practice questions
One of 724 original DVA-C02 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.