11# JRuby-Rack
22
3+ [ ![ Gem Version] ( https://badge.fury.io/rb/jruby-rack.png )] [ 8 ]
4+ [ ![ Build Status] ( https://github.com/jruby/jruby-rack/actions/workflows/maven.yml/badge.svg )] [ 9 ]
5+
36JRuby-Rack is a lightweight adapter for the Java Servlet environment that allows
47any (Ruby) Rack-based application to run unmodified in a Java Servlet container.
58JRuby-Rack supports Rails as well as any Rack-compatible Ruby web framework.
69
710For more information on Rack, visit http://rack.github.io/ .
811
9- ** This README (master) targets JRuby-Rack 1.3. Please use the
10- [ 1.1-stable] ( https://github.com/jruby/jruby-rack/tree/1.1-stable ) branch for
11- current stable 1.1.x releases.**
12-
13- [ ![ Gem Version] ( https://badge.fury.io/rb/jruby-rack.png )] [ 8 ]
14- [ ![ Build Status] ( https://github.com/jruby/jruby-rack/actions/workflows/maven.yml/badge.svg )] [ 9 ]
15-
1612## Compatibility
1713
18- JRuby-Rack 1.4.x
19- - aims to be compatible with JRuby 9.4 -> 10.0 and Java 17+
20- - supports any container compatible with Jakarta Servlet 5.0 API (JEE 9)
21-
22- JRuby-Rack 1.3.x
23- - aims to be compatible with JRuby 9.4 -> 10.0 and Java 11+
24- - supports any container compatible with Java Servlet 4.0 API
25-
26- JRuby-Rack 1.2.x
27- - compatible with JRuby 9.3 -> 9.4 and their supported JDK versions
28- - supports any container compatible with Java Servlet 3.0 API
29-
30- JRuby-Rack 1.1.x
31- - aims to be compatible with JRuby >= 1.6.4 (used successfully through JRuby 9.4)
32- - supports any container compatible with Java Servlet 2.5 API (JEE 5)
33-
14+ | JRuby-Rack Version | Status | JRuby Compat | Java Compat | Target Servlet API | Target Java EE | Notes |
15+ | --------------------------------------------------------------| ------------| --------------| -------------| --------------------| ----------------| ---------------------------------------------------|
16+ | 1.4.x (_ planned_ ) | Dev | 9.4 → 10.0 | Java 17+ | 5.0 | Jakarta EE 9 | |
17+ | 1.3.x (master, _ unreleased_ ) | Dev | 9.4 → 10.0 | Java 11+ | 4.0 | Java EE 8 | |
18+ | [ 1.2.x] ( https://github.com/jruby/jruby-rack/tree/1.2-stable ) | Maintained | 9.3 → 9.4 | Java 8+ | 3.0 | Java EE 6 | Servlet 3.1 → 4.0 tested OK with some containers. |
19+ | [ 1.1.x] ( https://github.com/jruby/jruby-rack/tree/1.1-stable ) | EOL | 1.6 → 9.4 | Java 8+ | 2.5 | Java EE 5 | Servlet 3.0 → 4.0 tested OK with some containers. |
3420
3521## Getting Started
3622
@@ -59,79 +45,85 @@ min/max runtime parameters. For **multi-threaded** (a.k.a. `threadsafe!`)
5945Rails with a single runtime, set min/max both to 1. Otherwise, define the size
6046of the runtime pool as you wish.
6147
62- <context-param>
63- <param-name>rails.env</param-name>
64- <param-value>production</param-value>
65- </context-param>
66- <context-param>
67- <param-name>jruby.min.runtimes</param-name>
68- <param-value>1</param-value>
69- </context-param>
70- <context-param>
71- <param-name>jruby.max.runtimes</param-name>
72- <param-value>1</param-value>
73- </context-param>
74-
75- <filter>
76- <filter-name>RackFilter</filter-name>
77- <filter-class>org.jruby.rack.RackFilter</filter-class>
78- <!-- optional filter configuration init-params : -->
79- <init-param>
80- <param-name>resetUnhandledResponse</param-name>
81- <param-value>true</param-value> <!-- true (default), false or buffer -->
82- </init-param>
83- <init-param>
84- <param-name>addsHtmlToPathInfo</param-name>
85- <param-value>true</param-value> <!-- true (default), false -->
86- </init-param>
87- <init-param>
88- <param-name>verifiesHtmlResource</param-name>
89- <param-value>false</param-value> <!-- true, false (default) -->
90- </init-param>
91- </filter>
92- <filter-mapping>
93- <filter-name>RackFilter</filter-name>
94- <url-pattern>/*</url-pattern>
95- </filter-mapping>
96-
97- <listener>
98- <listener-class>org.jruby.rack.rails.RailsServletContextListener</listener-class>
99- </listener>
48+ ``` xml
49+ <context-param >
50+ <param-name >rails.env</param-name >
51+ <param-value >production</param-value >
52+ </context-param >
53+ <context-param >
54+ <param-name >jruby.min.runtimes</param-name >
55+ <param-value >1</param-value >
56+ </context-param >
57+ <context-param >
58+ <param-name >jruby.max.runtimes</param-name >
59+ <param-value >1</param-value >
60+ </context-param >
61+
62+ <filter >
63+ <filter-name >RackFilter</filter-name >
64+ <filter-class >org.jruby.rack.RackFilter</filter-class >
65+ <!-- optional filter configuration init-params : -->
66+ <init-param >
67+ <param-name >resetUnhandledResponse</param-name >
68+ <param-value >true</param-value > <!-- true (default), false or buffer -->
69+ </init-param >
70+ <init-param >
71+ <param-name >addsHtmlToPathInfo</param-name >
72+ <param-value >true</param-value > <!-- true (default), false -->
73+ </init-param >
74+ <init-param >
75+ <param-name >verifiesHtmlResource</param-name >
76+ <param-value >false</param-value > <!-- true, false (default) -->
77+ </init-param >
78+ </filter >
79+ <filter-mapping >
80+ <filter-name >RackFilter</filter-name >
81+ <url-pattern >/*</url-pattern >
82+ </filter-mapping >
83+
84+ <listener >
85+ <listener-class >org.jruby.rack.rails.RailsServletContextListener</listener-class >
86+ </listener >
87+ ```
10088
10189### (Other) Rack Applications
10290
10391The main difference when using a non-Rails Rack application is that JRuby-Rack
10492looks for a "rackup" file named ** config.ru** in ` WEB-INF/config.ru ` or
10593` WEB-INF/*/config.ru ` . Here's a sample * web.xml* configuration :
10694
107- <filter>
108- <filter-name>RackFilter</filter-name>
109- <filter-class>org.jruby.rack.RackFilter</filter-class>
110- <!-- optional filter configuration init-params (@see above) -->
111- </filter>
112- <filter-mapping>
113- <filter-name>RackFilter</filter-name>
114- <url-pattern>/*</url-pattern>
115- </filter-mapping>
116-
117- <listener>
118- <listener-class>org.jruby.rack.RackServletContextListener</listener-class>
119- </listener>
95+ ``` xml
96+ <filter >
97+ <filter-name >RackFilter</filter-name >
98+ <filter-class >org.jruby.rack.RackFilter</filter-class >
99+ <!-- optional filter configuration init-params (@see above) -->
100+ </filter >
101+ <filter-mapping >
102+ <filter-name >RackFilter</filter-name >
103+ <url-pattern >/*</url-pattern >
104+ </filter-mapping >
105+
106+ <listener >
107+ <listener-class >org.jruby.rack.RackServletContextListener</listener-class >
108+ </listener >
109+ ```
120110
121111If you don't have a * config.ru* or don't want to include it in your web app, you
122112can embed it directly in the * web.xml* as follows (using Sinatra as an example):
123113
124- <context-param>
125- <param-name>rackup</param-name>
126- <param-value>
127- require 'rubygems'
128- gem 'sinatra', '~> 1.3'
129- require './lib/app'
130- set :run, false
131- set :environment, :production
132- run Sinatra::Application
133- </param-value>
134- </context-param>
114+ ``` xml
115+ <context-param >
116+ <param-name >rackup</param-name >
117+ <param-value >
118+ require 'rubygems'
119+ gem 'sinatra', '~> 1.3'
120+ require './lib/app'
121+ set :run, false
122+ set :environment, :production
123+ run Sinatra::Application
124+ </param-value >
125+ </context-param >
126+ ```
135127
136128Be sure to escape angle-brackets for XML !
137129
@@ -285,13 +277,16 @@ provided *config.ru* the bundled (latest) version of Rack will get loaded.
285277
286278Use ** rack.version** to specify the Rack gem version to be loaded before rackup :
287279
288- # encoding: UTF-8
289- # rack.version: ~>2.2.10 (before code is loaded gem '~>2.2.10' will be called)
280+ ``` ruby
281+ # encoding: UTF-8
282+ # rack.version: ~>2.2.10 (before code is loaded gem '~>2.2.10' will be called)
283+ ```
290284
291285Or the equivalent of doing ` bundle exec rackup ... ` if you're using Bundler :
292286
293- # rack.version: bundler (requires 'bundler/setup' before loading the script)
294-
287+ ``` ruby
288+ # rack.version: bundler (requires 'bundler/setup' before loading the script)
289+ ```
295290
296291## Logging
297292
@@ -318,21 +313,27 @@ For those loggers that require a specific named logger, set it with the
318313
319314Checkout the JRuby-Rack code using [ git] ( http://git-scm.com/ ) :
320315
321- git clone git://github.com/jruby/jruby-rack.git
322- cd jruby-rack
316+ ``` shell
317+ git clone git://github.com/jruby/jruby-rack.git
318+ cd jruby-rack
319+ ```
323320
324321Ensure you have [ Maven] ( http://maven.apache.org/ ) installed.
325322It is required for downloading jar artifacts that JRuby-Rack depends on.
326323
327324Build the .jar using Maven :
328325
329- mvn install
326+ ``` shell
327+ mvn install
328+ ```
330329
331330the generated jar should be located at ** target/jruby-rack-* .jar**
332331
333332Alternatively use Rake, e.g. to build the gem (skipping specs) :
334333
335- jruby -S rake clean gem SKIP_SPECS=true
334+ ``` shell
335+ jruby -S rake clean gem SKIP_SPECS=true
336+ ```
336337
337338You can ** not** use JRuby-Rack with Bundler directly from the git (or http) URL
338339(` gem 'jruby-rack', :github => 'jruby/jruby-rack' ` ) since the included .jar file
@@ -341,7 +342,7 @@ package and push the .jar every time a commit changes a source file).
341342
342343## Releasing
343344
344- * Make sure auth is configured for "ossrh " repository ID in your .m2/settings.xml
345+ * Make sure auth is configured for "central " repository ID in your .m2/settings.xml
345346* Update the version in src/main/ruby/jruby/rack/version.rb to the release version
346347* mvn release: prepare
347348* mvn release: perform (possibly with -DuseReleaseProfile=false due to Javadoc doclint failures for now)
0 commit comments