I am working on Spring boot application where I trying to deploy it on AWS ECS, Before that I tried it on local (Docker Desktop) where it is working fine but same correto8 image is giving below mentioned error on AWS ECS.
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration]; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/context/properties/bind/Bindable
This is the Docker file that I am using:
FROM amazoncorretto:8
# Copy your WAR file to the Tomcat webapps directory
WORKDIR /
COPY target/spring-boot-app*.war app.war
# Expose the default Tomcat port (8080)
EXPOSE 8080
ARG PROFILE
ENV PROFILE=${PROFILE}
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-amazon-corretto/jre
RUN chown 1000 app.war
RUN /bin/bash -c echo ${PROFILE}
USER 1000
CMD java -jar -Dspring.profiles.active=test -DskipTests /app.war
I guess this is related to maven classpath issue.
2
Answers
The error indicates a missing class issue, likely due to dependencies not being correctly packaged in your WAR file. To fix this, ensure all dependencies are correctly listed in your
pom.xml
and included in the WAR. Also, check for any conflicts in dependencies and verify that your Docker and ECS configurations are correct. Lastly, ensure your Spring profiles are set up correctly and consider adding more logging to diagnose the issue further.This may be a version conflict issue that is not defined in the pom.xml file.
This appears to be something that can happen if the version of the library referenced by the library being referenced in the project is not specified.