Report runs in linux terminal but no with PHP exec command

0

Hi there, 

I'm having problems executing the next command in a PHP file:

$cmd = '-Djava.awt.headless=true -Dlog4j.configuration=file:/opt/lampp/htdocs/crm2/modules/zr2_Report/jasper/log4j.properties -classpath "custom/ZuckerReports2/resources/:custom/ZuckerReports2/resources/areas_negocio.jasper_files/:modules/zr2_Report/jasper/jasperreports-javaflow-5.1.2.jar:modules/zr2_Report/jasper/zuckerreports-1.0.jar:modules/zr2_Report/jasper/commons-beanutils-1.8.0.jar:modules/zr2_Report/jasper/batik-anim.jar:modules/zr2_Report/jasper/bcel-5.2.jar:modules/zr2_Report/jasper/barcode4j-2.0.jar:modules/zr2_Report/jasper/ant-1.7.1.jar:modules/zr2_Report/jasper/jasperreports-applet-5.1.2.jar:modules/zr2_Report/jasper/batik-css.jar:modules/zr2_Report/jasper/servlet.jar:modules/zr2_Report/jasper/commons-digester-1.7.jar:modules/zr2_Report/jasper/batik-awt-util.jar:modules/zr2_Report/jasper/jasperreports-5.1.2.jar:modules/zr2_Report/jasper/antlr-2.7.5.jar:modules/zr2_Report/jasper/xml-apis-ext.jar:modules/zr2_Report/jasper/poi-3.6.jar:modules/zr2_Report/jasper/iText-2.1.7.jar:modules/zr2_Report/jasper/jxl-2.6.10.jar:modules/zr2_Report/jasper/commons-logging-1.0.4.jar:modules/zr2_Report/jasper/batik-gvt.jar:modules/zr2_Report/jasper/spring-beans-2.5.5.jar:modules/zr2_Report/jasper/mysql-connector-java-3.1.11-bin.jar:modules/zr2_Report/jasper/batik-parser.jar:modules/zr2_Report/jasper/batik-util.jar:modules/zr2_Report/jasper/hibernate3.jar:modules/zr2_Report/jasper/groovy-all-1.7.5.jar:modules/zr2_Report/jasper/barbecue-1.5-beta1.jar:modules/zr2_Report/jasper/jcommon-1.0.15.jar:modules/zr2_Report/jasper/jasperreports-functions-5.1.2.jar:modules/zr2_Report/jasper/log4j-1.2.15.jar:modules/zr2_Report/jasper/saaj-api-1.3.jar:modules/zr2_Report/jasper/jpa.jar:modules/zr2_Report/jasper/jfreechart-1.0.12.jar:modules/zr2_Report/jasper/spring-core-2.5.5.jar:modules/zr2_Report/jasper/mondrian-3.1.1.12687.jar:modules/zr2_Report/jasper/hsqldb-1.8.0-10.jar:modules/zr2_Report/jasper/batik-script.jar:modules/zr2_Report/jasper/serializer.jar:modules/zr2_Report/jasper/commons-collections-2.1.1.jar:modules/zr2_Report/jasper/batik-svggen.jar:modules/zr2_Report/jasper/batik-dom.jar:modules/zr2_Report/jasper/rhino-1.7R1.jar:modules/zr2_Report/jasper/batik-ext.jar:modules/zr2_Report/jasper/joda-time-1.2.1.jar:modules/zr2_Report/jasper/xml-apis.jar:modules/zr2_Report/jasper/batik-bridge.jar:modules/zr2_Report/jasper/xercesImpl-2.7.0.jar:modules/zr2_Report/jasper/TestZucker.jar:modules/zr2_Report/jasper/batik-svg-dom.jar:modules/zr2_Report/jasper/jasperreports-fonts-5.1.2.jar:modules/zr2_Report/jasper/jdt-compiler-3.1.1.jar:modules/zr2_Report/jasper/xalan-2.7.1.jar:modules/zr2_Report/jasper/png-encoder-1.5.jar:modules/zr2_Report/jasper/bsh-2.0b4.jar:modules/zr2_Report/jasper/batik-xml.jar:modules/zr2_Report/jasper/jaxen-1.1.1.jar:modules/zr2_Report/jasper/commons-javaflow-20060411.jar" at.go_mobile.zuckerreports.JasperBatchMain custom/ZuckerReports2/temp/4f558394-298d-4783-4600-51e812a588ef/cmd.properties 2>&1'; exec($cmd,$out,$res);

The result of this execution is this error:

Exception in thread "main" java.lang.ExceptionInInitializerError
	at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:121)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:88)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:103)
	at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:61)
	at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:153)
	at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:55)
	at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:170)
	at at.go_mobile.zuckerreports.JasperBatchMain.main(JasperBatchMain.java:126)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: java.io.IOException: Problem reading font data.
	at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:108)
	at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:128)
	at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(SimpleFontFace.java:67)
	at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:99)
	at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:261)
	at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:232)
	at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:193)
	at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:162)
	at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56)
	at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
	at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83)
	... 8 more
Caused by: java.io.IOException: Problem reading font data.
	at java.awt.Font.createFont0(Font.java:999)
	at java.awt.Font.createFont(Font.java:876)
	at net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:100)
	... 18 more</init></clinit></init></init></init></init></init></init>

But when i run the command directly in a linux terminal the report is generated right.

This are the last lines from the log4j log file:

11:05:39,779 DEBUG DefaultExtensionsRegistry,main:158 - Loading JasperReports extension properties resource jar:file:/opt/lampp/htdocs/crm2/modules/zr2_Report/jasper/jasperreports-functions-5.1.2.jar!/jasperreports_extension.properties
11:05:39,779 DEBUG DefaultExtensionsRegistry,main:208 - Instantiating registry of type net.sf.jasperreports.functions.FunctionsRegistryFactory for property net.sf.jasperreports.extension.registry.factory.functions
11:05:39,779 DEBUG DefaultExtensionsRegistry,main:233 - Instantiating extensions registry for functions using factory class net.sf.jasperreports.functions.FunctionsRegistryFactory
11:05:39,786 DEBUG DefaultExtensionsRegistry,main:158 - Loading JasperReports extension properties resource jar:file:/opt/lampp/htdocs/crm2/modules/zr2_Report/jasper/jasperreports-fonts-5.1.2.jar!/jasperreports_extension.properties
11:05:39,787 DEBUG DefaultExtensionsRegistry,main:208 - Instantiating registry of type net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory for property net.sf.jasperreports.extension.registry.factory.simple.font.families
11:05:39,787 DEBUG DefaultExtensionsRegistry,main:233 - Instantiating extensions registry for simple.font.families using factory class net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
I guess it could be a linux permission problem, but so far I couldn't detect what kind of issue it is.
Any help will be appreciated. Thanks in advance.
Greetings.
jasv.riot's picture
Joined: Jun 17 2013 - 7:44pm
Last seen: 6 years 4 months ago

1 Answer:

0

Well, finally I found the error, after searching a lot I came to find this post (http://blog.codyjung.com/2011/05/29/problems-with-lampp-and-exec/)

It turns out that lampp uses his own libraries, so I got to override /opt/lampp/lib/libgcc_s.so.1 library with the server one (/lib/libgcc_s.so.1), restart apache, and it works right away.

jasv.riot's picture
Joined: Jun 17 2013 - 7:44pm
Last seen: 6 years 4 months ago
Feedback
randomness