Reputation: 281
I have a web app that I run locally in tomcat and which I have also deployed to Cloudbees. However, I am having some problems with cloudbees using a virtual host versus my local tomcat using a context path.
I access my local tomcat app via
http://localhost:8080/SpringMVC
In cloudbees, I access it via
So far so good, but the problem is when I try to do a submit. Locally, this submits successfully to
http://localhost:8080/SpringMVC/HelloWorld
But on cloudbees, it tries (and fails) to submit to
http://springmvc.shaunabram.cloudbees.net/SpringMVC/HelloWorld
If I manually modify the browser URL to
http://springmvc.shaunabram.cloudbees.net/HelloWorld
it all works fine.
I saw a similar problem posted here, but the suggested solution was to
I had thought the solution might be to use the CloudBees Web Configuration File to somehow configure the app to use (something like) http://springmvc.shaunabram.cloudbees.net/SpringMVC
as my base url, but I can't see any examples of that (all CloudBees Web Configuration File examples seem to be used for environment specific DataSources).
Any help greatly appreciated!
Shaun
Upvotes: 0
Views: 698
Reputation: 2633
Web application should never use absolute path and always build URL using ServletContext.getContextPath(). I wonder you hit this issue, assuming you use SpringMVC that handles this for you.
Or maybe you hard-coded some resources path, but should use to generate the adequate path, or a scriptlet to append context Path :
<c:url value="/style.css" var="url" />
<link rel="stylesheet" href="${url}" type="text/css">
or
<link rel="stylesheet" href="${pageContext.request.contextPath}/style.css" type="text/css">
see also Spring MVC Request URLs in JSP
Upvotes: 2
Reputation: 378
CloudBees runs your applications using a ROOT context path [/]. You have at least two options to make your app work in both your local environment and the Cloud environment:
Upvotes: 0