Solved

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

Posted on 2009-05-07
15
532 Views
Last Modified: 2013-12-15
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
Comment
Question by:csciguy81
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 2

Expert Comment

by:irf44z
ID: 24330525
Do you mean how to start Tomcat from the command prompt? If so, run this bat file - <Tomcat Installation Directory>\bin\startup.bat
0
 

Author Comment

by:csciguy81
ID: 24330538
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
 
LVL 4

Expert Comment

by:Ronb23
ID: 24330585
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
 

Author Comment

by:csciguy81
ID: 24330673
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
 
LVL 2

Assisted Solution

by:irf44z
irf44z earned 300 total points
ID: 24330697
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
 
LVL 2

Accepted Solution

by:
irf44z earned 300 total points
ID: 24330773
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
 
LVL 92

Expert Comment

by:objects
ID: 24332470
export your app as a war and copy the war to tomcats webapp directory

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:csciguy81
ID: 24356654
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
 
LVL 2

Assisted Solution

by:irf44z
irf44z earned 300 total points
ID: 24359061
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
 

Author Comment

by:csciguy81
ID: 24359595
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
 

Author Comment

by:csciguy81
ID: 24359871
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
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 24359882
> 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
 
LVL 92

Assisted Solution

by:objects
objects earned 100 total points
ID: 24359885
you don't need to change server.xml either

0
 

Author Comment

by:csciguy81
ID: 24359921
Would the server.xml context need to be changed in that case?
0
 

Author Comment

by:csciguy81
ID: 24359927
Whoops. sorry.

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

-Xmx and -Xms are the two JVM options often used to tune JVM heap size.   Here are some common mistakes made when using them:   Assume BigApp is a java class file for the below examples. 1.         Missing m, M, g or G at the end …
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now