Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-info.properties is generated in a different path causing errors with BuildProperties bean #30148

Closed
AlbertoCortina opened this issue Mar 9, 2022 · 3 comments
Labels
status: duplicate A duplicate of another issue

Comments

@AlbertoCortina
Copy link

AlbertoCortina commented Mar 9, 2022

Versions used
Spring boot 2.6.4
Java 17
Gradle 7.4

Description of the bug
Starting from Spring boot 2.6.4 the build-info.properties file is generated in a different path causing the application to fail when it's deployed in a servlet container and you are using a BuildProperties bean.

demo_264-app-1  |       Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloWorldController' defined in file [/usr/local/tomcat/webapps/demo/WEB-INF/classes/com/example/demo/HelloWorldController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.info.BuildProperties' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

Structure of the war using Spring boot 2.6.4
image

Structure of the war using Spring boot 2.6.3
image

How to reproduce the error
demo_2.6.4.zip
demo_2.6.3.zip

Download both projects (basically they are the same project just changing the Spring boot version) and run the following command in both of them. After it finishes you can compare the wars created under build/libs folder and check that the path of the file is different.

$ ./gradlew bootWar

Also, to check the error produced when you run the war created by the project on a servlet container, you can find a docker-compose file that you can execute after generating the wars, and you will see the error at startup on the version using Spring boot 2.6.4

$ ./gradlew bootWar
$ docker compose up

image

@AlbertoCortina AlbertoCortina changed the title build-info.properties is generated in a different location causing errors with BuildProperties bean build-info.properties is generated in a different path causing errors with BuildProperties bean Mar 9, 2022
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 9, 2022
@wilkinsona
Copy link
Member

Sorry for the inconvenience. This has already been fixed in the latest 2.5 and 2.6 snapshots.

Duplicates #30026.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 9, 2022
@flyingfishflash
Copy link

flyingfishflash commented Mar 27, 2022

@wilkinsona Perhaps this is a separate issue, but with spring-boot 2.6.5 and gradle :bootJar, I'm still seeing the behavior where build-info.properties is placed in /META-INF rather than /BOOT-INF/classes/META-INF/.

This cause actuator/info endpoint to return nothing.

@wilkinsona
Copy link
Member

That would be a separate issue as this issue concerned a war deployed to a Servlet container.

The properties file is loaded from classpath:META-INF/build.properties. Both the root of the jar and BOOT-INF/classes are on the classpath so the file should be found from either location.

If you’d like us to investigate the problem that you are seeing, please open a new issue with a minimal sample that recreates it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants