Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a short coming when launching jruby-rack with webspere where the war... #170

Closed
wants to merge 1 commit into from

Conversation

mkristian
Copy link
Member

...-file gets not unpacked

see an explanation on how to setup websphere: https://github.com/mkristian/war-pack/

do not know how to provide a test case for this :( - hope that is OK

@kares
Copy link
Member

kares commented Mar 10, 2014

Thanks Kristian, last time I checked there were no issues deploying onto WS ( well all of them were fixed :) ... it's a bit unfortunate to put in an empty rescue block. do you still have the stack trace for the exception thrown and maybe report for future generations the server/jruby version used.

p.s. isn't this related to the refactorings done inside JRuby with how default gems are loaded ?
also, are you guys absolutely sure you want to force users to do/understand configuration details based on server type (assuming it somehow worked for all until now) ?

@mkristian
Copy link
Member Author

I can get the backtrace and then we can figure it out how to do it better
then with an empty rescue. but the point is the change directory just makes
no real sense if eveythings comes from within a warfile.

not sure if it is new and it depends on how directories are handled with
warfiles. just started to play around with packed war-files after basically
you told me it seems to work before ;)
t
that issue is NOT related to the default gems !!!

@mkristian
Copy link
Member Author

WebSphere Application Server Liberty Profile - version 8.5.5.1
https://www.ibmdw.net/wasdev/downloads/

only unexploded jars produces the error. (more later)

@kares
Copy link
Member

kares commented Mar 21, 2014

for the record of this issue ... here's the failure as reported by WAS Liberty Profile 8.5.5.1 :

org.jruby.rack.RackInitializationException: No such file or directory - /opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF
    from org/jruby/RubyDir.java:352:in `chdir'
    from classpath:/jruby/rack/booter.rb:125:in `change_working_directory'
    from classpath:/jruby/rack/booter.rb:105:in `boot!'
    from classpath:/jruby/rack/rails_booter.rb:26:in `boot!'
    from classpath:/jruby/rack/boot/rails.rb:10:in `(root)'
    from org/jruby/RubyKernel.java:1101:in `load'
    from <script>:1:in `(root)'

    at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
    at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:104)
    at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2220)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:960)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6049)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:421)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:241)
    at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:182)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:169)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:448)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:382)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:282)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:253)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:502)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:550)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:899)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:981)
    at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
    at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.jruby.exceptions.RaiseException: (Errno::ENOENT) /opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF
    at org.jruby.RubyDir.chdir(org/jruby/RubyDir.java:352)
    at RUBY.change_working_directory(classpath:/jruby/rack/booter.rb:125)
    at RUBY.boot!(classpath:/jruby/rack/booter.rb:105)
    at RUBY.boot!(classpath:/jruby/rack/rails_booter.rb:26)
    at RUBY.(root)(classpath:/jruby/rack/boot/rails.rb:10)
    at org.jruby.RubyKernel.load(org/jruby/RubyKernel.java:1101)
    at RUBY.(root)(<script>:1)

@kares
Copy link
Member

kares commented Mar 21, 2014

unfortunately ... as I was afraid it won't work with unexploded .war by default, due JRuby :

org.jruby.rack.RackInitializationException: No such file or directory - /opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF/gems/specifications/railties-4.0.3.gemspec
    from org/jruby/RubyFile.java:361:in `initialize'
    from org/jruby/RubyIO.java:1178:in `open'
    from org/jruby/RubyKernel.java:349:in `open'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/stub_specification.rb:61:in `data'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/stub_specification.rb:109:in `valid?'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:687:in `each_stub'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:678:in `each_gemspec'
    from org/jruby/RubyArray.java:1613:in `each'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:677:in `each_gemspec'
    from org/jruby/RubyArray.java:1613:in `each'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:676:in `each_gemspec'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:685:in `each_stub'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:705:in `stubs'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:897:in `find_inactive_by_path'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems.rb:183:in `try_activate'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:132:in `require'
    from classpath:/jruby/rack/rails/environment3.rb:23:in `load_environment'
    from classpath:/jruby/rack/rails_booter.rb:76:in `load_environment'
    from <script>:1:in `(root)'

    at org.jruby.rack.RackInitializationException.wrap(RackInitializationException.java:29)
    at org.jruby.rack.RackApplicationFactoryDecorator.init(RackApplicationFactoryDecorator.java:104)
    at org.jruby.rack.RackServletContextListener.contextInitialized(RackServletContextListener.java:50)
    at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2220)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:960)
    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:6049)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.startWebApp(DynamicVirtualHost.java:421)
    at com.ibm.ws.webcontainer.osgi.DynamicVirtualHost.createRunnableHandler(DynamicVirtualHost.java:241)
    at com.ibm.ws.http.internal.VirtualHostImpl.discriminate(VirtualHostImpl.java:182)
    at com.ibm.ws.http.dispatcher.internal.channel.HttpDispatcherLink.ready(HttpDispatcherLink.java:169)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:448)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.handleNewRequest(HttpInboundLink.java:382)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.processRequest(HttpInboundLink.java:282)
    at com.ibm.ws.http.channel.internal.inbound.HttpInboundLink.ready(HttpInboundLink.java:253)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:174)
    at com.ibm.ws.tcpchannel.internal.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:83)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.requestComplete(WorkQueueManager.java:502)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.attemptIO(WorkQueueManager.java:550)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager.workerRun(WorkQueueManager.java:899)
    at com.ibm.ws.tcpchannel.internal.WorkQueueManager$Worker.run(WorkQueueManager.java:981)
    at com.ibm.ws.threading.internal.Worker.executeWork(Worker.java:439)
    at com.ibm.ws.threading.internal.Worker.run(Worker.java:421)
    at java.lang.Thread.run(Thread.java:744)
Caused by: org.jruby.exceptions.RaiseException: (Errno::ENOENT) /opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF/gems/specifications/railties-4.0.3.gemspec
    at org.jruby.RubyFile.initialize(org/jruby/RubyFile.java:361)
    at org.jruby.RubyIO.open(org/jruby/RubyIO.java:1178)
    at org.jruby.RubyKernel.open(org/jruby/RubyKernel.java:349)
    at RUBY.data(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/stub_specification.rb:61)
    at RUBY.valid?(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/stub_specification.rb:109)
    at RUBY.each_stub(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:687)
    at RUBY.each_gemspec(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:678)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
    at RUBY.each_gemspec(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:677)
    at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
    at RUBY.each_gemspec(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:676)
    at RUBY.each_stub(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:685)
    at RUBY.stubs(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:705)
    at RUBY.find_inactive_by_path(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/specification.rb:897)
    at RUBY.try_activate(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems.rb:183)
    at RUBY.require(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:132)
    at RUBY.load_environment(classpath:/jruby/rack/rails/environment3.rb:23)
    at RUBY.load_environment(classpath:/jruby/rack/rails_booter.rb:76)
    at RUBY.(root)(<script>:1)

@mkristian do you know if this happens to get addressed on JRuby itself ?
seems to me that maybe if the path(s) had a jar:// prefix added it would work (not sure why it's not there seems to be that it used to be there), but even without it it should be detectable ... since there's a !/ in the path although that might be a bit "risky"
p.s. used bug-demo.war from https://github.com/mmc1ntyre/bug-demo just replaced the jruby-rack.jar

@mkristian
Copy link
Member Author

FYI: jruby has a nice feature for rubygems which I use for quite some time
with jruby-maven-plugins: just add your gems/* and specifactions/*
directory to the classloader. i.e. instead of putting you gems in
WEB-INF/gems put them into WEB-INF/classes. the advantage is that you do
not need to fiddle around with setting the Gem.path ! that is what I used
for warfile to test and that works with websphere for exploded and
unexploded warfiles.

BTW I also pack all the files which should be on the LOAD_PATH in
WEB-INF/classes as well - in that way I do not need to set ANY paths for
starting the app. so my startup script
ruby -Ilib rackup
works with the same on the commandline as a warfile.

rails might not work since they rely on path operations all over the place
to find their files :(

here that issue only came since it raises an exception when jruby-rack does
a Dir.chdir(...). finding the gems depends on where you pack them.

to detect a jar url by the '!/' inside the path could be doable ;)

@kares
Copy link
Member

kares commented Mar 21, 2014

Thanks Kristian, that is great to know but our users likely do not now about those details thus would be great to provide them with an "out-of-the-box experience" ... instead of, you know, a "Java-EE experience" it is configurable just copy that here and there :) ... so maybe this should than go with Warbler to introduce an option of packing gems into WEB-INF/classes (I do not like that but if it works it's better than failing) ?

@mkristian
Copy link
Member Author

well, I try to also look at how to setup a servlet which uses JRuby's ScriptingContainer and gems. there it is easier if you do not need to worry about how to setup the ENV['GEM_PATH'] and that is how I personally pack executable jars using ScriptingContainer and gems. and to run junit-tests I just need to make sure rubygems are on the classpath.

let see what @jkutner says about the idea to add an alternative packing for warbler.

@kares
Copy link
Member

kares commented Mar 21, 2014

actually, (maybe) less of a need to. I was able to get WAS to boot a "little more" by hacking getRealPath (and related) in a more "smart-way" ... so for now it's only JRuby's load/require likely not handling WAS' "wsjar:" protocol :

after an expanded require 'wsjar:file:/opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF/config/boot.rb' I get (not sure why it removed .rb but I bet it's due "wsjar:")

Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- wsjar:file:/opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF/config/boot
    at org.jruby.RubyKernel.require(org/jruby/RubyKernel.java:1085)
    at RUBY.require(classpath:/META-INF/jruby.home/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:55)
    at RUBY.load_environment(classpath:/jruby/rack/rails/environment3.rb:23)
    at RUBY.load_environment(classpath:/jruby/rack/rails_booter.rb:131)
    at RUBY.(root)(<script>:1)

should be noted that some File methods seem to work e.g. I got File.directory?("wsjar:file:/opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF") true ... while File.exist?("wsjar:file:/...") on files as well as dirs seems to always return false.

p.s. I was hoping you won't tell @jkutner ... he is a former IBM employee and he'll do anything to get their "Liberty Profile" working :) ... we're pretty much screwed here!

@mkristian
Copy link
Member Author

since you are already so far you could just try using (just a feeling)
file:/opt/apps/wlp/usr/servers/defaultServer/dropins/bug-demo.war!/WEB-INF/config/boot.rb

but File.dir? and File.exists? should behave consistently - maybe a bug.
the .rb might also be related to give preference to compile ruby files
which would end with .class instead (not sure though).

PS I might ask you one day to look at jruby-rack (for version 2.0) to be
more minimalistic reading non-rails applications. maybe I will not ask -
not sure yet ;)

PSS I had the feeling WS will have more funny classloader surprises hidden
;)

@kares
Copy link
Member

kares commented Jul 24, 2014

I've put out 1.1.15 (long time coming) where some of the "real-path" layout resolution is improved ...

@kares kares closed this Jul 24, 2014
@mkristian
Copy link
Member Author

thanx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants