JRuby and Apache FOP

Hi all,

I am working on a rails based project. The application will generate a
lot of documents in different kind of file formats, based on a XSLT
toolchain. In a previous project I used BackgrounDrb for the XSLT and
XSL-FO processing. With the availableness of JRuby a better approach
would be, to integrate the FO processor of the Apache Group directly
in the Rails Application. So I switched to JRuby am I am impressed how
good JRuby works.

For testing purpose I want to write a little JRuby application
independent from rails, in order to test the approach partly because
I am new to JRuby. Here is my starting point:

include Java

require ‘fop.jar’

module ApacheFop
include_package “org.apache.fop.apps”
end

fopfactory = ApacheFop::FopFactory.newInstance();

The problem is that the class FopFactory is not avaible unlike the
other classes in this package. The error message looks like

pbook-2:jrFOP $ jruby test.rb
/…/jruby-1.1.2/lib/ruby/site_ruby/1.8/builtin/javasupport/core_ext/
module.rb:24:in const_missing': uninitialized constant ApacheFop::FopFactory (NameError) from /.../jruby-1.1.2/lib/ruby/site_ruby/1.8/builtin/javasupport/ core_ext/module.rb:24:inconst_missing’
from test.rb:9

Does anyone here already used the FOP library in JRuby or has any
suggestions, where the problem is?

With best regards

Alexander
Küken

Alexander
KükenStudent
University of applied sciences Wiesbaden, Germany
Department of Design, Computer Science and Media


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi,

Most probably, you need more than just fop.jar in the classpath.
Try this (while you’re experimenting):

jruby -d -S jirb

(that would start irb in debug mode, and you’ll see more exceptions out
of JRuby
providing more info about why class cannot be loaded).

In your case:
#> require ‘java’
#> require ‘fop.jar’
#> org.apache.fop.apps.FopFactory.newInstance #===>

java.lang.NoClassDefFoundError:
org/apache/xmlgraphics/image/loader/ImageContext
at java.lang.ClassLoader.defineClass1(Native Method)

Thanks,
–Vladimir


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Thanks a lot Vladimir. The classpath was the problem. Seeting up the
CLASSPATH in the system enviroment did not work. But the following
solved the problem:

Dir[“/Users/alexander/bin/jruby/lib/fop/*.jar”].each { |jar| require
jar }

With best regards

Alexander

Am 31.05.2008 um 00:04 schrieb Vladimir S.:

–Vladimir


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email