Jruby / warbler / glassfish - envrionment.rb not read

Hope someone has a solution for this:

I have a rails application with a legacy database with column prefixes
on every table. For that I added a method set_column_prefix to
ActiveRecord::Base in environment.rb as proposed in
http://wiki.rubyonrails.org/rails/pages/howtouselegacyschemas.

So my enviroment.rb reads:

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence over those

specified here.

end

class << ActiveRecord::Base
def set_column_prefix(prefix)

end

require ‘timestamped’
class ActiveRecord::Base
include Timestamped
end

this works fine with mongrel on mri or jruby-1.1.6RC1, but when I
package with warbler and deploy to a glassfish v2 application server,
the column prefixes are not recognized:

[#|2008-12-23T17:48:26.250+0100|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=16;_ThreadName=httpWorkerThread-4848-0;_RequestID=a6230288-493f-49d2-9d22-fc40275afd89;|WebModule[/optile]unable
to create shared application instance

org.jruby.rack.RackInitializationException: undefined method
set_column_prefix' for #<Class:0x1124609> from C:\glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/app/models/acquirer.rb:8 from C:\glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/app/models/acquirer.rb:31:in require’
from
/C:/glassfish/domains/domain1/generated/jsp/j2ee-modules/optile/loader/META-INF/jruby.home/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
require' from C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in require’
from
C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:262:in
require_or_load' from C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:221:in depend_on’
from
C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:133:in
require_dependency' from C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/rails-2.2.2/lib/initializer.rb:368:in load_application_classes’
… 11 levels…
from
C:/glassfish/domains/domain1/generated/jsp/j2ee-modules/optile/loader/rack/builder.rb:22:in
instance_eval' from C:/glassfish/domains/domain1/generated/jsp/j2ee-modules/optile/loader/rack/builder.rb:22:in initialize’
from :3

at
org.jruby.rack.DefaultRackApplicationFactory$4.init(DefaultRackApplicationFactory.java:154)

:
:
Caused by: org.jruby.exceptions.RaiseException

at
Kernel.method_missing(C:/glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/gems/gems/activerecord-2.2.2/lib/active_record/base.rb:1833)

at
#Class:01x173b318.method_missing(C:\glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/app/models/acquirer.rb:8)

at
(unknown).(unknown)(C:\glassfish/domains/domain1/applications/j2ee-modules/optile/WEB-INF/app/models/acquirer.rb:31)

:
:
|#]

now, what’s strange is that I thought this had disappeared last night,
after many attempts with rearranging the definition of
set_column_prefix, but came up again after a fresh restart of the server
today.
If anyone has an explanation, workaround or fix for this, please let me
know.

complete sever log attached.

finally - i found an explanation and hence a solution: as fred explains
in his blog

I just cannot expect all environment.rb to be evaluated before the
application classes are getting loaded. I put the aliasing of the column
prefixes into an initializer and now it is fine on glassfish as well.