How to re-use Play app's models in a JRuby script?

9 views
Skip to first unread message

nile...@truweight.in

unread,
May 25, 2016, 6:44:25 AM5/25/16
to play-framework
I am trying to re-use my webapp's code for somebackground scripts. This is at the top of my Ruby script:

require 'java'
Dir["./target/universal/myapp-1.0-SNAPSHOT/lib/*.jar"].each { |jar| require jar }

The JARs were generated with "activator dist". After this, I am able to import some Java classes from my app and use them in Ruby script:

java_import 'util.Utility'
Utility.main()


However, this does not work for all classes. Utilities, Beans work fine but models (which are using Ebean ORM), throw this error:

jruby-9.0.5.0> java_import 'models.Centre'
NameError: cannot initialize Java class models.Centre
    from org/jruby/javasupport/JavaClass.java:204:in `for_name'
    from org/jruby/javasupport/JavaUtilities.java:34:in `get_proxy_class'


JRuby version: jruby 9.0.5.0 (2.2.3) 2016-01-26 7bee00d Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 +jit [linux-amd64]
Play framework version: 2.3.9

What am I missing? How do I debug this issue further?
Reply all
Reply to author
Forward
0 new messages