Reputation: 8348
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.
Upvotes: 4
Views: 2260
Reputation: 279990
Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)
.war
with the correct format..war
file to the /webapps
directory of your Tomcat installation folder./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.
Upvotes: 1
Reputation: 5001
All the majic happens in two places.
The first is your 'Servers' directory in the root of your Eclipse Package Explorer. These are your server configuration files that Eclipse will use (mostly) when it creates a new server instance.
The second is in the ./metadata/.plugins/org.eclipse.wst.server.core/ file system directory in your Eclipse workspace. This is where the tomcat application is actually deployed by eclipse.
The Tomcat Documentation is pretty good actually and helps explain how to do deployments. FYI, I do not know many people that use the Manager, from my experience most people deploy their applications by hand.
Upvotes: 0
Reputation: 6627
Ultimately you are deploying an web application that means you are deploying a war file to the server. Regardless of using frameworks like spring, struts anything.
SO a web application request starts from web.xml file. SO for spring mvc application, you are mapping all request coming from browser to DispatcherServlet and then this guy is responsible to manage whole life cycle of your application. For more details of how MVC works please see http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html
So in order to deploy your application (a war) on server first of all you have to create a war from your source code. You can go to traditional approach to use java given utility like using jar from command prompt or you can use ANT, GRADLE, MAVEN and such build tool that creates war for you in automated way. Spring is not doing anything extra for you. I believe you to research a bit more on how these tools works. Once a war is ready for you, you can simply go to tomcat UI and there you will find options to deploy your war.
I hope it helps you.
Upvotes: 0