• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Running Tomcat from Eclipse

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have installed tomcat 7 as a windows service and it starts and runs perfecting well as a service (ie i can see status, manageer view perfectly well using internet explorer)

I also have a Java web app that has this server associated with the project in eclipse.

The problem i have is that when i already have tomcat running as a service and then try 'Run as' >run on server - in eclipse for my web app - the eclipse console window looks like it going through the motions of
attempting to start the tomcat server itself (see console window output below)

Mar 06, 2012 9:16:21 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["http-bio-8080"]
Mar 06, 2012 9:16:22 AM org.apache.coyote.AbstractProtocol pause
INFO: Pausing ProtocolHandler ["ajp-bio-8009"]
Mar 06, 2012 9:16:23 AM org.apache.catalina.core.StandardService stopInternal
INFO: Stopping service Catalina
Mar 06, 2012 9:16:23 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["http-bio-8080"]
Mar 06, 2012 9:16:24 AM org.apache.coyote.AbstractProtocol stop
INFO: Stopping ProtocolHandler ["ajp-bio-8009"]
Mar 06, 2012 9:16:25 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["http-bio-8080"]
Mar 06, 2012 9:16:25 AM org.apache.coyote.AbstractProtocol destroy
INFO: Destroying ProtocolHandler ["ajp-bio-8009"]



Shortly after which an error message is displayed in eclipse -

Starting Tomcat v7.0 at localhost has encountered a problem.
Server Tomcat v7.0 Server at localhost failed to start.

Ok - so i naturally guess that this is likely because the server is already started, so my first thought it to stop the windows service that is running my tomcat server and simply let eclipse start it on its own.

This starts the server from eclipse perfectly well - although i cannot simply type localhost:8080 in IE but need to use the webapp project name to see my project, i cannot get to status or manager page.

My question is - is there a way to have my tomcat service always running and use it in eclipse also or do i need to keep going through the hassle of stopping my tomcat windows service first.

Thanks
Steve



 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can debug any external application - not just Tomcat - from Eclipse, any other IDE with debugging capabilities, or for that matter, from a command line using the jdb program that comes with the JDK.

The secret is that you must start the JVM with debugging enabled. If you look at the Tomcat startup scripts, you'll see that there's a special startup option "jpda" that enables remote debugging. When Tomcat is launched with remote debugging enabled, its JVM will listen on the port indicated by JPDA_ADDRESS (8000, by default) for a debugger to connect to it.

Use Tomcat's Run/Debug Configuration dialog to create a debug profile for Remote Java Debugging. Connect to localhost, port 8000. Set your breakpoints as desired. You can use this to debug both Tomcat-deployed webapps and Tomcat itself.
 
Steven Barn
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thankyou for your reply - i have installed tomcat as a windows service so i'm not sure i have access to the startup scripts. Previously i had installed just the binaries and setup everything to work from startup.bat, which worked fine but i just
thought that the windows service looked neater and was the preferred way on a recent Java course - any thoughts on the preferred way to run tomcat (either from the .bat file or as a windows service) ?

Could you point me in the right direction for the startup scripts (if they are accessible under my current setup) or if i need to re-install tomcat not as a service.

Thanks
Steve
 
Tim Holloway
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steven Barnacle wrote: any thoughts on the preferred way to run tomcat (either from the .bat file or as a windows service) ?



Yeah. As a Linux service.

Sorry. Couldn't help it. There isn't enough money in the world to persuade me to be a Windows Security Administrator. I'd spend it all on antacids and tranquilizers. Granted, things are much improved these days, and Linux is no longer too insignificant to be safe from attackers, but it's a matter of basic architecture. Unix was created from a commercial OS concept then grew up in college labs where students routinely tried to do nasty things to each other on a shared computer. Windows grew up in an environment where only one person was operating the machine and getting programs to control other programs was a key benefit with no worry about malice or practical jokes (except maybe from Bill Gates). There are 1 or 2 basic security holes down deep inside of Windows that cannot be fixed because almost every Windows app that was ever written would break. So the machines I place in harm's way don't run Windows.

Unfortunately, that also means that I'm not as familiar with the Tomcat wrapper for Windows as I might be.

But the straight answer to your question is that I'd use the Windows Service for (shudder) production Windows machines. I'd usually use the command line when doing development. Although for a lot of development, my IDE manages Tomcat. I use the sysdeo plugin, however, not WTP, which is horrible. So I can't use the "run on server" menu option, I click on the kitties instead.

Regardless, I'm fairly sure that if you create a TOMCAT_HOME/bin/setenv.bat file and put your environment assignments in it, they'll be picked up and used regardless of whether Tomcat is started as a service, started from the command line or started by sysdeo. I'm less certain that WTP will see them, though. WTP doesn't see a lot of important things, which is why I hate it.

So, to boil it all down. On a development machine, it's usually not advisable to run Tomcat as a Service. Let the development system manage it. It has finer-grained controls and a debugging environment. The exception is when you actually want to mimic the production environment for final pre-deployment testing.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic