Search code examples
javaspringspring-mvcspring-securityjava-ee-6

What happens behind the scenes of deploying a Spring MVC application to tomcat outside of eclipse?


I guess a drawback of using such an awesome IDE like eclipse is that you miss the point for what happens behind the scenes of an application. I'm a ruby developer so not a java veteran. So I've been coding a project in java and using the spring framework for IOC and MVC. Can someone explain to me what is going on when I select run on server in eclipse? Because eventually I will be deploying this masterpiece of an application to a Linux server. Here is my setup. I am using Spring MVC 3 and the maven plugin in eclipse. In the pom.xml file, I have stuff like latest spring release version, log4j, spring mvc, spring context etc.

I have been testing my application on localhost using the handy option of run on server in the eclipse IDE. The server configuration in eclipse is pointing to the tomcat directory location for where I have installed tomcat 7. Please demystify what happens behind the scenes and what I will need to do if I want to deploy this application on a production server. The more detail the better. Thanks a ton in advance.


Solution

  • Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)

    1. Bundle your application in a .war with the correct format.
    2. Move the generated .war file to the /webapps directory of your Tomcat installation folder.
    3. Run the /bin/startup.[sh|bat] script in the Tomcat installation folder.

    Note that there are intermediate steps you can do to configure the deployment, like changing your context path. Go through the Tomcat documentation for details.

    In step 3, Tomcat will extract the .war contents to a directory in the /webapps folder with the same name as your .war file. It will use this as the context path. The script itself launches a java process by putting the WEB-INF/[class|lib|...] onto the classpath along with some Tomcat libraries.

    So Eclipse basically does all the steps above for you.