Tomcat5 windows服务不能启动的终极解决方法

本人多次碰到这个问题,在网上搜索很久,一直没有找到真正的解决方法。今天下午一次偶然的机会发现了问题所在,根据问题,提出以下解决方案。

问题所在:

现在很多人都在使用jdk的压缩版,使得tomcat服务不能正确设置java VM,导致tomcat服务不能正常配置和启动。如果你是安装版jdk也出现启动问题,请参照以下方法解决。

假设

jdk安装目录为d:\j2sdk

tomcat5安装目录为D:\Program Files\Apache Software Foundation\Tomcat

5.0

1.配置环境变量:

JAVA_HOME = d:\j2sdk

CLASSPATH

= %JAVA_HOME%\bin;.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_H OME%\lib\tools.jar

CATALINA_HOME = D:\Program Files\Apache Software Foundation\Tomcat 5.0

2.配置Tomcat服务

这里有两种情况,一是tomcat5为安装版,二是解压版,针对这两种情况分别解决。

(1)安装版tomcat5

在安装时选择安装tomcat服务,如图

安装完成后,打开注册表regedit.exe,找到

HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat ServiceManager\Tomcat5\Parameters,你可以看到里面有很多参数值,主要是修改Java项的值为d:\j2sdk\jre\bin\server\jvm.dll,修改正确后,你就可以通过开始->程序->Apache Tomcat 5.0->start tomcat启动服务了。若没有若没有此项,可以依照以下方法设置参数。

(2)解压版tomcat5

这时你要先配置服务所用的参数,启动命令是tomcat5的bin目录下的tomcatw.exe(后面附上tomcatw.exe命令参数)。

如果不存在HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software

Foundation\TomcatServiceManager\Tomcat5\Parameters,请先创建,这一步是关键。

使用命令tomcatw.exe //ES//Tomcat5打开配置窗口,如下

设置参数如下:

Service栏

Description = Apache Tomcat 5.0(这个可以随便写)

Image Path = d:\Program Files\Apache Software Foundation\Tomcat

5.0\bin\bootstrap.jar

Work Path = d:\Program Files\Apache Software Foundation\Tomcat 5.0Auto Start这个参数允许设置服务为自动启动

Java VM栏:

Auto不要打勾

Java VM = D:\j2sdk\jre\bin\server\jvm.dll

Java Options = -Dcatalina.home="d:\Program Files\Apache SoftwareFoundation\Tomcat 5.0"

-Djava.endorsed.dirs="d:\Program Files\Apache Software

Foundation\Tomcat 5.0\common\endorsed" -Xrs

Start Class = org/apache/catalina/startup/Bootstrap;main;startStop Class =

org/apache/catalina/startup/Bootstrap;main;stopStandard Streams: 只要设置两项

Output = d:\Program Files\Apache Software Foundation\Tomcat

5.0\logs\stdout.log

Error = d:\Program Files\Apache Software Foundation\Tomcat

5.0\logs\stderr.log

根据以上设置,接下来可以使用tomcatw.exe //GT//Tomcat5启动服务了。若有问题可以给我留言或者加我QQ: 4034348

TOMCAT5在WINDOWS下的一些命令行

Tomcatw monitor application

Tomcatwis a GUI application for monitoring and configuring Tomcatservices.

The available command line options are:

Edit service

//ES//

configurationThis is the default operation. It is called ifthe no option is provided but the executable isrenamed toservicenameW.exe

//MS//Monitor servicePut the icon in the system try

Command line arguments

Each command line directive is in the form of//XX//ServiceNameThe available command line options are:

This is the default operation. It is called ifRuntheserviceas

thenooptionisprovided.TheServiceNameisthe//TS//console

name of the executable without exe sufix,application

meaning Tomcat5

//RS//Run the serviceCalled only from ServiceManager

//SS//Stop the service

Update service

//US//

parameters

//IS//Install service

//DS//Delete serviceStops the service if running

Command line parameters

Eachcommandparameterisprefixedwith-

-.Ifthecommandlineisprefixedwith++then it's value will be appended to the existing option. If theenvironment variable with the same name as command line parameter butprefixed withPR_exists it will take precedence. For example:set

PR_CLASSPATH=xx.jar

is equivalent to providing

--Classpath=xx.jar

as command line parameter.

ParameterNameDefault

--Description

--DisplayNameServiceName

--Installprocrun.exe

//RS//ServiceName

--Startupmanual

--DependsOn

--Environment

--User

--Password

--JavaHomeJAVA_HOME

--JvmautoDescription

Servicenamedescription(maximum1024characters)

Service display name

Install image

Servicestartupmodecanbeeitherautoormanual

List of services that this servicedepend on. Dependent services areseparated using either#or;characters

List of environment variables thatwillbeprovidedtotheserviceintheformkey=value. They are separatedusing either#or;charactersUser account used for runningexecutable. It is used only forStartModejavaorexeand enablesrunning applications as service underaccount without LogonAsServiceprivilege.

Passwordforuseraccountsetby--Userparameter

SetadifferentJAVA_HOMEthendefinedby JAVA_HOME environment variableUse eitherautoor specify the fullpath to thejvm.dll. You can use theenvironment variable expansion here.--JvmOptions-Xrs

--Classpath

--JvmMs

--JvmMx

--JvmSs

--StartImage

--StartPath

--StartClass

--StartParams

--StartMethodMain

--StartModeexecutable --StopImage

--StopPath

--StopClass

--StopParams

--StopMethodMain

--StopModeexecutable

--StopTimeoutNo Timeout --LogPathworking path

--LogPrefixjakarta_service --LogLevelINFO

--StdOutput

--StdErrorListofoptionsintheformof-Dor-Xthat will be passed to the JVM. Theoptions are separated using either#or;characters.

Set the Java classpath

Initial memory pool size in MBMaximum memory pool size in MBThread stack size in KB

Executable that will be run.Working path for the start imageexecutable.

Class that will be used for startup.Listofparametersthatwillbepassedto either StartImage or StartClass.Parameters are separated using either#or;character.

Method name if differs then mainCan one ofjvmjavaorexe

Executable that will be run on Stopservice signal.

Working path for the stop imageexecutable.

ClassthatwillbeusedonStopservicesignal.

Listofparametersthatwillbepassedto either StopImage or StopClass.Parameters are separated using either#or;character.

Method name if differs then mainCan one ofjvmjavaorexe

Defines the timeout in seconds thatprocrun waits for service to exitgracefully.

Defines the path for loggingDefines the service log filenameDefines the logging level and can beeithererror,info,warnordebugRedirected stdout filename

Redirected stderr filename

Installing services

The safest way to manually install the service is to use the providedservice.batscript.

Install the service named 'Tomcat5'

C:\> service.bat install

If using tomcat.exe, you need to use the//IS//parameter.

Install the service named 'Tomcat5'

C:\> tomcat5 //IS//Tomcat5 --DisplayName="Apache Tomcat 5" \C:\> --

Install="C:\Program Files\Tomcat\bin\tomcat5.exe" --Jvm=auto \C:\> --StartMode=jvm --StopMode=jvm \

C:\> --StartClass=org.apache.catalina.startup.Bootstrap

--StartParams=start \

C:\> --StopClass=org.apache.catalina.startup.Bootstrap

--StopParams=stop

Updating services

To update the service parameters, you need to use the//US//parameter.Update the service named 'Tomcat5

C:\> tomcat //US//Tomcat5 --Description="Apache Tomcat Server -

https://www.360docs.net/doc/6318827136.html,/tomcat " \

C:\> --Startup=auto

--

Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar

Removing services

To remove the service, you need to use the//DS//parameter.If the service is running it will be stopped and then deleted.Remove the service named 'Tomcat5'

C:\> tomcat //DS//Tomcat5

Debugging services

Toruntheserviceinconsolemode,youneedtousethe//TS//parameter.Theservicesh utdown

canbeinitiatedbypressingCTRL+CorCTRL+BREAK.Ifyourenamethetomcat5.exetotestser vice.exethenyoucanjustexecutethe testservice.exe and this command mode will be executed by default.Run the service named 'Tomcat5' in console mode

C:\> tomcat //TS//Tomcat5 [additional arguments]

Or simply execute:

C:\> tomcat

安装Tomcat服务的方法

a)

%CATALINA_HOME%\bin\tomcat.exe -install "Tomcat5"

"%JAVA_HOME%\jre\bin\server\jvm.dll"

-

Djava.class.path="%CATALINA_HOME%\bin\bootstrap.jar;%JAVA_HOME%\lib\tools.j ar" -Dcatalina.home="%CATALINA_HOME%" -Xrs -start

org.apache.catalina.startup.Bootstrap -params start -stop

org.apache.catalina.startup.Bootstrap -params stop -out

"%CATALINA_HOME%\logs\stderr.log"

b)

%CATALINA_HOME%\bin\tomcat.exe -uninstall -Tomcat5

相关文档
最新文档