Hello everyone!
Hope this is an appropriate place to post this. I’ve also gotten
questions onto the sinatra, warbler, and jruby-rack lists, but am
thinking it might be better here, but maybe I’m wrong. I am a lot. In a
nutshell, just read the questions within the many, many equals marks. I
don’t live in a nutshell often, which is why it spills between.
I’m having some trouble in our jruby + jruby-rack + sinatra app with the
following:
======================================================================================================================================================
- Trying to get a rack test working for a sinatra app (and I’ve used
the recently updated Testing Sinatra with Rack::Test as an
example) where the Sinatra app is using some jars for a custom client
that I wrote.
======================================================================================================================================================
jruby -S rake test
I get:
(in /Users/garyweaver/dev/git/dmws)
“Classpath is "
“Classpath is (contains all jars required)”
(eval):1:in `include_class’: cannot load Java class
(fully qualified classname of class being called) (NameError)
rake aborted!
Command failed with status (1): [/(path to jruby)/jruby/bin/jruby -
I"lib” …]
(See full trace by running task with --trace)
Rakefile looks like:
—start copy/paste—
raise “Rake must be called with JRuby: try again with `jruby -S rake’”
unless defined?(JRUBY_VERSION)
p “Classpath is #{ENV[‘CLASSPATH’]}”
ENV[‘CLASSPATH’] = Dir[“#{File.expand_path ‘lib’}/*.jar”].join
(File::PATH_SEPARATOR)
p “Classpath is #{ENV[‘CLASSPATH’]}”
require ‘rubygems’
require ‘rake’
require ‘rake/testtask’
desc “Default: run all tests”
task :default => :test
desc “Run tests”
task :test => %w(test:units test:acceptance)
namespace :test do
desc “Run unit tests”
Rake::TestTask.new(:units) do |t|
t.test_files = FileList[“test/unit/*_test.rb”]
end
desc “Run acceptance tests”
Rake::TestTask.new(:acceptance) do |t|
t.test_files = FileList[“test/acceptance/*_test.rb”]
end
end
—end copy/paste—
======================================================================================================================================================
2. Trying to get some sort of standard logging with timestamp working in
the Sinatra app (assuming rack logger is best, but can’t get it to
work?)
In the sinatra controller script I wrote it has:
…
configure do
Sample = “test”
Version = Sinatra::VERSION
set :dump_errors, true
set :clean_trace, false
try to setup the rack logger
set :logging, false
Log = Logger.new(“myapplication.log”)
use Rack::CommonLogger, Log
end
…
post ‘/somepath’ do
#Log.debug “Request coming in: #{request.inspect}”
…
end
…
Here is the error I get:
uninitialized constant Logger from dc_controller.rb:33 from
/usr/java/apache-tomcat-6.0.18/webapps/dmws/WEB-INF/gems/gems/sinatra-0.9.2/lib/sinatra/base.rb:849:in
configure' from (__DELEGATE__):3:in
configure’ from
dc_controller.rb:21 from dc_controller.rb:31:in `require’ from
file:/usr/java/apache-tomcat-6.0.18/webapps/dmws/WEB-INF/lib/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require’ from
======================================================================================================================================================
3. The recommended way to ensure that the jruby and jruby-rack jars and
other gems are consistent both in the version of the sinatra app tested
by rack-test and the warbled (warred) webapp, and are also all “frozen”
(including the jars) in the project itself and not scattered about under
the jruby installation’s gems.
Part of this (the keeping the jruby and jruby-rack jars in the project
directory structure that warbler uses at least) could be solved I guess
with the stuff that Nick put here:
Specifically something similar to this part (except paths would need to
be different, and would also want jruby in there):
config.java_libs.delete_if {|f| f =~ /jruby-rack/}
config.java_libs += FileList[“…/…/target/jruby-rack*.jar”]
======================================================================================================================================================
4. I’d like to easily be able to work with the most recent version of
jruby and jruby-rack jars instead of building the version in git with
ant jar-complete and putting it into (jruby
install dir)/lib/ruby/gems/1.8/gems/warbler-0.9.13/lib/ which for
whatever reason in my case still causes warbler to include the released
jruby-complete jar (1.3.0RC1) instead of just the locally-built one.
Other than the method mentioned in #3 above for warbler including diff
jars, is it possible to grab some nightly build of the jruby complete
and jruby-rack jars from some Ivy/Maven 2 repo or similar that you’d
recommend?
Thanks!
Gary
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email