I’m attempting to use YAJB to talk to JasperReports from Ruby.
Please scream at me right now if there’s a better way to get to
JasperReports.
This is what I have so far:
-------------------BEGIN------------------
require ‘yajb/jbridge’
require ‘fileutils’
include JavaBridge
$REPORTS_LIB_DIR = “/home/kevin/dli/” + “backend/reports_module/lib/”
path = “$CLASSPATH”
FileUtils::cd($REPORTS_LIB_DIR) do
Dir[“*.jar”].each { |name|
path += “:#{$REPORTS_LIB_DIR + name}/”
}
end
JBRIDGE_OPTIONS = {
:classpath => path
}
jimport “net.sf.jasperreports.engine.*”
jimport “java.util.HashMap”
jasperReport = jnew :JasperCompileManager
jasperReport.compileReport(
“/home/kevin/dli/backend/reports_module/report_templates/VirtualizerReport.jrxml”);
hash = jnew :HashMap
data = jnew :JREmptyDataSource
jasperPrint = jnew :JasperFillManager
jasperPrint.fillReport(jasperReport, hash, data)
-------------------END------------------
This does just fine for compiling the report, but when I try to call
fillReport, the world blows up:
/usr/local/lib/site_ruby/1.8/yajb/bstream.rb:655:in value': java.lang.RuntimeException (JavaBridge::JException) No such method: fillReport in net.sf.jasperreports.engine.JasperFillManager java.lang.RuntimeException: No such method: fillReport in net.sf.jasperreports.engine.JasperFillManager at jbridge.BridgeServer.generalCall(BridgeServer.java:145) at jbridge.BridgeServer.call(BridgeServer.java:179) at jbridge.comm.binstream.BStream_JBServer$2.send(BStream_JBServer.java:140) at jbridge.comm.binstream.MessageServer$MethodInvocation.run(MessageServer.java:456) at jbridge.InvocationPool$Worker.workloop(InvocationPool.java:97) at jbridge.InvocationPool$Worker.access$000(InvocationPool.java:55) at jbridge.InvocationPool$1.run(InvocationPool.java:62) at java.lang.Thread.run(Unknown Source) from /usr/local/lib/site_ruby/1.8/yajb/bstream.rb:810:in
send_message’
from /usr/local/lib/site_ruby/1.8/yajb/bstream.rb:1048:in
send_message' from /usr/local/lib/site_ruby/1.8/yajb/comm_bstream.rb:59:in
send_message_to_java’
from /usr/local/lib/site_ruby/1.8/yajb/jbridge.rb:506:in
__send_message_to_java' from /usr/local/lib/site_ruby/1.8/yajb/jbridge.rb:739:in
call’
from /usr/local/lib/site_ruby/1.8/yajb/jbridge.rb:685:in
`method_missing’
from ./testing_stub.rb:35
I could see why it would get confused. It’s an overloaded method. I’ve
poured over the docs for yajb but haven’t found anywhere that explains
how to
force calls of overloaded methods. I would like to use yajb because
it’s
pure ruby and pure java, meaning no compiling, and installs are easy.
The
communication being slow makes almost zero difference to me because I
won’t
be doing very much communication, just spawning off processor hogs with
the
thing.
So is there a way to specify types for overloaded methods, or do I need
to use
RJB (http://arton.no-ip.info/collabo/backyard/?RubyJavaBridge)? Or do I
need
to be slapped across the face with a wet trout for not seeing the easy
solution?