Warbler 和 tomcat 未正确设置上下文

发布于 2024-12-16 02:23:45 字数 1480 浏览 0 评论 0原文

我正在尝试使用 Warbler 生成的 war 文件将 Rails 应用程序部署到 Tomcat。 war 文件部署到 /myproject-rails-gui 没有任何问题,但是,当我尝试访问应用程序上的页面时,我得到:

ArgumentError: wrong number of arguments (1 for 0)
          send at org/jruby/RubyKernel.java:2097
       Railtie at /home/myproject/apache-tomcat-7.0.22/webapps/myproject-rails-gui/WEB-INF/gems/gems/actionpack-3.0.10/lib/action_controller/railtie.rb:54

尝试设置relative_url_root 时失败。还有其他 Stack Overflow 文章(正确地)指出relative_url_root 已弃用,您应该设置 RAILS_RELATIVE_URL_ROOT 环境变量。

来自 GitHub 上的 Rails 项目

module ActionController
  class Base
    # Deprecated methods. Wrap them in a module so they can be overwritten by plugins
    # (like the verify method.)
    module DeprecatedBehavior #:nodoc:
      def relative_url_root
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root is ineffective. " <<
          "Please stop using it.", caller
      end

      def relative_url_root=
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root= is ineffective. " <<
          "Please stop using it.", caller
      end

不过,我还没有弄清楚如何使用 Warbler 和 Tomcat 来做到这一点。有什么建议吗?就其价值而言,当我在根上下文中运行该应用程序时,它运行良好。

我的环境:

  • Warbler 1.3.2
  • Tomcat 7.0.22
  • JRuby 1.6.5
  • Rails 3.0.10

I'm trying to deploy a Rails app to Tomcat with a war file generated by Warbler. The war file deploys to /myproject-rails-gui without any problems but, when I try to access a page on the app, I'm getting:

ArgumentError: wrong number of arguments (1 for 0)
          send at org/jruby/RubyKernel.java:2097
       Railtie at /home/myproject/apache-tomcat-7.0.22/webapps/myproject-rails-gui/WEB-INF/gems/gems/actionpack-3.0.10/lib/action_controller/railtie.rb:54

It's failing when it tries to set relative_url_root. There are other Stack Overflow articles that (correctly) point out that relative_url_root is deprecated and you should set the RAILS_RELATIVE_URL_ROOT environment variable instead.

From the Rails project on GitHub

module ActionController
  class Base
    # Deprecated methods. Wrap them in a module so they can be overwritten by plugins
    # (like the verify method.)
    module DeprecatedBehavior #:nodoc:
      def relative_url_root
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root is ineffective. " <<
          "Please stop using it.", caller
      end

      def relative_url_root=
        ActiveSupport::Deprecation.warn "ActionController::Base.relative_url_root= is ineffective. " <<
          "Please stop using it.", caller
      end

I haven't had any luck figuring out how to do that using Warbler and Tomcat, though. Any suggestions? For what it's worth, the app works fine when I run it in the root context.

My environment:

  • Warbler 1.3.2
  • Tomcat 7.0.22
  • JRuby 1.6.5
  • Rails 3.0.10

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文