Forum: JRuby AOT compile rails apps

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sam (Guest)
on 2008-10-15 00:08
(Received via mailing list)
Hi,
I got a question regarding jruby's aot compile feature. Is it possible
to ship an obfuscated rails app with it?

I tried compiling only my controllers but I get an error regarding
Invalid characters (see stacktrace).

Does someone know how to start an obfuscated rails app or can provide
a tutorial? At least ThoughtWorks mingle is shiping as obfuscated
project so it should be possible.

Thanks
Sam



First stacktrace

mb-2:jrubyc -p "" controllers/
Compiling all in '/Users/main/repositories/testapp/trunk/app/
controllers'...
Compiling controllers//activities_controller.rb to class controllers/
activities_controller
Compiling controllers//application.rb to class controllers/application
...
...
...

mb-2:cd controllers/
mb-2:controllers main$ ls -d *.class | sed 's/\(.*\).class$/mv "&"
"\1.rb"/' | sh
mb-2:controllers main$ cd ../../
mb-2:trunk main$ jruby -S script/server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails 2.1.0 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/Users/main/repositories/testapp/trunk/app/controllers/application.rb:
215: /Users/main/repositories/testapp/trunk/app/controllers/
application.rb:1: Invalid char `\276' ('?') in expression (SyntaxError)
  from /Users/main/repositories/testapp/trunk/app/controllers/
application.rb:215:in `load'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:215:in `load_file'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:354:in
`new_constants_in'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:214:in `load_file'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:95:in `require_or_load'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:60:in `depend_on'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/dependencies.rb:456:in
`require_dependency'
  from /Users/main/repositories/testapp/trunk/vendor/rails/actionpack/
lib/action_controller/dispatcher.rb:18:in `define_dispatcher_callbacks'
   ... 38 levels...
  from /Users/main/repositories/testapp/trunk/vendor/rails/railties/lib/
commands/server.rb:27:in `require'
  from /opt/local/share/java/jruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require'
  from script/server:3
mb-2:trunk main$


second stacktrace

mb-2:trunk main$ java -cp .:/Users/main/Desktop/test/WEB-INF/lib/jruby-
complete-1.1.4.jar script/server
Exception in thread "main" /Users/main/repositories/testapp/trunk/
vendor/rails/activesupport/lib/active_support/vendor.rb:2:in
`require': no such file to load -- rubygems (LoadError)
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/vendor.rb:2
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support/vendor.rb:26:in `require'
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support.rb:26
  from /Users/main/repositories/testapp/trunk/vendor/rails/
activesupport/lib/active_support.rb:1:in `require'
  from /Users/main/repositories/testapp/trunk/vendor/rails/railties/lib/
commands/server.rb:1
  from /Users/main/repositories/testapp/trunk/vendor/rails/railties/lib/
commands/server.rb:3:in `require'
  from script/server:3
  ...internal jruby stack elided...
  from Kernel.require(/Users/main/repositories/testapp/trunk/vendor/
rails/activesupport/lib/active_support/vendor.rb:2)
  from (unknown).(unknown)(/Users/main/repositories/testapp/trunk/
vendor/rails/activesupport/lib/active_support/vendor.rb:26)
  from Kernel.require(/Users/main/repositories/testapp/trunk/vendor/
rails/activesupport/lib/active_support.rb:26)
  from (unknown).(unknown)(/Users/main/repositories/testapp/trunk/
vendor/rails/activesupport/lib/active_support.rb:1)
  from Kernel.require(/Users/main/repositories/testapp/trunk/vendor/
rails/railties/lib/commands/server.rb:1)
  from (unknown).(unknown)(/Users/main/repositories/testapp/trunk/
vendor/rails/railties/lib/commands/server.rb:3)
  from Kernel.require(script/server:3)
  from (unknown).(unknown)(:1)
Rich M. (Guest)
on 2008-10-15 01:05
(Received via mailing list)
Hi Sam.  There's more on this topic on this thread:
http://jruby.markmail.org/search/?q=manalang&x=0&y...

The answer is yes, you can compile your rails app (I've tested with the
app/
and lib/ directories fully compiled using jrubyc).  You will need to
patch
ActiveSupport to get it to work though.

As far as obfuscation goes, I don't know what TW is using to obfuscate
their
code (I think it's something they wrote themselves).

Rich
Charles Oliver N. (Guest)
on 2008-10-15 04:24
(Received via mailing list)
Rich M. wrote:
> Hi Sam.  There's more on this topic on this thread:
> 
http://jruby.markmail.org/search/?q=manalang&x=0&y...
> 
<http://jruby.markmail.org/search/?q=manalang&x=0&y...
>
> The answer is yes, you can compile your rails app (I've tested with the
> app/ and lib/ directories fully compiled using jrubyc).  You will need
> to patch ActiveSupport to get it to work though.

I'm going to comment on that in the recent thread, but I think we should
fix load to look for .class files as well.

> As far as obfuscation goes, I don't know what TW is using to obfuscate
> their code (I think it's something they wrote themselves).

I believe TW ships a special LoadService (the logic behind require and
load) that decrypts their encrypted .rb source files.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.