Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^4: inline::java error

by cliffrubinmusic (Novice)
on Jul 14, 2012 at 18:50 UTC ( [id://981841]=note: print w/replies, xml ) Need Help??


in reply to Re^3: inline::java error
in thread inline::java error

Hi; Thank you so much..I feel like it's starting to make sense..BUT, this is the error I'm receiving now..

PdfReportGenerator.java:20: cannot find symbol symbol : class FileInputStream location: class PdfReportGenerator InputStream template = new FileInputStream(template_filename); ^ PdfReportGenerator.java:21: cannot find symbol symbol : class OuputStream location: class PdfReportGenerator OuputStream report = new FileOutputStream(report_filename); ^ PdfReportGenerator.java:21: cannot find symbol symbol : class FileOutputStream location: class PdfReportGenerator OuputStream report = new FileOutputStream(report_filename); ^ PdfReportGenerator.java:22: cannot find symbol symbol : class FileInputStream location: class PdfReportGenerator InputStream xmlData = new FileInputStream(xmlData_filename);

maybe the strings added to the streams need to happen sooner?

Replies are listed 'Best First'.
Re^5: inline::java error
by cliffrubinmusic (Novice) on Jul 14, 2012 at 19:25 UTC
    Hi again; I can't tell you how excited I am!!

    I changed the import to "import java.io.*;"

    and it made the pdf file!

    However, it's empty..But, geez, I feel so close. Any thoughts on why it's not picking up the other 2 variables? If that is the problem..

      I imagine the other two filenames are getting across just fine. You could add a few debugging statements to your Java to make sure (System.err.println(report_filename)).

      The problem is more likely to be at the Java end. Things to check:

      • Your xmlData input path refers to a file that actually exists.
      • Your xmlData input path refers to a file that is readable.
      • That these classes actually work as you'd expect in Java, independently of Perl:
        • java.datasource.dom4j.Dom4jDataSource
        • java.xmlreport.ProcessPdf
        • java.xmlreport.ProcessReport
      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Just a blind suggestion from a passer-by: You should first make a stand-alone Java program that does what you want. Take the code you have in class PdfRecordGenerator, add a bare-bones public static void main(String[] argv) method that calls the real method (like you would in Perl). Muck around with it until you get it working. After that, remove the main method and try again through Perl.

      Besides, there's always System.out.println() to debug and check that everything from Perl gets passed correctly.

        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/'; } 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";

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://981841]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-25 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found