Forum: JRuby JRuby class consumed as a Java class for Wicket?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5c6727e573b7be20dea6a6880856a888?d=identicon&s=25 Mike Pence (Guest)
on 2013-10-03 05:44
(Received via mailing list)
So I guess that I am making a lot of the newbie mistakes, as I have
put JRuby and Wicket into a pom.xml file and started trying to get my
favorite web framework and my favorite language to play nice.

Naively, I thought that I could create a Ruby class that would be seen
Java as a Java class pretty trivially. But line 9 of tries to find a Java class by
referencing HomePage.class. I have translated to
with my best first guess ( but
never even gets that far. The compiler says WTF to me in the form of
cannot find symboll:  class HomePage
  location: class com.mycompany.WicketApplication."

So, now I know what Red Bridge is, and I recall BSF and all of that, but
just want a JRuby object that behaves like a Java object without all of
that rigamarole. What am I missing?
486ca04f06d968004643ce5b47376ded?d=identicon&s=25 Keith B. (keith_b)
on 2013-10-03 06:41
(Received via mailing list)
Mike -

I'm not confident about the answer, but it might be worth a try until
someone with a clue chimes in. ;)

I don't think Java code can access any Ruby classes by their class name.
What if you were to inject the Ruby class object into the Application
class?  For example, define a setter on your application class that
stores the passed class in a class variable. Then, have getHomePage
return that variable.

Somewhere in your app before Wicket calls getHomePage, you'd need to
call setHomePage with your Ruby class.

- Keith
C983ad33b47479f17a28e083e1bb3d8b?d=identicon&s=25 Eric West (edubkendo)
on 2013-10-03 06:44
(Received via mailing list)
Mike, I don't know how you are attempting to run these or hook them
together but jruby scripts require the jruby interpreter to run . So you
use jruby or jruby.jar to run the scripts just like you would run ruby
scripts from the command line : `jruby myscript.rb`. You can require and
use java classes in your jruby scripts, like you've done, but the java
of things can't so easily see and use your ruby classes. If the java
library you are using is expecting a java object, you may need to use
of the special conversion methods to make it work.

If you are trying to run this as java, and expecting the wicket library
just see your ruby class as if it was a java class, that won't work. in
that case, you would definitely need to use something like Red Bridge to
make it work.

In fact, looking into what Wicket is, and how it's run, (A Java EE web
framework, etc), because the java server expects to find specific java
classes in specific places in order to run things, I think you will need
write some kind of integration layer that essentially fires up your ruby
scripts inside a scripting container from the java process and gets them
talking. You might look into how jruby-rack and warbler accomplish this
sort of thing.

Sorry I can't be more help but I don't have any experience with what you
are trying to do. All the best, and I hope you can figure it out.
This topic is locked and can not be replied to.