将jRuby部署到Tomcat的子文件夹中 [英] jRuby deployment into a subfolder in Tomcat
问题描述
在使用webbrick作为网络服务器开发jRuby应用程序时,我的所有代码都是用 http:// localhost:3000 编写的
While developing a jRuby application using webbrick as the webserver, all my code is written with http://localhost:3000 as the root.
部署到Tomcat时,我创建了一个WAR文件,并在webapps /文件夹下创建了一个子文件夹:localhost:8080 / project_name /
When deploying to Tomcat, I create a WAR file and it creates a subfolder under the webapps/ folder: localhost:8080/project_name/
这会导致我的代码出现很多问题。我可以在我的ruby route.rb文件中做些什么来解决这个问题?
This causes a load of problems with my code. Is there anything I can do in my ruby routes.rb file to deal with this?
我应该在Tomcat中使用某种虚拟主机吗?
Should I resort to using some sort of virtual host in Tomcat?
推荐答案
JRuby-Rack中有代码可以解决这个问题。根据Tomcat和/或Rails的版本,它可能无法正确检测到额外的上下文路径。
There is code in JRuby-Rack to deal with this. Depending on the version of Tomcat and/or Rails, it may not be detecting the extra context path correctly.
本应生效的环境变量称为 ENV ['RAILS_RELATIVE_URL_ROOT']
。您可能会在启动时打印出该表达式的值,并查看在Tomcat中运行时它是否被设置。
The environment variable that is supposed to take effect is called ENV['RAILS_RELATIVE_URL_ROOT']
. You might print out the value of that expression during boot time and see whether it's getting set when you run in Tomcat.
有问题的代码在这里:
https://github.com/nicksieger/jruby-rack/blob/master/src/main/ruby/jruby/rack/rails.rb#L32-38
您使用的Tomcat,Rails和JRuby-Rack版本将有助于进一步诊断问题。
The versions of Tomcat, Rails and JRuby-Rack you're using would help diagnose the problem further.
这篇关于将jRuby部署到Tomcat的子文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!