Peter K Chan created JRUBY-6619:
-----------------------------------
Summary: NoMethodError 'upcase' on Java string
Key: JRUBY-6619
URL: https://jira.codehaus.org/browse/JRUBY-6619
Project: JRuby
Issue Type: Bug
Components: Java Integration
Affects Versions: JRuby 1.6.7
Environment: Windows Server 2008 and Windows Server 2008 R2 with JDK
7u3
Reporter: Peter K Chan
I have a Rails 2.3.14 app, running on Trinidad. However, when starting up the
web app, I am getting sporadic NoMethodError when serving initial pages.
{code}
Application Error
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `upcase'
for #<Java::JavaLang::String:0x17a4277>
at
LazyEnv.load_headers(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack-1.1.4.jar!/rack/handler/servlet.rb:101)
{code}
Here is the section of code from jruby-rack-1.1.4:
{code}
...
@servlet_env.getHeaderNames.each do |h|
next if h =~ /^Content-(Type|Length)$/i
puts h.inspect; puts h.class.name; k = "HTTP_#{h.upcase.gsub(/-/, '_')}" #
line 101 / puts added for tracing.
env[k] = @servlet_env.getHeader(h) unless env.has_key?(k)
end
...
{code}
It appears that on line 101 of jruby-rack-1.1.4, when loading headers, JRuby is
not automatically converting Java strings into Ruby strings, leading to the
NoMethodError.
Here is a full transcript of two web app launches, with the above trace
statements.
The first one is a normal one.
{code}
C:\work\app>web.bat
Apr 04, 2012 12:09:48 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-5000"]
Apr 04, 2012 12:09:48 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Apr 04, 2012 12:09:48 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
2012-04-04 05:09:48 INFO: No global web.xml found
Info: received max runtimes = 1
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) Client VM
1.7.0_03) [Windows Server 2008-x86-java]
Runtime start
2012-04-04 05:10:00 INFO: Starting ProtocolHandler ["http-bio-5000"]
"host"
String
"user-agent"
String
"accept"
String
"accept-language"
String
"accept-encoding"
String
"accept-charset"
String
"keep-alive"
String
"connection"
String
"cookie"
String
"if-none-match"
String
"cache-control"
String
"host"
String
"user-agent"
String
"accept"
String
"accept-language"
String
"accept-encoding"
String
"accept-charset"
String
"keep-alive"
String
"connection"
String
"referer"
String
"cookie"
String
"if-modified-since"
String
"cache-control"
String
"host"
String
"user-agent"
String
"accept"
String
"accept-language"
String
"accept-encoding"
String
"accept-charset"
String
"keep-alive"
String
"connection"
String
"referer"
String
"cookie"
String
"if-modified-since"
String
"cache-control"
String
"host"
String
"user-agent"
String
"accept"
String
"accept-language"
String
"accept-encoding"
String
"accept-charset"
String
"keep-alive"
String
"connection"
String
"referer"
String
"cookie"
String
"if-modified-since"
String
"cache-control"
String
2012-04-04 05:10:05 INFO: Pausing ProtocolHandler ["http-bio-5000"]
2012-04-04 05:10:05 INFO: Stopping service Tomcat
Runtime exit
2012-04-04 05:10:05 INFO: Stopping ProtocolHandler ["http-bio-5000"]
2012-04-04 05:10:06 INFO: Destroying ProtocolHandler ["http-bio-5000"]
Terminate batch job (Y/N)? ^C
{code}
The second one is the one where JRuby failed to convert Java string to Ruby
string:
{code}
C:\work\app>web.bat
Apr 04, 2012 12:10:12 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-5000"]
Apr 04, 2012 12:10:12 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Apr 04, 2012 12:10:12 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.23
2012-04-04 05:10:13 INFO: No global web.xml found
Info: received max runtimes = 1
jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (Java HotSpot(TM) Client VM
1.7.0_03) [Windows Server 2008-x86-java]
Runtime start
2012-04-04 05:10:24 INFO: Starting ProtocolHandler ["http-bio-5000"]
#<Java::JavaLang::String:0x17a4277>
Java::JavaLang::String
Application Error
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `upcase'
for #<Java::JavaLang::String:0x17a4277>
at
LazyEnv.load_headers(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:101)
at
Enumeration.each(C:/java/xjruby/lib/ruby/site_ruby/shared/builtin/java/java.util.rb:39)
at
LazyEnv.load_headers(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:99)
at
LazyEnv.load_env_key(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:74)
at
LazyEnv.initialize(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-
rack-1.1.4.jar!/rack/handler/servlet.rb:59)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:270)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:220)
at org.jruby.RubyHash.default(org/jruby/RubyHash.java:647)
at org.jruby.RubyHash.[](org/jruby/RubyHash.java:1007)
at
Env.populate(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack-1
.1.4.jar!/rack/handler/servlet.rb:47)
at
Env.initialize(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack
-1.1.4.jar!/rack/handler/servlet.rb:41)
at
Servlet.create_env(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-
rack-1.1.4.jar!/rack/handler/servlet.rb:24)
at
Servlet.call(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack-1
.1.4.jar!/rack/handler/servlet.rb:20)
#<Java::JavaLang::String:0x17a4277>
Java::JavaLang::String
Error: Couldn't handle error
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `upcase'
for #<Java::JavaLang:
:String:0x17a4277>
at
LazyEnv.load_headers(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:101)
at
Enumeration.each(C:/java/xjruby/lib/ruby/site_ruby/shared/builtin/java/java.util.rb:39)
at
LazyEnv.load_headers(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:99)
at
LazyEnv.load_env_key(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jrub
y-rack-1.1.4.jar!/rack/handler/servlet.rb:74)
at
LazyEnv.initialize(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-
rack-1.1.4.jar!/rack/handler/servlet.rb:59)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:270)
at org.jruby.RubyProc.call(org/jruby/RubyProc.java:220)
at org.jruby.RubyHash.default(org/jruby/RubyHash.java:647)
at org.jruby.RubyHash.[](org/jruby/RubyHash.java:1007)
at
Env.populate(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack-1
.1.4.jar!/rack/handler/servlet.rb:47)
at
Env.initialize(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack
-1.1.4.jar!/rack/handler/servlet.rb:41)
at
Servlet.create_env(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-
rack-1.1.4.jar!/rack/handler/servlet.rb:24)
at
Servlet.call(file:C:/java/xjruby/lib/ruby/gems/1.8/gems/jruby-rack-1.1.4/lib/jruby-rack-1
.1.4.jar!/rack/handler/servlet.rb:20)
{code}
I can reproduce this about 40% of the time. Generally, if this happens, my
webapp will not work and I need to restart it a few times until it works. I am
at a loss as to how to debug this further. Any suggestions appreciated.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email