wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes FOP : problem with inserting PNG (causes error) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "FOP : problem with inserting PNG (causes error)" Watch "FOP : problem with inserting PNG (causes error)" New topic
Author

FOP : problem with inserting PNG (causes error)

Remi Malessa
Greenhorn

Joined: Aug 27, 2007
Posts: 7
Hi.
I have a servlet that produces PDF documents. I use XSLT and FOP to produce the PDF.
It worked fine so far (for many months), but now it stopped working with some PNG images.
The images seems fine and I have no clue what is going on.

Here is a tomcat log showing the error:

java.lang.reflect.UndeclaredThrowableException
at $Proxy80.readUTF(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.xmlgraphics.image.loader.util.ImageUtil$1.invoke(ImageUtil.java:246)
at $Proxy80.readUTF(Unknown Source)
at com.sun.imageio.plugins.png.PNGImageReader.parse_iTXt_chunk(PNGImageReader.java:469)
at com.sun.imageio.plugins.png.PNGImageReader.readMetadata(PNGImageReader.java:709)
at com.sun.imageio.plugins.png.PNGImageReader.getImageMetadata(PNGImageReader.java:1542)
at org.apache.xmlgraphics.image.loader.impl.imageio.PreloaderImageIO.preloadImage(PreloaderImageIO.java:71)
at org.apache.xmlgraphics.image.loader.ImageManager.preloadImage(ImageManager.java:175)
at org.apache.xmlgraphics.image.loader.cache.ImageCache.needImageInfo(ImageCache.java:128)
at org.apache.xmlgraphics.image.loader.ImageManager.getImageInfo(ImageManager.java:122)
at org.apache.fop.fo.flow.ExternalGraphic.bind(ExternalGraphic.java:81)
at org.apache.fop.fo.FObj.processNode(FObj.java:123)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:282)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
at net.sf.saxon.event.ContentHandlerProxy.startContent(ContentHandlerProxy.java:362)
at net.sf.saxon.event.NamespaceReducer.startContent(NamespaceReducer.java:197)
at net.sf.saxon.event.ComplexContentOutputter.startContent(ComplexContentOutputter.java:553)
at net.sf.saxon.event.ComplexContentOutputter.endElement(ComplexContentOutputter.java:426)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:304)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:619)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:619)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:619)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
at net.sf.saxon.instruct.ForEach.processLeavingTail(ForEach.java:331)
at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:619)
at net.sf.saxon.instruct.Instruction.process(Instruction.java:93)
at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:301)
at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:632)
at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:229)
at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:346)
at net.sf.saxon.Controller.transformDocument(Controller.java:1851)
at net.sf.saxon.Controller.transform(Controller.java:1702)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:548)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:874)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.xmlgraphics.image.loader.impl.AbstractImageSessionContext$ObservingImageInputStreamInvocationHandler.invoke(AbstractImageSessionContext.java:219)
... 61 more
Caused by: java.io.UTFDataFormatException: malformed input around byte 917
at java.io.DataInputStream.readUTF(DataInputStream.java:634)
at javax.imageio.stream.ImageInputStreamImpl.readUTF(ImageInputStreamImpl.java:332)
... 66 more

I made some tests on oXygen editor and on version 10 it produces PDF , but images are not there. On version 12 of oXygen everything is fine.
The servlet produces corrupted PDF's

I looked at the oXygen modules and updated my jar files, but it still doesn't work
I am using Java 1.6.0_17
FOP 1.0

Will appreciate help.

Cheers
Remi
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18113
    
    8

It looks to me like the "Sun" code which reads in PNG files is throwing an exception when it's trying to read the metadata from one particular file. That's just based on reading the method names near the top of the stack trace. So you may think the PNG file is okay but apparently Sun's code disagrees with you.

So I would say this problem is all about the PNG file, not about FOP, or Saxon, or even Tomcat. Could you try to replicate this in a simpler environment?
Remi Malessa
Greenhorn

Joined: Aug 27, 2007
Posts: 7
I think its a good idea. I will make some tests off the server and come back... Thanks
Remi Malessa
Greenhorn

Joined: Aug 27, 2007
Posts: 7
The picture compiles when I run the FOP locally and FOP produces correct PDF.
My application embedding the FOP runs in a servlet container and gets the PNG image by asking another servlet which
passes the image as a stream.

I tried clearing out the jar's but just not making any progress.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FOP : problem with inserting PNG (causes error)
 
Similar Threads
java.net.SocketException: Connection reset
I set up JBoss mail, so why can't I access the mail bean?
FTP server
Class Not Found Exception
Problem starting service jboss:service=Naming