Hi Team,
Recently, I came across an issue where a forward slash ('/') gets automatically added before the context path or something is wrong with context-path not really sure what it is.
In my application, I have set a custom context path
server.servlet.context-path=/{contextPath}
Application URL: https://{domain}/{contextPath}/{endpoint}
So, when I am deploying the application in the cloud (GKE Cluster) and trying to run this in dev env with an endpoint /{endpoint} I am getting an illegalArgumentException saying
invalid context : '/{contextPath}' must match the start of request path: '//{something/{endpoint}'.
But on the same side, I change the application URL to https://{domain}/{contextPath}{endpoint} from https://{domain}/{contextPath}/{endpoint} it works fine. I hope you can notice the small change, which is only happening with Spring Boot v2.6.3 (tired with other versions as well, all works as expected)
The change for v2.6.3 https://{domain}/{contextPath}~/~{endpoint}. But everything works well in my local.
In local, I can get the expected response from the expected URL itself http://localhost:{port}/{contextPath}/{endpoint} this works totally fine.
I hope, this issue gets addressed soon. Thank you
Comment From: wilkinsona
Thanks for the report. Unfortunately, I'm not sure that I fully understand the problem that you've describde so I don't know how I would go about diagnosing it. For example, it sounds like you're saying that the problem is specific to GKE, but I'm not certain of that. I can also tell that it's a servlet-based web application but you haven't told us whether you're using Jetty, Tomcat, or Undertow.
If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. Also, if the problem is specific to GKE, we'll need precise instruction on how to deploy the application to reproduce the problem.
Comment From: pawank0411
Thanks for the reply. I am not sure whether the problem is specific to the GKE cluster or Spring Boot. But as the with same deployment steps, another Spring version (2.3.1.RELEASE) works perfectly well. So, here it seems the problem is going towards Spring Boot v2.6.3
Yes, it's a servlet-based application that uses a Tomcat server.
Comment From: snicoll
@pawank0411 please take the time to read the reply that requests you to share a sample. It is in the second paragraph.
Comment From: pawank0411
Thank you team.
There was issue with my dev env configuration.
The issue is fixed.
Comment From: erinreeves
@pawank0411 What was the issue in your dev env configuration? I too am running into the similar/same error.