Hello,

I am using FOP 0.20.5rc to produce TIFF files from XML in an EJB
environment. I experience  strange multithreading issues when I run the
thing in the (production-near) test-environement on a 4-proc box - the font
sizes get messed up completly on the 4 proc machine but only if I render
more than 1 TIFF in parallel.
If I run only one rendering at a time, it is fine.
If I run the same thing multithreaded on my dev box, it runs fine (though
there is only one proc of course)

It is entierly possible that the TIFFRenderer (from Oleg, based on
AWTRenderer and JAI), or the pja toolkit (http://www.eteks.com/pja/en/)  is
the problem.

I attached an example of a messed up TIFF, and attached to code I use to
call FOP in my EJB.

I tried to isolate the problem, though did not have any success so far, any
help is very welcome.

thanks,
Reto


(See attached file: Unde0004.tif)

I have the following environment:

local dev box: (here I don't expierience the problem)

WinNT 4, 1 proc
Weblogic 7.0.1
FOP 0.20.5rc
TIFFRenderer 0.9 from Oleg
JDK 1.3.1


Test environment:

Solaris 5.8, 4-processor machine, no X-Server running
Weblogic 7.0.1
FOP 0.20.5rc
TIFFRenderer0.9
JDK1.3.1
PJA Toolkit V2.4



Code that calls FOP. (sorry for the German comments, my client forces us to
write them in German... :-(
I instanciate one of these TIFFRenderHelpers for every call.

public class TIFFRenderHelper {


    /**
     * Den Skalierungs-Faktor für das TIF. 200 gibt eine vernünftige
Grösse.
     */
    public static final int TIF_SCALE_FACTOR = 200;


    // FOP speichert Konfigurations-Einträge in statischen Variablen.
    // diese dürfen nur einmal initialisert werden (threading probleme
sonst!)
    // wir tun dies bewusst hier in einem static block, bevor FOP zum
ersten mal aufgerufen wird.
    static {
        Logger logger = new Logger() {
                  <snip>
        };
        MessageHandler.setScreenLogger(logger);

        InputStream stream = TIFFRenderHelper.class.getResourceAsStream
("fop_userconfig.xml");
        if (stream == null) {
            throw new CSSFatalErrorException("stream ist null");
        }
        InputSource source = new InputSource(stream);
        if (source == null) {
            throw new CSSFatalErrorException("source ist null");
        }
        ConfigurationReader reader = new ConfigurationReader(source);
        reader.setDumpError(true);
        try {
            reader.start();
        } catch (org.apache.fop.apps.FOPException error) {
            // Logging in FOP error log
            MessageHandler.errorln("Could not load user configuration file
"
                    + " - error: "
                    + error.getMessage());
            MessageHandler.errorln("using default values");
            reader.dumpError(error);

            // css exception handling.
            CSSFatalErrorException cssException = new
CSSFatalErrorException(error);
            cssException.setLogged(true);
            throw cssException;
        }

        try {
            stream.close();
        } catch (IOException e) {
            CSSLogging.error(e);
            throw new CSSFatalErrorException(e);
        }
    }


    /**
     * Konvertiert den xml_String der invoice in ein TIF (zurückgegeben als
byte[]).
     * Das TIF hat das Format: TIFFRendererParams.COMPRESSION_GROUP3_2D.
     * Wichtig: Darf nur aufgerufen an invoices, welche das Interface
Transformable implementieren.
     * Benutzt Apache FOP und den TIFFRenderer für FOP von Oleg Tachenko.
     * @param xslFileName Der Namen des XSL Files für die XSLT:FOP
Transformation. Muss
     * im Classpath sein.
     * @return den Beleg als TIF in einem byte[].
     */
    public byte[] convertToTif(final Transformable invoice, String
xslFileName) {
        Driver driver = new Driver();

        Logger logger = new Logger() {

            <snip>

        };
        driver.setLogger(logger);

        TIFFRenderer tiffRenderer = TIFFRendererFactory.newTIFFRenderer();
        tiffRenderer.setScaleFactor(TIF_SCALE_FACTOR);
        TIFFRendererParams params = new TIFFRendererParams();
        params.setCompression(TIFFRendererParams.COMPRESSION_GROUP3_2D);
        tiffRenderer.setRenderParams(params);
        driver.setRenderer(tiffRenderer);

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        driver.setOutputStream(outputStream);
        Transformer transformer = null;

        byte[] output = null;

        try {
            TransformerFactory transFactory =
TransformerFactory.newInstance();
            InputStream xslStream = getClass
().getResourceAsStream(xslFileName);
            if (xslStream == null) {
                CSSFatalErrorException fe = new CSSFatalErrorException
("xslt file kann nicht geladen                        werden: " +
xslFileName);
                CSSLogging.criticalError(fe);
                fe.setLogged(true);
                throw fe;
            }
            StreamSource source = new StreamSource(xslStream);
            transformer = transFactory.newTransformer(source);

            Collection trafoParams = invoice.getTransformParameters();
            if (trafoParams != null) {
                Iterator i = invoice.getTransformParameters().iterator();
                while (i.hasNext()) {
                    String[] param = (String[]) i.next();
                    transformer.setParameter(param[0], param[1]);
                }
            }

            Source xmlsource = new StreamSource(new
StringReader(invoice.getXmlString()));
            transformer.transform(xmlsource, new
SAXResult(driver.getContentHandler()));
            output = outputStream.toByteArray();
            outputStream.close();
            xslStream.close();
        } catch (TransformerFactoryConfigurationError
transformerFactoryConfigurationError) {
            CSSLogging.error(e);
            throw new CSSFatalErrorException(e);
        } catch (TransformerConfigurationException e) {
            CSSLogging.error(e);
            throw new CSSFatalErrorException(e);
        } catch (TransformerException e) {
            CSSLogging.error(e);
            throw new CSSFatalErrorException(e);
        } catch (IOException e) {
            CSSLogging.error(e);
            throw new CSSFatalErrorException(e);
        }

        return output;
    }


___________________________________________________________________

CSS Versicherung
Reto Blunschi EXTERNE
Rösslimattstrasse 40
CH-6002 Luzern
Telefon  ++41 (0)41 369 1236
Telefax  ++41 (0)41 369 1212
[EMAIL PROTECTED]
www.css.ch

<<attachment: Unde0004.tif>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to