How do I startup tomcat manually when it is configured in Eclipse?


Currently I have a java project setup in eclipse.  This project uses an instance of Tomcat that is configured to start through eclipse.  In order to run the project, I right click on my eclipse project, hit Run As -> Run on server.

How do I run tomcat manually, such that I do not have to do this process in eclipse?  I am looking to deploy my java project and start it manually without eclipse being part of the process (in regards to stopping/starting the server).
Who is Participating?

Improve company productivity with a Business Account.Sign Up

irf44zConnect With a Mentor Commented:
Another tip that would save you from copying the web application from the Eclipse Workspace to the 'webapps' directory:

After you copy and replace the configuration files, edit the file - <Tomcat Install Dir>\conf\server.xml, locate the "<Context" element for your project. (Hint: you can identify it using the path name in the element. It would be same as your Eclipse project name.)

Change docBase to the absolute location of your web application. See below for a sample config:

Before Change:
<Context docBase="/TestWeb" path="/TestWeb" reloadable="true" source="org.eclipse.jst.j2ee.server:TestWeb"/></Host>
After Change:
<Context docBase="D:/Eclipse_Workspace/TestWeb/TestWeb" path="/TestWeb" reloadable="true" source="org.eclipse.jst.j2ee.server:TestWeb"/></Host>

Open in new window

Do you mean how to start Tomcat from the command prompt? If so, run this bat file - <Tomcat Installation Directory>\bin\startup.bat
csciguy81Author Commented:
I do that, but the instance of tomcat starts up on a completely different port (8400) and my web app content is not there.

I'm looking to basically launch the exact same tomcat configuration/setup that is in eclipse when I click "Run on Server".
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

If you start up command prompt and go to the tomcat's bin folder, you can type "apache -" and it will give you available options to choose from. Here's what I believe should do the trick for you.

apache -k start
apache -k restart
apache -k stop

Hope this helps.
csciguy81Author Commented:
Going to the tomcat bin folder, and typing apache -k start results in a command not found error.

This is Apache Tomcat Version 6.0.14, the BlazeDS turnkey version.
irf44zConnect With a Mentor Commented:
oh ok.. got your question...

You need to do the following steps to start the server with the same configuration:
  1. Copy the files from <Eclipse Workspace Directory>\Servers\<Your Tomcat Server Config Directory>\*.*
      <Tomcat Installation Directory>\conf
    NOTE: Backup the files in <Tomcat Installation Directory>\conf before you replace the files.

   These is the server configuration used when you start the server from Eclipse.

  2. You need to manually copy the Web Application directory from your Eclipse Workspace to <Tomcat Installation Directory>\webapps

  3. Start the server via startup.bat. It should work.
export your app as a war and copy the war to tomcats webapp directory

csciguy81Author Commented:
How do I export my app as a war in Eclipse?  I'm unfamiliar with anything more than running it on the configured Tomcat server.

Is there a way to tell what is going on when I am running the project via eclipse, such as where it's copying files to?  I'm looking in the webapps directory of my tomcat install, but I don't see any project related files.  Does this mean it's running tomcat, but using the eclipse workspace directory as the context directory?
irf44zConnect With a Mentor Commented:
Eclipse doesn't copy files to webapps directory. It uses the workspace directory as the context directory.

Eclipse starts Tomcat with the following configuration:
<Your Eclipse Workspace Directory>\Servers\<Your Tomcat Server Config Directory>\server.xml

The webapp entry in server.xml points to the workspace directory.
csciguy81Author Commented:
Okay, I followed the earlier steps.  I copied the following from the workspace/servers/tomcat directory:

I went to edit the docbase in server.xml and I do not see any reference to the docbase inside of the server.xml.  Is this there by default?  Do I need to add it?
csciguy81Author Commented:
Adding that Context line worked, and I can now access localhost:8080 to see my app, which is good.

Last question.  If I want to deploy the war from eclipse, how would I do that, and would I then need to go back in and re-edit this server.xml file to reflect the code being contained in the war?
objectsConnect With a Mentor Commented:
> How do I export my app as a war in Eclipse?


you don't need to manually copy any filea]s, the war is all you need

objectsConnect With a Mentor Commented:
you don't need to change server.xml either

csciguy81Author Commented:
Would the server.xml context need to be changed in that case?
csciguy81Author Commented:
Whoops. sorry.

Great.  This is all very good.  Thanks for the help guys.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.