Visualizzazione post con etichetta web application. Mostra tutti i post
Visualizzazione post con etichetta web application. Mostra tutti i post

giovedì 24 marzo 2016

How to move a web project from Glassfish to Tomcat?

Today I stumbled upon a web project that was configured for Glassfish instead of Tomcat. Since I am very fond of Tomcat, which integrates perfectly with my Eclipse IDE, I did not want to change my forma mentis and tools just to comply with the former configuration.

Unfortunately, when I tried to launch the project, it was not reading properly static resources (e.g., CSS files), since Glassfish has an XML configuration file (which is a substitute of the plain old web.xml file) in which you specify the context root of your project, i.e.:

http://localhost:8080/context-root/the-page-you-want

Tomcat is configured so as to use as context root the name of the project. So, how to fix this?
A solution can be found here, and is applied as follows:

  1. Project -> Properties -> Web Project Settings
  2. Modify the context root with the name you want and confirm
  3. Stop Tomcat
  4. Clean the Tomcat server by right-clicking on the server itself and selecting Clean
  5. Restart the server
  6. Confirm that you want to change the context root
...and you are done!