-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Missing resource handling configuration when separate management context is configured #25113
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
Comments
I've spent some time trying to reproduce this issue, no success so far. With that project, you can run
In order to rewrite URLs in templates, Spring Boot is contributing a At this point I'm suspecting an error in your setup. If you believe this is a bug in Spring Boot, please build on top of my sample to have a minimal repro for this issue. Thanks! |
Thanks for your example @bclozel! I will take a look at it as soon I can and give you feedback. We also disabled the I will take a deeper look soon. |
@bclozel thanks for your sample project. I can not reproduce your sample project that http://localhost:8080 includes the CSS resource a hash suffix. Example curl request for the Note: The jsessionid=87F1FDB8CC4C56A613914C475F0EB70A is not the expected hash
Can you please provide the output of your curl? Big thx! |
Sorry I missed the important part in my repro: declaring the Now my sample shows:
Thanks, |
Thanks for your Example @bclozel. I took a first look into it and defined the But now to the strange part. If I run the application via
This is not strange at all. Because we now have duplicated beans. Ok. But if I build a war and let it run, everything works, no duplicated beans, and the hashes are there. But if I add the So what does the Maybe you have some hints for us, before we start debugging in this rabbit hole :) |
I don't understand why |
I thought the same. Will have a look at it tomorrow. Thanks for your help an input! |
Hi @bclozel, Our application is using springfox-boot-starter in version 3.0.0 and it seems that there is an issue running managment server on a different port. I don't know why, but in https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java#L140 there are just beans available e.g. I checkt the springfox autoconfiguration. In https://github.com/springfox/springfox/blob/master/springfox-boot-starter/src/main/java/springfox/boot/starter/autoconfigure/SwaggerUiWebMvcConfigurer.java#L20 there is a registration of an additional ResourceHandler. I don't get it why running the management server on the same port is working and on a different port not. Big thanks for your support mate! |
I replaced SpringFox with SpringDoc and I have the exact same behaviour see https://github.com/synyx/urlaubsverwaltung/tree/springdoc and if I remove both, springfox and springdoc, everything is working as expected. So why and what does the change of the @bclozel are there different RessourceHandler if I add |
At this point it seems we've established that this is likely to be an issue with those libraries, not Spring Boot. I'll leave this issue opened until we have a better understanding. Please provide the requested information: the auto-configuration reports for both variants (with the hash and without it). This should help us narrow down the source of the problem. |
Hey @bclozel,
a ResourceHandler is added via If you debug into https://github.com/spring-projects/spring-framework/blob/master/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java#L140 with a different I also added the debug output with and without different ports and a diff of it. with-resource-handler-and-management-the-same.log |
I gave it another try after thinking about it, and thought why not downgrade to the latest version thiat is working, because I had the feeling that it is a Spring Boot bug. And there it is I can only reproduce the bug with Spring Boot 2.4.2 and 2.3.8. With 2.4.1 and 2.3.7 and added I added another PR to your example where I downgraded the application to 2.4.1 see bclozel/gh-25113#2 |
Thanks for helping out here, this is a hard one to figure out. To reproduce this issue, we need the following:
The sample application is here. Here's what's happening:
The expected order is to switch 4) and 3) so that Spring Boot's resource handling configuration is detected. I think this could be related to #24748 (and since this is a forward port, its parent issues). It seems that having a parent/child context setup involves an event being fired before the resource handling configuration is processed in the parent. We'll need more time to figure out what is the problem exactly - I'll update my sample application right away. Thanks! |
spring.web.resources.chain.strategy.content.*
does not work if management.server.port != server.port
Good Morning @bclozel, that was a nice journey with you. Thanks for your time and support! :) |
While something might have changed in Spring Boot that alters the ordering of those parent/child context events in some way, we've found that the main issue here is that the We're closing this issue and marking it as superseded by spring-projects/spring-framework#26561 (and spring-projects/spring-framework#26562 for the backport). This will be fixed in Spring Boot 2.4.4, since it will pick up the upcoming Spring Framework 5.3.5 release. |
If we configure the
management.server.port
and this one is not equal toserver.port
viaspring.web.resources.chain.strategy.content.*
generation of the hash does not work and we do not get the correct hashs on the files. If there are some information about this in docs please hint me to it. Otherwise here are an example how to reproduce it:Id you start this docker-compose file everything will be configured for you and the hashing of the assets in
/css/**
e.g. does work.Take a look at http://localhost:8080/login with the developer console in Chrome/Firefox e.g. and see that the
style.css
e.g. does have a hash and if we add theMANAGEMENT_SERVER_PORT=8081
we do not see the hashes.The
common.$hash.css
file can be ignored this is not placed in/css/**
and will be generated via webpack.But know if I add the
management.server.port
the hash of/css/**
files e.g. is not generatedThe default application properties that we add in the given docker container can be seen here https://github.com/synyx/urlaubsverwaltung/blob/master/src/main/resources/application.properties#L30
Do you have any information for us, if this is a common behaviour and how we can achieve having hashed css files and split the server and management port?
Hint: This is independent from docker. I have the same behaviour via ide, 'java -jar ...' and so on :-)
The text was updated successfully, but these errors were encountered: