tomcat注册服务问题

[复制链接]
查看11 | 回复2 | 2021-1-27 05:27:04 | 显示全部楼层 |阅读模式
我将tomcat注册成系统服务时发生错误,感觉环境都配好了。
service.bat配置:
@echooff
set"JAVA_HOME=F:\GT\deploy64\jdk"
set"JRE_HOME=F:\GT\deploy64\jdk\jre"
set"PR_DISPLAYNAME=tomcat7"
remLicensedtotheApacheSoftwareFoundation(ASF)underoneormore
remcontributorlicenseagreements.SeetheNOTICEfiledistributedwith
remthisworkforadditionalinformationregardingcopyrightownership.
remTheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0
rem(the"License");youmaynotusethisfileexceptincompliancewith
remtheLicense.YoumayobtainacopyoftheLicenseat
rem
remhttp://www.apache.org/licenses/LICENSE-2.0
rem
remUnlessrequiredbyapplicablelaworagreedtoinwriting,software
remdistributedundertheLicenseisdistributedonan"ASIS"BASIS,
remWITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
remSeetheLicenseforthespecificlanguagegoverningpermissionsand
remlimitationsundertheLicense.
rem---------------------------------------------------------------------------
remNTServiceInstall/Uninstallscript
rem
remOptions
reminstallInstalltheserviceusingTomcat7asservicename.
remServiceisinstalledusingdefaultsettings.
remremoveRemovetheservicefromtheSystem.
rem
remname(optional)Ifthesecondargumentispresentitisconsidered
remtobenewservicename
rem---------------------------------------------------------------------------
setlocal
set"SELF=%~dp0%service.bat"
remGuessCATALINA_HOMEifnotdefined
set"CURRENT_DIR=%cd%"
ifnot"%CATALINA_HOME%"==""gotogotHome
set"CATALINA_HOME=%cd%"
ifexist"%CATALINA_HOME%\bin\tomcat7.exe"gotookHome
remCDtotheupperdir
cd..
set"CATALINA_HOME=%cd%"
:gotHome
ifexist"%CATALINA_HOME%\bin\tomcat7.exe"gotookHome
echoThetomcat7.exewasnotfound...
echoTheCATALINA_HOMEenvironmentvariableisnotdefinedcorrectly.
echoThisenvironmentvariableisneededtorunthisprogram
gotoend
:okHome
remMakesureprerequisiteenvironmentvariablesareset
ifnot"%JAVA_HOME%"==""gotogotJdkHome
ifnot"%JRE_HOME%"==""gotogotJreHome
echoNeithertheJAVA_HOMEnortheJRE_HOMEenvironmentvariableisdefined
echoServicewilltrytoguessthemfromtheregistry.
gotookJavaHome
:gotJreHome
ifnotexist"%JRE_HOME%\bin\java.exe"gotonoJavaHome
ifnotexist"%JRE_HOME%\bin\javaw.exe"gotonoJavaHome
gotookJavaHome
:gotJdkHome
ifnotexist"%JAVA_HOME%\jre\bin\java.exe"gotonoJavaHome
ifnotexist"%JAVA_HOME%\jre\bin\javaw.exe"gotonoJavaHome
ifnotexist"%JAVA_HOME%\bin\javac.exe"gotonoJavaHome
ifnot"%JRE_HOME%"==""gotookJavaHome
set"JRE_HOME=%JAVA_HOME%\jre"
gotookJavaHome
:noJavaHome
echoTheJAVA_HOMEenvironmentvariableisnotdefinedcorrectly
echoThisenvironmentvariableisneededtorunthisprogram
echoNB:JAVA_HOMEshouldpointtoaJDKnotaJRE
gotoend
:okJavaHome
ifnot"%CATALINA_BASE%"==""gotogotBase
set"CATALINA_BASE=%CATALINA_HOME%"
:gotBase
set"EXECUTABLE=%CATALINA_HOME%\bin\tomcat7.exe"
remSetdefaultServicename
setSERVICE_NAME=Tomcat7
setDISPLAYNAME=ApacheTomcat7.0%SERVICE_NAME%
if"x%1x"=="xx"gotodisplayUsage
setSERVICE_CMD=%1
shift
if"x%1x"=="xx"gotocheckServiceCmd
:checkUser
if"x%1x"=="x/userx"gotorunAsUser
if"x%1x"=="x--userx"gotorunAsUser
setSERVICE_NAME=%1
setDISPLAYNAME=ApacheTomcat7.0%1
shift
if"x%1x"=="xx"gotocheckServiceCmd
gotocheckUser
:runAsUser
shift
if"x%1x"=="xx"gotodisplayUsage
setSERVICE_USER=%1
shift
runas/env/savecred/user:%SERVICE_USER%"%COMSPEC%/K\"%SELF%\"%SERVICE_CMD%%SERVICE_NAME%"
gotoend
:checkServiceCmd
if/i%SERVICE_CMD%==installgotodoInstall
if/i%SERVICE_CMD%==removegotodoRemove
if/i%SERVICE_CMD%==uninstallgotodoRemove
echoUnknownparameter"%SERVICE_CMD%"
:displayUsage
echo.
echoUsage:service.batinstall/remove[service_name][/userusername]
gotoend
:doRemove
remRemovetheservice
echoRemovingtheservice'%SERVICE_NAME%'...
echoUsingCATALINA_BASE:"%CATALINA_BASE%"
"%EXECUTABLE%"//DS//%SERVICE_NAME%
--LogPath"%CATALINA_BASE%\logs"
ifnoterrorlevel1gotoremoved
echoFailedremoving'%SERVICE_NAME%'service
gotoend
:removed
echoTheservice'%SERVICE_NAME%'hasbeenremoved
gotoend
:doInstall
remInstalltheservice
echoInstallingtheservice'%SERVICE_NAME%'...
echoUsingCATALINA_HOME:"%CATALINA_HOME%"
echoUsingCATALINA_BASE:"%CATALINA_BASE%"
echoUsingJAVA_HOME:"%JAVA_HOME%"
echoUsingJRE_HOME:"%JRE_HOME%"
remTrytousetheserverjvm
set"JVM=%JRE_HOME%\bin\server\jvm.dll"
ifexist"%JVM%"gotofoundJvm
remTrytousetheclientjvm
set"JVM=%JRE_HOME%\bin\client\jvm.dll"
ifexist"%JVM%"gotofoundJvm
echoWarning:Neither'server'nor'client'jvm.dllwasfoundatJRE_HOME.
setJVM=auto
:foundJvm
echoUsingJVM:"%JVM%"
set"CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar"
ifnot"%CATALINA_HOME%"=="%CATALINA_BASE%"set"CLASSPATH=%CLASSPATH%;%CATALINA_HOME%\bin\tomcat-juli.jar"
"%EXECUTABLE%"//IS//%SERVICE_NAME%
--Description"ApacheTomcat7.0.70Server-http://tomcat.apache.org/"
--DisplayName"%DISPLAYNAME%"
--Install"%EXECUTABLE%"
--LogPath"%CATALINA_BASE%\logs"
--StdOutputauto
--StdErrorauto
--Classpath"%CLASSPATH%"
--Jvm"%JVM%"
--StartModejvm
--StopModejvm
--StartPath"%CATALINA_HOME%"
--StopPath"%CATALINA_HOME%"
--StartClassorg.apache.catalina.startup.Bootstrap
--StopClassorg.apache.catalina.startup.Bootstrap
--StartParamsstart
--StopParamsstop
--JvmOptions"-Dcatalina.home=%CATALINA_HOME%;-Dcatalina.base=%CATALINA_BASE%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed;-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties"
--JvmMs128
--JvmMx256
ifnoterrorlevel1gotoinstalled
echoFailedinstalling'%SERVICE_NAME%'service
gotoend
:installed
echoTheservice'%SERVICE_NAME%'hasbeeninstalled.
:end
cd"%CURRENT_DIR%"

我在cmd中执行service.batinstalltomcat7会报错:

为什么安装不成功呢?
分 -->
回复

使用道具 举报

千问 | 2021-1-27 05:27:04 | 显示全部楼层
为啥感觉我发的贴从来没有人回复,悲伤
回复

使用道具 举报

千问 | 2021-1-27 05:27:04 | 显示全部楼层
需要配置path,把tomcat的bin路径配进去
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行