Deploy JRuby on Rails-developed applications to Tomcat

Source: Internet
Author: User
Tags netbeans
Environment DescriptionWindows XP jdk 6u12 JRuby 1.2.0 rails 2.2.2 NetBeans 6.5.1 Tomcat 5.5 MySQL 5 upgrade to JRuby 1.2.0

The JRuby version is not NetBeans's 1.1.4 because the Rails 2.2.2 need a gem version of 1.3, and JRuby 1.1.4 has a gem version of 1.2, although my first article described how to upgrade the JRuby gem version, But in the deployment is always unsuccessful, the system still think gem version of 1.2, helpless under the JRuby 1.2.0, download link http://jruby.codehaus.org/

In NetBeans, it's easy to add and switch ruby platforms, and you just need to manually specify a new 1.2.0 Jruby.bat file.

However, this will have to reinstall all the gems for JRuby 1.2.0, where the installation of the Quick Debugger is very special, here is a description

At present, NetBeans does not support the automatic installation of fast debugger for JRuby, it has to do its own, a wiki describes how to install

Http://wiki.netbeans.org/RubyDebugging

The approximate steps are as follows:

First download Ruby-debug-base-0.10.3.1-java.gem

Then install at the command line

Jruby-s Gem Install-l Ruby-debug-base-0.10.3.1-java.gem

Finally install the Debug IDE

Jruby-s gem install--ignore-dependencies-v 0.3.4 ruby-debug-ide

Note that the Debug-ide version number, as I have tested 0.3.1 is also available, NetBeans itself with is 0.3.1, and the higher 0.4 is not available

packaging items with Warbler

Let's get down to business.

First you have to install the Warbler gem, which is a hint when you build the project

Then I refer to the JE article to do, but the process is more different http://chengj.iteye.com/blog/184479

Activerecord-jdbc-adapter This gem must be installed, and activerecord-jdbcmysql-adapter I did not install and still packaged successfully (my project is using JDBC way to connect to the database)

All of the jar packages used in the project will be placed in the Lib root directory, including the Mysql-connector-java-5.1.6-bin.jar that was brought in the project

(when I wrote it, it occurred to me that it might not be possible to activerecord-jdbcmysql-adapter the jar bag after installing it.) )

Modify the Enviroment.rb file, write the Third-party gem referenced by the project, for example, my project uses mislav-will_page, then add ruby code Config.gem ' Mislav-will_paginate ' in it: Version => ' ~> 2.3.8 ',: Lib => ' Will_paginate ',: Source => ' http://gems.github.com '

Config.gem ' Mislav-will_paginate ',: Version => ' ~> 2.3.8 ',: Lib => ' Will_paginate ',  : source => ' http:// Gems.github.com '

Below the command line to enter the project directory, execute the command Ruby code jruby-s warble Config


A warble.rb file is generated under the Config directory, open to modify it, and uncomment such a line of comments Ruby code config.gems = ["Activerecord-jdbc-adapter", "Jruby-openssl"]

Finally still executing the command in the project directory Ruby code jruby-s warble War


So a war file will appear in the project root directory, and put it under Tomcat's WebApps, and it's done.

Special Reminder : There is a bug in the JRuby that causes the last command to be executed under window. Ruby Code Private method ' split ' called for Nil:nilclass Q:/app/codehaus/jruby_1_2_0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/repaired_system.rb:109:in ' Find_ Runnable ' (for the full trace by running task with--trace)

Private method ' split ' called for Nil:nilclass
q:/app/codehaus/jruby_1_2_0/lib/ruby/gems/1.8/gems/rake-0.8.4/ Lib/rake/repaired_system.rb:109:in ' find_runnable '
(the full trace by running task with--trace)

The reason for this bug can be found here http://jira.codehaus.org/browse/JRUBY-3598

Simply put, JRuby cannot get the PATH environment variable while executing env["path" under Windows, and only through env["path"] can you get it correctly

The workaround is to manually modify the Repaired_system.rb file under Rake, change the path inside 109 lines to path, or add a line of Ruby code to the above env["path"]= "Your PATH environment variable"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.