【问题标题】:Jruby: How to change the application url in war file deployed on glassfish serverJruby:如何更改部署在 glassfish 服务器上的 war 文件中的应用程序 url
【发布时间】:2018-03-10 08:58:01
【问题描述】:

我已经在 glassfish 服务器上部署了应用程序。可以使用 url localhost:8080/test 访问我的应用程序

以下是我的 warble.rb 文件中的设置

Warbler::Config.new do |config|
  config.jar_name = 'test'
  config.webxml.jruby.min.runtimes = 2
  config.webxml.jruby.max.runtimes = 10
  config.includes = FileList['init.rb']
end

上述设置创建名为“test.war”的war文件,因此它是应用程序的url,即localhost:8080/test。我想要的是我想保持文件名原样,即它应该是“test.war”,但应用程序 url 应该是 localhost:8080/test_application 而不是 localhost:8080/test

【问题讨论】:

    标签: glassfish jruby jrubyonrails warbler


    【解决方案1】:

    来自Glassfish Application Deployment Guide (PDF)

    部署 Web 模块时,如果不指定上下文根,则默认为不带 .war 扩展名的 WAR 文件的名称。 Web 模块上下文根在服务器实例中必须是唯一的。

    如果您想更改上下文根,您必须在部署描述符中执行此操作。有几种方法可以做到这一点,但对于莺最简单的可能是以下方法(尽管它是 Glassfish 特有的)。

    1. 在 Rails 应用程序根目录中创建一个名为“glassfish-web.xml”的文件。它应该有以下内容:

      <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
      <glassfish-web-app>
        <context-root>test_application</context-root>
      </glassfish-web-app>
      
    2. 将以下内容添加到您的 warbler 配置 (warble.rb) 以确保此文件被打包到您的应用程序 war 的 WEB-INFO 目录中:

      config.webinf_files += FileList["glassfish-web.xml"]
      
    3. 重新运行您的应用程序并重新部署。

    4. 现在应该可以在 localhost:8080/test_application 访问它了。

    【讨论】:

      猜你喜欢
      • 2020-07-18
      • 2012-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多