2

I’m trying to develop a Spring 3 MVC application using the Springsource Tool Suite/Eclipse IDE.

My current application context in STS/Eclipse is /localhost:8080/realtyguide/

What I want is to access the application as root using just /localhost:8080/

I tried in eclipse.. Project > Properties > Web Project Settings > entered “/” for Context Root . But this just returned a “404 error - requested resource (/) is not available” after executing the app. And it also broke the app. So I just put context root back to 'realtyguide'.

I deployed the app to my webhost on a Tomcat server. I edited the server.xml’s and elements and so I was able to bring up the index page with the url www.mydomain.com.

However, the links to the other pages are broken. It is also not picking up the static resources for the index page like css and jquery files.

I believe this is caused by my app’s application context of /localhost:8080/realtyguide/ in eclipse (in my development pc). The rest of the pages returned by my controller has a url of /localhost:8080/realtyguide/page_name

How do I change my app’s application context to run as root in eclipse, as in simply /localhost:8080/. So that my pages would be called as simply /localhost:8080/page_name

Is the solution a setting I should make in my web or Spring configuration files or in eclipse?

I’ve tried googling this but have not found a clear, definitve answer. I am very new to this and a detailed answer from you will be of great help.

esoriano
  • 115
  • 3
  • 10
  • You may want to try the `root` context path with your app bundled as root.war as mentioned [here](http://www.coderanch.com/t/424290/Tomcat/deploy-Root-Tomcat-Website) – srkavin Nov 03 '11 at 23:48
  • Another related SO entry http://stackoverflow.com/q/715506/862441 – srkavin Nov 03 '11 at 23:50
  • I’m not sure if I wrote my question correctly. I was already able to deploy the app as root in tomcat and access the index page thru /www.mydomain.com/ My problem is that it is broken. It doesn’t pick up my css and js files and the page links are broken. I edited my post. Please see my edited post. – esoriano Nov 04 '11 at 01:25

4 Answers4

4

Thanks to the other answers provided. However, it doesn't address my main objective - to run the app as root inside eclipse.

This is how I was able to do it. I changed Tomcat's conyext path in eclipse.

Do the following:

  1. Right click on the server name from the Server Console > Open
  2. Click on the Modules tab
  3. Click on a module then click the Edit button
  4. Edit the entry for Path to the desired context path then click OK
JMax
  • 26,109
  • 12
  • 69
  • 88
esoriano
  • 115
  • 3
  • 10
0

Simply change server.xml in Tomcat Server.

  1. Package Explorer > Servers
  2. expend path Tomcat vX.X Server
  3. open server.xml
  4. go to Server > Service > Engine
  5. find your Context and change path to value "/"
  6. restart the server!
Jay Lim
  • 3
  • 3
0

You need to make your web-app the "default" application, ROOT. There are step-by-step instructions on the Tomcat Wiki, at http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F.

ruakh
  • 175,680
  • 26
  • 273
  • 307
  • I’m not sure if I wrote my question correctly. I was already able to deploy the app as root in tomcat and access the index page thru /www.mydomain.com/ My problem is that it is broken. It doesn’t pick up my css and js files and the page links are broken. I edited my post. Please see my edited post. – esoriano Nov 04 '11 at 01:26
0

One way is to name the war simply ROOT.war (uppercase). This works only if you deploy not from eclipse

If you have done your links/urls with <c:url> or <spring:url> then it should work without problems.

Ralph
  • 118,862
  • 56
  • 287
  • 383