【问题标题】:Can't install Tomcat 7 as a Service in Windows无法在 Windows 中将 Tomcat 7 安装为服务
【发布时间】:2015-12-04 02:47:55
【问题描述】:

我正在尝试在 Windows Server 2008 中将 tomcat 作为服务安装。

我在stackoverflow中搜索并找不到这个问题的任何答案,我可以看到其他相关的问题,它们都不相同(与代码错误0有关,我的是代码错误1) 或没有有效的答案,所以我决定创建这个问题。

我正在使用它来创建服务:

https://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html#Installing_services

tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" \

命令后,我可以在我的服务列表中看到 Apache Tomcat 7 服务,问题是它已停止,如果我尝试启动它,我会看到此错误:

Windows could not start the Apache Tomcat 7 on Local Computer. For
more information, review the System Event Log. If this is a
non-Microsoft service, contact the service vendor, and refer to
service-specific error code 1.

在系统事件查看器中,我可以看到此错误的日志:

The Apache Tomcat 7 service terminated with service-specific error Incorrect function..

我正在使用 java 64 位,并且我使用 32 位和 64 位的 tomcat 进行了测试,两者都有同样的问题。我也尝试使用管理员权限打开 cmd.exe,但我遇到了同样的问题...

感谢您的帮助

仅供参考:如果我使用 startup.bat 手动启动 tomcat,它会正确启动

【问题讨论】:

  • 您可以在HKLM\SYSTEM\CurrentControlSet\Services\Apache Tomcat 7 检查您的注册表吗?有子键吗?
  • 它被称为 Services\Tomcat7 而不是 Apache Tomcat 7,它有很多子键
  • 是的,对不起名字。有Parameters 子键吗?
  • 它是一个名为 parameters 的子目录,具有未指定值的 REG_SZ 类型

标签: java windows apache tomcat windows-services


【解决方案1】:

这是因为您的 JDK/Java 运行环境和您的 Tomcat 安装不匹配。两者都必须是 32 位或 64 位。

第 1 步:卸载 Apache Tomcat。第 2 步:卸载您的 java 和 jdk。

第 2 步:下载相同的架构安装。

第 3 步:重新安装两者。

这将解决您的问题。

【讨论】:

    【解决方案2】:

    打开tomcat7w.exe 应用程序并验证通知的人。

    【讨论】:

    • 不是一个完整的答案。
    • 我在 JDK 7 x64 上遇到了与 tomcat7 相同的问题。修复了编辑“Java 虚拟机”和“ClassPath”!
    • 安装用户不是管理员。以“admin”用户身份安装“Java 虚拟机”和“ClassPath”配置已正确填充。另请参阅stackoverflow.com/questions/45842730/…
    【解决方案3】:

    我无法将 Apache Tomcat 作为服务安装在 Windows 10 或 Windows 2012 中。运行 Service.bat install 命令后,例程会找到 JDK,但总是失败,并显示类似:服务安装失败。

    我的解决方案:创建一个指向

    的 Windows 任务计划程序任务
    C:\tomcat7\bin\startup.bat
    

    并使该任务在系统启动时启动,而无需系统登录。在这两种操作系统中都能发挥出色的作用。

    HTH。

    【讨论】:

      【解决方案4】:

      我只是用其他方法安装服务解决了它:

      service.bat install
      

      此命令将卸载服务:

      service.bat uninstall
      

      要启动它并启用自动启动,您必须进入 Windows 的服务管理器(西班牙语版本的 Servicios)并启动服务并启用自动启动。

      如果你能在tomcat/bin目录下找到service.bat文件,请阅读:

      apache-tomcat-[version].zip or .tar.gz
             Base distribution. These distributions do not include the Windows service wrapper nor the compiled APR/native library for Windows.
      
      apache-tomcat-[version]-windows-x86.zip
             32-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 32-bit JVMs on both 32 and 64 bit Windows platforms.
      
      apache-tomcat-[version]-windows-x64.zip
             64-bit Windows specific distribution that includes the Windows service wrapper and the compiled APR/native library for use with 64-bit JVMs on x64 Windows platforms.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-06-19
        • 2019-07-21
        • 1970-01-01
        • 1970-01-01
        • 2011-04-06
        • 1970-01-01
        相关资源
        最近更新 更多