Jruby 1.6.0.RC2 + Rails3 + Glassfish-gem = big fail - glassfish

Having problems getting glassfish to even run on my server. jRuby is absoutely maddening to begin with, but this is killing me.
I have a pretty complex app, so I won't go into too many details, other than to say the Rails2 version is working under jRuby 1.5.1.
When I start and do the first hit on the server I get the following error:
Feb 19, 2011 12:20:14 AM com.sun.grizzly.jruby.RackGrizzlyAdapter dispatchRequest
WARNING: (NoMethodError) undefined method `call' for nil:NilClass
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `call' for nil:NilClass
at Rack::Handler::Grizzly.call(/usr/local/rvm/gems/jruby-1.6.0.RC2/gems/glassfish-1.0.3.dev-universal-java/lib/rack/handler/grizzly.rb:55)
I have tried starting glassfish every way since sunday and have also swapped out various gems. It seems bundler 1.0.10 also has some issues. It broke my Rails2 app.
Any insite anywhere as to where to even start looking would be appreciated.
The app works just fine when running webrick.

The jRuby stack still has a long way to go. Finally figured this debacle out. Turns out the rackup.rb file pulled into glassfish from an as yet unidentified source (I hacked it for now and moved on) has logic that only supports rack in development, test or production. I was using a multistage environment so I could test things out. I had a, shocker, staging environment. So this all worked fine under the old glassfish that detected and ran rails separately but created a host of issues for the rails3 application running with a config.ru rack file.
I will post an update to my blog when I get this nailed down correctly. You can't monkey patch this because glassfish loads from the installed gem location not your own project or even bundle repository.

Related

Hard time installing Ruby on Rails because of different RVM versions

I'm following Michael Hartl's Ruby on Rails tutorial book and am trying to install rails. As the book says, I followed the instructions on InstallRails.com and got through most of it until I was told to run rails server and I kept getting the error that I didn't have railties gem not installed. I had initially ran sudo gem install rails and so I read that it didn't pick up railties for some reason but gem install rails did - so that fixed it. So now I was able to run rails server and the app was live.
I returned to the book and as the instructions say, I generated a new rails app, specifying the rails version (4.2.2). However, when I run rails again, I get errors. At this point, having tried a dozen different stackover flow solutions, I feel like I must have screwed up the files and maybe I should just get rid of rails completely and try installing from scratch.
Here's some information on where I'm currently at:
Faiques-MacBook-Pro:Desktop Faique$ rails -v
Rails 4.2.3
Faiques-MacBook-Pro:Desktop Faique$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
Faiques-MacBook-Pro:Desktop Faique$ mkdir workspace
Faiques-MacBook-Pro:Desktop Faique$ cd workspace
Faiques-MacBook-Pro:workspace Faique$ rails _4.2.2_ new hello_app/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'railties' (= 4.2.2) - did find: [railties-4.2.3] (Gem::LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/ ubygems/dependency.rb:307:in `to_spec'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:47:in `gem'
from /usr/bin/rails:22:in `<main>'
I'm not sure what other information I should provide.
This isn't an ideal solution but what I ended up doing was completely restoring my mac and then reinstalling rails but using rbenv instead as per a friend's recommendation. I am now set up with Rails.
I wanted to do a complete restore (deleting all my data) because I had tried so many stack overflow answers for different errors - including using sudo for certain commands - that I'm sure I had messed some important settings and would take a long time to figure out. I think this was surprisingly one of the more efficient solution, although far from ideal.

New Relic ActiveRecord::ConnectionNotEstablised Rails 3.2.3 error

I just installed the newrelic_rpm gem in my RefineryCMS Rails 3.2.3 application. I copied in the newrelic.yml config file as per the instructions. My app is being deployed with Heroku on the Cedar stack, so the instructions were pretty simple.
https://devcenter.heroku.com/articles/newrelic#cedar
However, running "rails server" on my development box gave me this error message:
/home/xxx/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:398:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
Setting the agent_enabled value to "false" in the newrelic.yml file allowed the server to start up again. Setting my license key and app name environment variables made no difference.
Interestingly, even though I couldn't get the app to start on my dev box, when I deployed it to Heroku, everything worked fine - and I am now getting new relic stats. Great!
My workaround has been to remove newrelic_rpm from the gemfile (which is what the install instructions say to do), and put it only into a :production group. Obviously, new relic is only useful in production, so it's no big deal.
group :production do
... other gems
gem 'newrelic_rpm'
end
Anyone else ever experienced this, or know why it should be causing an ActiveRecord error (with no mention in the error trace of new relic at all)?
The issue you were running into looks like a bug in the newrelic_rpm gem that was addressed with our (I work at New Relic) recent 3.6.4 release. I'd suggest that you try updating to 3.6.4 to see if the issue persists.
By way of explanation: we have something in the newrelic_rpm gem called an EnvironmentReport, which gathers information about the environment your application is executing in (Rails version, gem versions, DB adapter, Ruby version, etc) to display in the UI. In version 3.6.0 of the newrelic_rpm gem, we pushed the generation of the EnvironmentReport into a background thread. Because the EnvironmentReport potentially referenced the ActiveRecord::Base constant, generating it could trigger some ActiveRecord initialization code paths that are not thread-safe. If the EnvironmentReport happened to hit ActiveRecord::Base at just the wrong time, it could trigger errors like what you were seeing on the main thread.
We addressed this in 3.6.4 by moving the generation of the EnvironmentReport back onto the main thread.
Sorry for the headache, and please let us know if 3.6.4 doesn't solve your issue.
Edit - hmm, just noticed that you asked about this before 3.6.0 was released. I'd still suggest trying 3.6.4, since I suspect a similar race condition may have existed in older versions of the newrelic_rpm.

activeadmin formatting error on rails 3 app

I recently migrated a rails 3 app from a Mac OS X environment to a Debian server. The migration succeeded, the app is running through the WEBrick server but the formatting that had originally come with the activeadmin gem has disappeared from most views. The form is still accessible and functioning but it is in the default html formatting.
However http://domainexample.com:3000/admin still has the custom formatting, any ideas of why this has happened?
In my troubleshooting:
reinstalled activeadmin with
rails generate active_admin:install
When I run
rake db:migrate
got devise errors so dropped the databases and ran
rake db:create
rails s still works and boots the server but
rake db:migrate throws an error:
Mysql2::Error: Table 'admin_users' already exists
UPDATE:
This fixed the problem, but I don't understand why.
had to copy the active_admin.css as active_admin.css.dup.css file from my local and upload it to the server version in app/assets/stylesheets. The server version was implementing namespaces for some reason.

Building .war with JRuby and warbler

I have been trying for hours to get a JRuby Rails application packaged as a war that actually works, without success... (JRuby 1.6.7, warbler 1.3.5, Rails 3.2.2)
Issue #1: Warbler seems to like to lump all libraries in one root folder rather than respecting the subdirectories they originally came from. For example, the Rails app itself runs fine but the war is broken when libraries are referenced as
require "lib/foo/bar.jar"
require "lib/baz.rb"
Mind you, foo/bar.jar and baz.rb are actually present in WEB-INF/lib, I just don't know how to configure Warbler to wire things up so the requires work right.
Issue #2: If I condescend to change all the requires to
require "bar.jar"
require "baz.rb"
, all is well if I build an executable war file, but if I try dropping the war into a Tomcat 6.0.20 installation, the application fails to initialize:
SEVERE: Error: application initialization failed
java.lang.NullPointerException
at org.jruby.RubyInstanceConfig$ArgumentProcessor.processArguments(RubyInstanceConfig.java:711)
No amount of Googling has shed light on what the problem is. Presumably the war is missing something or misconfigured somehow, but what is it?
I can't say for sure this would cause your error - however I remember that there was a known bug between Jruby and Rails 3.2.x - which was apparently fixed in Jruby 1.7.
I had tried using Rails 3.2 with Jruby 1.6.7 before and came across this:
JIRA-Ticket-JRUBY-3986
Hope that may at least help a little

Pushing new Rails 3.1 app to Heroku causing problems with Sorcery mod (requiring bson-1.4.1)

I have an app that runs great locally. Everything seems to be set up correctly to transfer over to Heroku, including the Postgres gem (and dev was done using a postgres server).
The problem is, when I try to push it up, I get error messages surrounding the three currently problematic dependencies, bson_ext, bson, and mongoid, 1.4.1. It seems that Sorcery requires these (at 1.4.1) to run. I got them installed locally by downloading the manually, but they were yanked from the online sources. So when Heroku tries to find them, it can't, and it aborts. I tried specifying to use 1.4.0 for all of them, and the app then installs fine (and does the database setup stuff for the Cedar stack, etc).
The problem is that when I load the app on their server, I get the generic "oops, there's been a problem" Heroku message. Upon checking the actual heroku log, I can't really find anything wrong. What is the way to make this work?
Thanks for your help.
I ran into the same problem, and I was able to get past it by specifying version 1.3.1 for the mongo, bson, and bson_ext gems. I just put this in my Gemfile:
gem 'mongo', '1.3.1'
gem 'bson', '1.3.1'
gem 'bson_ext', '1.3.1'