如何解决运行Tomcat出错:指定的服务并未以已安装的服务存在

    今天,在安装Tomcat6.0时遇到个问题:安装的时候,弹出错误信息:Failed to install Tomcat6 service. Check your settings and permissions Ignore and continue anyway
    点击忽略后继续安装,但安装完成后启动Tomcat6时,又会提示:指定的服务并未以已安装的服务存在 Unable to open the service 'Tomcat6'
    后来发现,这是因为原来的系统中已经装了Tomcat5.5,并将其添加到了系统的本地服务中了,所以在启动Tomcat6.0的时候就出错了,这时我们只需先讲系统中的Tomcat5服务卸载掉,然后再将Tomcat6的服务添加到系统中即可,无需卸载Tomcat5
如何卸载Tomcat的服务:运行cmd,进入到Tomcat5的bin目录下,然后运行命令“Service.bat remove”,结果我的Tomcat5中没有这个文件,郁闷死我了~~~
好在在网上找到了这个文件,现将其贴出来,文件内容如下:


@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements.   See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License.   You may obtain a copy of the License at
rem
rem      http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.

if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem NT Service Install/Uninstall script
rem
rem Options
rem install                 Install the service using tomcat5 as service name.
rem                         Service is installed using default settings.
rem remove                  Remove the service from the System.
rem
rem name         (optional) If the second argument is present it is considered
rem                         to be new service name                                          
rem
rem $Id: service.bat 600659 2007-12-03 20:15:09Z jim $
rem ---------------------------------------------------------------------------

rem Guess CATALINA_HOME if not defined
set CURRENT_DIR=%cd%
if not "%CATALINA_HOME%" == "" goto gotHome
set CATALINA_HOME=%cd%
if exist "%CATALINA_HOME%/bin/tomcat5.exe" goto okHome
rem CD to the upper dir
cd ..
set CATALINA_HOME=%cd%
:gotHome
if exist "%CATALINA_HOME%/bin/tomcat5.exe" goto okHome
echo The tomcat.exe was not found...
echo The CATALINA_HOME environment variable is not defined correctly.
echo This environment variable is needed to run this program
goto end
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto okHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:okHome
if not "%CATALINA_BASE%" == "" goto gotBase
set CATALINA_BASE=%CATALINA_HOME%
:gotBase

set EXECUTABLE=%CATALINA_HOME%/bin/tomcat5.exe

rem Set default Service name
set SERVICE_NAME=tomcat5
set PR_DISPLAYNAME=Apache Tomcat

if "%1" == "" goto displayUsage
if "%2" == "" goto setServiceName
set SERVICE_NAME=%2
set PR_DISPLAYNAME=Apache Tomcat %2
:setServiceName
if %1 == install goto doInstall
if %1 == remove goto doRemove
if %1 == uninstall goto doRemove
echo Unknown parameter "%1"
:displayUsage
echo.
echo Usage: service.bat install/remove [service_name]
goto end

:doRemove
rem Remove the service
"%EXECUTABLE%" //DS//%SERVICE_NAME%
echo The service '%SERVICE_NAME%' has been removed
goto end

:doInstall
rem Install the service
echo Installing the service '%SERVICE_NAME%' ...
echo Using CATALINA_HOME:     %CATALINA_HOME%
echo Using CATALINA_BASE:     %CATALINA_BASE%
echo Using JAVA_HOME:         %JAVA_HOME%

rem Use the environment variables as an example
rem Each command line option is prefixed with PR_

set PR_DESCRIPTION=Apache Tomcat Server - http://tomcat.apache.org/
set PR_INSTALL=%EXECUTABLE%
set PR_LOGPATH=%CATALINA_BASE%/logs
set PR_CLASSPATH=%CATALINA_HOME%/bin/bootstrap.jar
rem Set the server jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%/jre/bin/server/jvm.dll
if exist "%PR_JVM%" goto foundJvm
rem Set the client jvm from JAVA_HOME
set PR_JVM=%JAVA_HOME%/jre/bin/client/jvm.dll
if exist "%PR_JVM%" goto foundJvm
set PR_JVM=auto
:foundJvm
echo Using JVM:               %PR_JVM%
"%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stop
if not errorlevel 1 goto installed
echo Failed installing '%SERVICE_NAME%' service
goto end
:installed
rem Clear the environment variables. They are not needed any more.
set PR_DISPLAYNAME=
set PR_DESCRIPTION=
set PR_INSTALL=
set PR_LOGPATH=
set PR_CLASSPATH=
set PR_JVM=
rem Set extra parameters
"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%/endorsed" --StartMode jvm --StopMode jvm
rem More extra parameters
set PR_LOGPATH=%CATALINA_BASE%/logs
set PR_STDOUTPUT=auto
set PR_STDERROR=auto
"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%/temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%/conf/logging.properties" --JvmMs 128 --JvmMx 256
echo The service '%SERVICE_NAME%' has been installed.

:end
cd %CURRENT_DIR%


    卸载掉Tomcat5服务之后就可以安装Tomcat6服务了,同样的进入到Tomcat6的bin目录下,运行“Service.bat install”(如果bin目录下也没有Service.bat文件,只需将Tomcat5下的过来,将文件中的所有Tomcat5替换成Tomcat6即可),这样,Tomcat6服务就安装好了,Tomcat6也就可以正常运行了~~~
    当然在安装其他版本的Tomcat出现上述错误时,都可以这样处理~~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值