简体   繁体   English

Tomcat 在作为 Windows 服务运行时无法加载 webapp

[英]Tomcat fails to load webapp when it is running as a windows service

I am using tomcat 7 and I have a webapp which has 1 configuration file & 1 hazelcast.xml file in tomcat bin directory.我正在使用 tomcat 7 并且我有一个 webapp,它在 tomcat bin 目录中有 1 个配置文件和 1 个 hazelcast.xml 文件。 When I start tomcat as a process from startup.bat catalina.timestamp.log shows INFO: Configuring Hazelcast from 'C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0_ApacheTomcat7\\bin\\hazelcast.xml'.当我从 startup.bat catalina.timestamp.log 作为进程启动 tomcat 时,显示INFO: Configuring Hazelcast from 'C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0_ApacheTomcat7\\bin\\hazelcast.xml'. and everything works fine, but when I start the same webapp by starting tomcat as a windows service it goes to tomcat home dir and looks for the file here INFO: Configuring Hazelcast from 'C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0_ApacheTomcat7\\hazelcast.xml'.一切正常,但是当我通过将 tomcat 作为 Windows 服务启动相同的 web 应用程序时,它会转到 tomcat 主目录并在此处查找文件INFO: Configuring Hazelcast from 'C:\\Program Files\\Apache Software Foundation\\Tomcat 7.0_ApacheTomcat7\\hazelcast.xml'.

Is there any jvm or tomcat option that I need to place?我需要放置任何 jvm 或 tomcat 选项吗?

below is my Java Options which is set in Tomcat properties下面是我在 Tomcat 属性中设置的 Java 选项

-Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7
-Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7
-Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\endorsed
-Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\temp
-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
-Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 7.0_ApacheTomcat7\conf\logging.properties

在此处输入图片说明

I was able to solve my problem.我能够解决我的问题。

When I start Tomcat as a Windows service it sets the current working dir to %CATALINA_HOME% .当我将 Tomcat 作为 Windows 服务启动时,它将当前工作目录设置为%CATALINA_HOME% So I added --StartPath=%CATALINA_HOME%\\bin in service.bat (details here ) and installed a fresh service like so: service.bat install MyService .所以我在service.bat添加了--StartPath=%CATALINA_HOME%\\bin (详细信息在这里)并安装了一个新的服务,如下所示: service.bat install MyService

屏幕截图显示必须在何处输入 StartPath

Incase one does not have service.bat but tomcat6 : below is the command to create a fresh windows service.如果没有service.bat但没有tomcat6 :下面是创建一个新的 Windows 服务的命令。

tomcat6 //IS//MyService --DisplayName="My Service Name" \ --Install="C:\tomcat6\bin\tomcat6.exe" --Jvm=auto \ --StartMode=jvm --StopMode=jvm \ --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start \ --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop \ --StartPath=C:\tomcat6\bin

You can even set this in the Tomcat GUI: Startup tab |您甚至可以在 Tomcat GUI 中进行设置: Startup选项卡 | Start parameters . Start parameters
(The Tomcat GUI is also known as the "Commons Daemon Service Manager". Default name is tomcat7w.exe , or "YOURSERVICENAMEHEREw.exe".) (Tomcat GUI 也称为“Commons Daemon Service Manager”。默认名称是tomcat7w.exe或“YOURSERVICENAMEHEREw.exe”。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM