Issue Details (XML | Word | Printable)

Key: MPPDF-62
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Lukas Theussl
Reporter: Andy Jefferson
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Maven 1.x PDF Plugin

OutOfMemoryError using Maven 1.1 and v2.5.1 but works with Maven1.0 and v2.2.1

Created: 21/Jun/08 05:14 AM   Updated: 24/Jun/08 09:27 AM   Resolved: 24/Jun/08 09:12 AM
Component/s: None
Affects Version/s: 2.5.1
Fix Version/s: 2.5.2

Time Tracking:
Not Specified


 Description  « Hide

The following project
svn co https://datanucleus.svn.sourceforge.net/svnroot/datanucleus/documentation/accessplatform.datanucleus.org/trunk datanucleus
when running "maven clean pdf" runs fine when using Maven1.0 and plugin 2.2.1. Just tried with Maven1.1 and plugin 2.5.1 and it gives
[java] [INFO] [297]
[java] [INFO] [298]
[java] [INFO] [299]
[java] [INFO] [300]
[java] [INFO] [301]
[java] [INFO] [302]
[java] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
[java] at java.lang.String.<init>(String.java:208)
[java] at java.lang.StringBuilder.toString(StringBuilder.java:431)
[java] at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
[java] at java.lang.Integer.parseInt(Integer.java:447)
[java] at java.lang.Integer.parseInt(Integer.java:497)
[java] at org.apache.fop.layout.FontInfo.createFontKey(FontInfo.java:130)
[java] at org.apache.fop.layout.FontState.<init>(FontState.java:112)
[java] at org.apache.fop.fo.PropertyManager.getFontState(PropertyManager.java:117)
[java] at org.apache.fop.fo.flow.TableCell.layout(TableCell.java:292)
[java] at org.apache.fop.fo.flow.TableRow.layout(TableRow.java:360)
[java] at org.apache.fop.fo.flow.AbstractTableBody.layout(AbstractTableBody.java:236)
[java] at org.apache.fop.fo.flow.Table.layout(Table.java:302)
[java] at org.apache.fop.fo.flow.Block.layout(Block.java:257)
[java] at org.apache.fop.fo.flow.Block.layout(Block.java:257)
[java] at org.apache.fop.fo.flow.Block.layout(Block.java:257)
[java] at org.apache.fop.fo.flow.Block.layout(Block.java:257)
[java] at org.apache.fop.fo.flow.AbstractFlow.layout(AbstractFlow.java:154)
[java] at org.apache.fop.fo.flow.AbstractFlow.layout(AbstractFlow.java:110)
[java] at org.apache.fop.fo.pagination.PageSequence.makePage(PageSequence.java:400)
[java] at org.apache.fop.fo.pagination.PageSequence.format(PageSequence.java:338)
[java] at org.apache.fop.apps.StreamRenderer.render(StreamRenderer.java:262)
[java] at org.apache.fop.fo.FOTreeBuilder.endElement(FOTreeBuilder.java:223)
[java] at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
[java] at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
[java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
[java] at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
[java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[java] at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
[java] at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
[java] at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
[java] at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
[java] at org.apache.fop.apps.Driver.render(Driver.java:498)

It was running through quite quick til it got to 250 or so then slower and slower.

Obviously will be different on each machine, but I have
setenv MAVEN_OPTS "-Xmx512m -Xms512m"
but have tried also with 1024 for both

Anything I can set to get around this ?



Andy Jefferson added a comment - 21/Jun/08 09:54 AM

OOME also occurs using Maven 1.0 and 2.5.1 plugin, concluding that the issue is likely the plugin (and its dependencies) and not the version of Maven. I'm using JDK1.5_12 on Linux btw


Andy Jefferson added a comment - 22/Jun/08 05:59 AM

Taking the "plugin-resources" files from 2.5.1 and putting them into the plugin for 2.2.1 results in a working plugin that seems to have all of the fixes that have gone in since 2.2.1 (contents page not coping with > 10 sections, not including images in same directory, etc) yet doesn't give OOME.

Of the other diffs in these plugin versions that I can see
2.2.1 : Fop (0.20.5), Batik=1.5.0, xerces=2.4, xalan=2.4.1
2.5.1 : Fop=0.20.5, Batik=1.5.0-fop-0.20.5, xerces=2.8, xalan=2.7

Any ideas?

At least now I can build a custom version of this plugin and have something working, but would be nice to have this done officially and someone in the know can understand why the official latest release gives OutOfMemoryError on significant size PDF generation.


Lukas Theussl added a comment - 24/Jun/08 04:15 AM

Hi Andy,

I can reproduce your problem. However, I get the same OOME when running fop from the command line on the generated fo file, which means that the plugin is not at fault. What I actually don't understand is why it works with plugin 2.2.1.

I verified that in your case it's the table of contents that is responsible for the OOME. This is a well-known issue with forward references [1], I removed the toc creation from the xsl transformation and your pdf was created fine. So the question is if you want/need the toc, we can easily add an option to skip the toc generation (and rely on pdf bookmarks) or maybe move the toc to the end of the file, which would avoid the forward references (still need to check if this actually works).

[1] http://xmlgraphics.apache.org/fop/0.94/running.html#memory


Andy Jefferson added a comment - 24/Jun/08 04:34 AM

Hi Lukas,
thx for investigating it.

I have no particular requirement for the TOC. The PDF bookmarks are more important anyway IMHO. But if you could add an option for TOC with options like "start", "end", "none" then you're catering for all tastes.

In terms of when you run fop from the command line, aren't you also using Xerces/Xalan/Batik in that process? No idea what has changed in Xerces/Xalan between 2.4 and 2.7/8 so can't help on why that should matter.


Lukas Theussl added a comment - 24/Jun/08 06:44 AM

I deployed a snapshot, please test. The property is called maven.pdf.generateTOC and can take values 'start' (default), 'end' or 'none'.

maven plugin:download -Dmaven.repo.remote=http://people.apache.org/repo/m1-snapshot-repository/,http://repo1.maven.org/maven -DgroupId=maven -DartifactId=maven-pdf-plugin -Dversion=2.5.2-SNAPSHOT


Andy Jefferson added a comment - 24/Jun/08 08:38 AM

Thx. Tried the 2.5.2-SNAPSHOT with "end" and "none" and there's no OutOfMemoryError now!.
However I no longer get the projectLogo/companyLogo displayed. No idea if that is related to what you changed, but with my previous 2.2.1 + "plugin-resources" from 2.5.1 it had no problem displaying the companyLogo.


Lukas Theussl added a comment - 24/Jun/08 09:01 AM

The logo locations need to be relative paths (with leading slash due to MPPDF-31):

maven.pdf.companyLogo=/images/logos/DataNucleus_AccessPlatform_80.jpg


Andy Jefferson added a comment - 24/Jun/08 09:12 AM

Thx. Problem resolved with TOC at end


Lukas Theussl added a comment - 24/Jun/08 09:27 AM

Ok, I'll close this then. I still don't know exactly why this worked with plugin 2.2.1 but most likely because internal links didn't work then (MPPDF-24) which removes a lot of forward references.