簡體   English   中英

在Windows平台上將jruby項目部署到tomcat

[英]Deploy jruby project to tomcat in windows platform

我是紅寶石世界的新手,在做了一些研究之后,我可以在webrick服務器上生成一個demo rails應用程序並進行測試

但是當我開始使用tomcat部署時我遇到了問題我使用warbler生成war文件以便成功部署而不會出現錯誤復制warcat在Tomcat 7.0上的webapps文件夾下啟動服務器並嘗試在瀏覽器上運行我發現資產文件無法訪問,控制器方法無法重定向到正確的視圖,但顯示“我們很抱歉,但出了點問題。” 信息

我試過的部署配置

JRuby 1.7.0
Gems    
    jruby-rack 1.1.10, 1.0.10
    rails 3.2.9, 3.2.0
    warbler 1.3.6, 1.3.2
Tomcat 7.0.32

這是tomcat的訪問日志

127.0.0.1 - - [20/Nov/2012:13:56:38 +0800] "GET /demo/ HTTP/1.1" 200 5906
127.0.0.1 - - [20/Nov/2012:13:56:49 +0800] "GET /demo/assets/rails.png HTTP/1.1" 404 728
127.0.0.1 - - [20/Nov/2012:14:01:21 +0800] "GET /demo/order/add HTTP/1.1" 500 643

這是tomcat的日志形式

2012/11/20 13:56:18 org.apache.catalina.core.ApplicationContext log

    INFO: jruby 1.7.0 (1.9.3p203) 2012-10-22 ff1ebbe on Java HotSpot(TM) Client VM 1.6.0_34-b04 [Windows XP-x86]

    2012/11/20 13:56:18 org.apache.catalina.core.ApplicationContext log

    INFO: using : runtime pool with acquire timeout of 10.0 seconds

    2012/11/20 13:56:19 org.apache.catalina.core.ApplicationContext log

    ContextListener: contextInitialized()

    2012/11/20 13:56:19 org.apache.catalina.core.ApplicationContext log

    SessionListener: contextInitialized()

    2012/11/20 13:56:19 org.apache.catalina.core.ApplicationContext log

    ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@1858aa0')

    2012/11/20 01:56:38 org.apache.catalina.core.ApplicationContext log

    INFO: pool was empty - getting new application instance

    2012/11/20 01:56:47 org.apache.catalina.core.ApplicationContext log

    Started GET "/demo/assets/rails.png" for 127.0.0.1 at 2012-11-20 13:56:47 +0800


    2012/11/20 01:56:47 org.apache.catalina.core.ApplicationContext log

    Connecting to database specified by database.yml


    2012/11/20 01:56:49 org.apache.catalina.core.ApplicationContext log


    ActionController::RoutingError (No route matches [GET] "/assets/rails.png"):
    gems/gems/actionpack-3.2.9/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
    gems/gems/actionpack-3.2.9/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
    gems/gems/railties-3.2.9/lib/rails/rack/logger.rb:32:in `call_app'
    gems/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
    gems/gems/activesupport-3.2.9/lib/active_support/tagged_logging.rb:22:in `tagged'
    gems/gems/railties-3.2.9/lib/rails/rack/logger.rb:16:in `call'
    gems/gems/actionpack-3.2.9/lib/action_dispatch/middleware/request_id.rb:22:in `call'
    gems/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
    gems/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
    gems/gems/activesupport-3.2.9/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
    gems/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
    gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
    gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
    gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
    gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
    gems/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
    gems/gems/railties-3.2.9/lib/rails/engine.rb:479:in `call'
    gems/gems/railties-3.2.9/lib/rails/application.rb:223:in `call'
    file:/lib/jruby-rack-1.1.10.jar!/rack/handler/servlet.rb:22:in `call'




    2012/11/20 14:01:21 org.apache.catalina.core.ApplicationContext log

    Started GET "/demo/order/add" for 127.0.0.1 at 2012-11-20 14:01:21 +0800


    2012/11/20 14:01:21 org.apache.catalina.core.ApplicationContext log

    Processing by OrderController#add as HTML


    2012/11/20 14:01:21 org.apache.catalina.core.ApplicationContext log

    Rendered order/add.html.erb within layouts/application (16.0ms)


    2012/11/20 14:01:21 org.apache.catalina.core.ApplicationContext log

    Completed 500 Internal Server Error in 78ms

看起來路由問題出現了,當我部署除ROOT位置以外的rails應用程序時,問題是什么?

我研究了類似的主題,我嘗試了一些解決方案,例如在production.rb中添加以下命令,但沒有幫助。

config.action_controller.relative_url_root = "/demo"

謝謝你的解決方案

您是否在進行warbling之前預先編譯了您的資產?

您需要運行rake assets:precompile以在運行warble之前生成靜態內容

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM