• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 560
  • Last Modified:

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

All,

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).
0
csciguy81
Asked:
csciguy81
  • 7
  • 4
  • 3
  • +1
5 Solutions
 
irf44zCommented:
Do you mean how to start Tomcat from the command prompt? If so, run this bat file - <Tomcat Installation Directory>\bin\startup.bat
0
 
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".
0
 
Ronb23Commented:
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.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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.
0
 
irf44zCommented:
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>\*.*
       to
      <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.
0
 
irf44zCommented:
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

0
 
objectsCommented:
export your app as a war and copy the war to tomcats webapp directory

0
 
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?
0
 
irf44zCommented:
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.
0
 
csciguy81Author Commented:
Okay, I followed the earlier steps.  I copied the following from the workspace/servers/tomcat directory:
catalina.policy
catalina.properties
context.xml
server.xml
tomcat-users.xml
web.xml

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?
0
 
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?
0
 
objectsCommented:
> How do I export my app as a war in Eclipse?

File>Export...

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

0
 
objectsCommented:
you don't need to change server.xml either

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

Great.  This is all very good.  Thanks for the help guys.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 4
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now