cliffrubinmusic has asked for the wisdom of the Perl Monks concerning the following question:

Ok; here's what I have so far:

the code in the java, when run from the command line makes the pdf file, with the data in it. That code looks like this:

import java.datasource.dom4j.Dom4jDataSource; import java.xmlreport.ProcessPdf; import java.xmlreport.ProcessReport; import java.io.*; /** * Generate a PDF report using an XML file as the datasource. For this + use case this is the entire set of code needed * to use Windward Reports. For different output formats and/or differ +ent datasources, the code will change. */ public class GeneratePdfReport { /** * Generate a PDF report using an XML file as the datasource. * @param template The report template. * @param report The generated report. * @param xmlData The XML data file. */ public static void generatePdfReport(String template_filename, String + report_filename, String xmlData_filename) throws Exception { InputStream template = new FileInputStream(template_filename); OutputStream report = new FileOutputStream(report_filename) +; InputStream xmlData = new FileInputStream(xmlData_filename); // generally called once when your app starts, not in here. ProcessReport.init(); // create the report. ProcessPdf proc = new ProcessPdf(template, report); proc.processSetup(); proc.processData(new Dom4jDataSource(xmlData), ""); proc.processComplete(); } public static void main(String []args) throws Exception{ String template_filename = "/path/PurchaseOrderTemplate.rtf"; String report_filename = "/path/order.pdf"; String xmlData_filename= "/path/order.xml"; GeneratePdfReport myTest = new GeneratePdfReport(); myTest.generatePdfReport( template_filename, report_filename, xmlData_filename ); } }

this works like a charm BUT, when I put this code inside inline::java, get ride of the main, it runs, but the pdf file is empty. Here's the code:

#!/usr/bin/perl -w use strict; use CGI::Carp qw(fatalsToBrowser); BEGIN { $ENV{CLASSPATH}='.:/path/java.jar'; } use Inline Java => <<'END', CLASSPATH => $ENV{CLASSPATH}; import java.datasource.dom4j.Dom4jDataSource; import java.xmlreport.ProcessPdf; import java.xmlreport.ProcessReport; import java.io.*; /** * Generate a PDF report using an XML file as the datasource. For this + use case this is the entire set of code needed * to use Windward Reports. For different output formats and/or differ +ent datasources, the code will change. */ public class GeneratePdfReport { /** * Generate a PDF report using an XML file as the datasource. * @param template The report template. * @param report The generated report. * @param xmlData The XML data file. */ public static void generatePdfReport(String template_filename, String + report_filename, String xmlData_filename) throws Exception { InputStream template = new FileInputStream(template_filename); OutputStream report = new FileOutputStream(report_filename) +; InputStream xmlData = new FileInputStream(xmlData_filename); // generally called once when your app starts, not in here. ProcessReport.init(); // create the report. ProcessPdf proc = new ProcessPdf(template, report); proc.processSetup(); proc.processData(new Dom4jDataSource(xmlData), ""); proc.processComplete(); } } END text("does this work still 2?"); my $template_file = '/path/PurchaseOrderTemplate.rtf'; my $report_file = '/path/order.pdf'; my $xml_file = '/path/order.xml'; my $generator = GeneratePdfReport->new; $generator->generatePdfReport( "$template_file", "$report_file", "$xml_file" ); print "yes it did\n"; ###################################################################### +######### sub text { print "Content-type: text/html\n\n"; print "<table width='340' border='0' cellspacing='0' cellpadding='0'>< +tr><td>"; print "<p><strong>@_</strong></p>"; print "</td></tr></table>"; } ###################################################################### +########

also, the print command at the end of the code won't print. Any suggestions?

Replies are listed 'Best First'.
Re: inline::java problem
by MidLifeXis (Monsignor) on Jul 16, 2012 at 19:00 UTC
      it's a continuation, because I didn't know how to keep the original as a question
        I've put every file I know of in the classpath and am still receiving that error. Is there any way to find out which file it's looking for??
Re: inline::java problem
by tobyink (Canon) on Jul 16, 2012 at 19:04 UTC

    You're running this as a CGI script through a browser? Try running the CGI script from the command line and see if that makes a difference. It's likely to be a permissions problem. (The web server is probably running under a different user ID.)

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      I opened up the permissions on the folders completely, just for testing purposes, so, it couldn't be permissions. Unless I'm not thinking about this correctly?
        Here's the error I get when running the script from the command line:

        main::java::lang:: NoClassDefFoundErr or=HASH(0x2242180)

        not sure what it means. I don't get this error when I run the java from the command line. any suggestions?