Bug 49681 - Upgrade Exceptions from fop 0.95 to 1.o
Upgrade Exceptions from fop 0.95 to 1.o
Status: CLOSED FIXED
Product: Fop - Now in Jira
Classification: Unclassified
Component: images
1.0
PC Windows Vista
: P2 critical
: ---
Assigned To: fop-dev
:
: 49727 (view as bug list)
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-07-31 09:36 UTC by Murthy
Modified: 2012-04-01 06:18 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Murthy 2010-07-31 09:36:07 UTC
i tried to upgrade from 0.95 to 1.0 version, and getting the exception attached when generating the TIFF image.

These are my changes

0.95 jars                     1.0 upgrade changes
========================      =============================
fop0.95.jar                   - fop1.0.jar
xercesImpl-2.6.2.jar          - xercesImpl-2.7.1.jar
xmlgraphics-commons-1.3.1.jar - xmlgraphics-commons-1.4.jar

other Jars using 
=================
xalan-2.7.0.jar
batik-all-1.7.jar
avalon-framework-4.2.0.jar
barcode4j-fop-ext-complete.jar


please help me out in this problem

Thanks
Murthy
Comment 1 Pascal Sancho 2010-08-02 03:08:05 UTC
no exception log is attached, please give further information.
Comment 2 Murthy 2010-08-02 04:44:51 UTC
I'm sorry that the attachment is not uploaded, sorry for the inconvenience caused.

Below is the exception
======================
java.lang.Error: TIFFImageEncoder4
	at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.encode(TIFFImageEncoder.java:245)
	at org.apache.xmlgraphics.image.codec.tiff.TIFFImageEncoder.finishMultiple(TIFFImageEncoder.java:186)
	at org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter$TIFFMultiImageWriter.close(TIFFImageWriter.java:206)
	at org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler.endDocument(AbstractBitmapDocumentHandler.java:174)
	at org.apache.fop.render.intermediate.IFRenderer.stopRenderer(IFRenderer.java:285)
	at org.apache.fop.area.RenderPagesModel.endDocument(RenderPagesModel.java:256)
	at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java:309)
	at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:164)
	at net.sf.saxon.event.ContentHandlerProxy.close(ContentHandlerProxy.java:274)
	at net.sf.saxon.event.ProxyReceiver.close(ProxyReceiver.java:90)
	at net.sf.saxon.event.ReceivingContentHandler.endDocument(ReceivingContentHandler.java:218)
	at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
	at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at net.sf.saxon.event.Sender.sendSAXSource(Sender.java:371)
	at net.sf.saxon.event.Sender.send(Sender.java:185)
	at net.sf.saxon.IdentityTransformer.transform(IdentityTransformer.java:29)


Note: "xml-apis-ext-1.3.04.jar" it is also part of core Jars

Thanks
MVVR Murthy
Comment 3 Jeremias Maerki 2010-09-02 02:59:19 UTC
*** Bug 49727 has been marked as a duplicate of this bug. ***
Comment 4 Jeremias Maerki 2010-09-02 03:10:21 UTC
The actual exception:

        case DataBuffer.TYPE_INT:
        case DataBuffer.TYPE_FLOAT:
            if(sampleSize[0] != 32) {
                throw new Error("TIFFImageEncoder4");
            }

Ugly as hell but this has been so since TIFFImageEncoder has been introduced into Batik. Anyway, the error probably happens because INT is used as sample carrier but I assume the sample size is only 24 bits.

One change that happened from 0.95 to 1.0 was the introduction of the new intermediate format so that TIFF output is now handled by TIFFDocumentHandler instead of TIFFRenderer by default, but both classes use the same ImageWriter API from XML Graphics Commons. The default color type (RGBA) has remained the same. So I'm not sure where this comes from. I'll have to try to reproduce.

A possibility in the meantime is to try different color format settings:
http://xmlgraphics.apache.org/fop/1.0/output.html#bitmap-configuration
Comment 5 Jeremias Maerki 2010-09-02 03:21:27 UTC
Ok, on my side, the ImageIO implementation for ImageWriter is used which doesn't show this problem. If I disable the ImageIO implementation the internal codec becomes active and fails on the default configuration settings with said exception. Now, the question is why the ImageIO implementation isn't used. Maybe it has to do with Bug 49696 but I don't really think so. So my next question:

What JVM are running this on so you get this result? That might help me figure out why the internal codecs are selected over the ImageIO implementations.

In this light, another work-around presents itself:
In xmlgraphics-commons.jar you can edit
META-INF/services/org.apache.xmlgraphics.image.writer.ImageWriter
and remove the following entries:
org.apache.xmlgraphics.image.writer.internal.PNGImageWriter
org.apache.xmlgraphics.image.writer.internal.TIFFImageWriter
org.apache.xmlgraphics.image.writer.internal.JPEGImageWriter
Comment 6 Jeremias Maerki 2010-09-02 03:36:12 UTC
Should have thought about it earlier. We're talking about TIFF export, so another work-around: Install JAI ImageIO Tools to give ImageIO a TIFF codec which it hasn't by default.

http://jai-imageio.dev.java.net/

So, I guess that's an important clue. Could it be that you had JAI ImageIO Tools installed but didn't add that when upgrading to FOP 1.0? Otherwise, I still can't explain that the error should have appeared when switching to FOP 1.0.
Comment 7 Murthy 2010-09-05 02:31:43 UTC
(In reply to comment #6)
> Should have thought about it earlier. We're talking about TIFF export, so
> another work-around: Install JAI ImageIO Tools to give ImageIO a TIFF codec
> which it hasn't by default.
> http://jai-imageio.dev.java.net/
> So, I guess that's an important clue. Could it be that you had JAI ImageIO
> Tools installed but didn't add that when upgrading to FOP 1.0? Otherwise, I
> still can't explain that the error should have appeared when switching to FOP
> 1.0.

Hi Maerki,
	Yes you are right, JAI ImageIO tools were missing from my classpath which results in error.
	After placing the JAI ImageIO tool, able to generate the TIFF successfully.
	
	Thanks for all your help.

Thanks
Murthy
Comment 8 Marc Lang 2011-10-14 16:21:31 UTC
I am getting this error using the below ANT task.

<?xml version="1.0" encoding="UTF-8"?>
<project name="FOPAnt" default="generate-pdf-from-transform" basedir=".">

	<property name="fop.home" value="D:\Dev\Java\libraries\fop-1.0-bin\fop-1.0"/>
	
	<taskdef name="fop" classname="org.apache.fop.tools.anttasks.Fop">
	  <classpath>
	    <fileset dir="${fop.home}/lib">
	      <include name="*.jar"/>
	    </fileset>
	    <fileset dir="${fop.home}/build">
	      <include name="*.jar"/>
	    </fileset>
	    
	  </classpath>
	</taskdef>	
	
	
<target name="generate-pdf-from-transform" description="Generates a single PDF file from an XSLT stylesheet">
     
   <fop format="image/tiff" force="true" userconfig="D:\Dev\Java\FopConverter\workspace\FopConverterService\fop.xconf"
        xmlfile="D:\Dev\Java\FopConverter\workspace\TestFiles\EDIS_SCIDischarge.xml"
        xsltfile="D:\Dev\Java\FopConverter\workspace\Stylesheets\EDIS.fo"
        outfile="D:\Dev\Java\FopConverter\workspace\FopConverterService\something.tif" />     
        
</target>
</project>



As you can see, the contents of D:\Dev\Java\libraries\fop-1.0-bin\fop-1.0\build are included in the CLASSPATH, which includes jai_imageio.jar
Comment 9 Glenn Adams 2012-04-01 06:18:40 UTC
batch transition to closed; if someone wishes to restore one of these to resolved in order to perform a verification step, then feel free to do so