Hi Al, A ClassNotFoundException almost always means that the class cannot be found *on the classpath*. I'd say double-check that. I'm really not familiar with your PHP-Java bridge, but is there any way for you to make sure that it's being included at runtime?
Sam On Fri, Apr 17, 2009 at 4:20 AM, Al Dancer <[email protected]> wrote: > Hello, > > I've tried the following PHP script: > > www:root>vi ExampleFO2PDF.php > ------------ > <?php > require_once('java/Java.inc'); > > $basedir = new Java("java.io.File", "."); > $outdir = new Java("java.io.File", "out"); > $outdir->mkdirs(); > > $fofile = new Java("java.io.File", $basedir, "helloworld.fo"); > $pdffile = new Java("java.io.File", $outdir, "ResultFO2PDF.pdf"); > > echo "Input: ".$fofile->toString()."\n"; > echo "Output: ".$pdffile->toString()."\n"; > > $myObject = new Java("embedding.ExampleFO2PDF"); > $myObject->convertFO2PDF($fofile, $pdffile); > ?> > --------- > When I run : java embedding.ExampleFO2PDF > it's OK: > > FOP ExampleFO2PDF > > Preparing... > Input: XSL-FO (./xml/fo/helloworld.fo) > Output: PDF (./out/ResultFO2PDF.pdf) > Transforming... > > PageSequence <no id> generated 1 pages. > PageSequence <no id> generated 1 pages. > Generated 2 pages in total. > Success! > > But when I send a request: > http://myhost.com/embedding/ExampleFO2PDF.php > > I've got error in PHP error log: phperror.log > --------- > [17-Apr-2009 10:10:11] PHP Fatal error: Uncaught > [[o:Exception]:"java.lang.Exception: CreateInstance failed: new > embedding.ExampleFO2PDF. Cause: java.lang.ClassNotFoundException: > embedding.ExampleFO2PDF VM: 1.6.0...@http://java.sun.com/" at: > ---------- > > The class embedding.ExampleFO2PDF does exist, and is in the right place (in > the directory $CLASSPATH). > > Could someone give a hint about how to make this script working, please? > > Al > > > > > > --- On Thu, 4/16/09, Sam Fuqua <[email protected]> wrote: > > From: Sam Fuqua <[email protected]> > Subject: Re: create PDF file using ExampleFO2PDF.java > To: [email protected] > Date: Thursday, April 16, 2009, 7:04 AM > > I use Tomcat for a very similar function. Unfortunately, the exact > servlet given as an example is not what will work. The best way to do > it is to modify the example so that the transform is in a separate > method which returns a byte[]. This byte array can the be used to > write a file to your server as well as to return it to the browser. I > find that this is a much simpler and cleaner way of doing it. Are you > a confident Java programmer? > > On Thu, Apr 16, 2009 at 9:49 AM, Al Dancer <[email protected]> wrote: >> Hello, >> >> AFAIK, the servlet on my Tomcat server doesn't create the PDF file on my >> server, >> it just shows the PDF in the browser. >> >> after sending a request : >> http://myhost.com:8080/fop/fop?fo=/opt/coolstack/fop/foo.fo >> I see the PDF file, but there's no filename foo.pdf created on myhost.com >> All I want is to see the PDF file in the client's browser and to have the >> PDF file created on the server's side. >> >> regards, >> >> Al >> >> --- On Thu, 4/16/09, Sam Fuqua <[email protected]> wrote: >> >> From: Sam Fuqua <[email protected]> >> Subject: Re: create PDF file using ExampleFO2PDF.java >> To: [email protected] >> Date: Thursday, April 16, 2009, 6:32 AM >> >> Though I haven't used PHP for this, is there any reason why you can't >> simply use the example as a servlet on your Tomcat server? It would >> be very easy to pass the location of the fo to the servlet if that's >> what you're trying to do, rather than use php to make Java calls. >> Though you probably have your reasons. >> >> On Thu, Apr 16, 2009 at 9:16 AM, Al Dancer <[email protected]> wrote: >>> Hello all, >>> >>> I've installed FOP 0.95 on my Unix server. >>> I'd like to create a PDF file from FO file using the ExampleFO2PDF.java >>> from >>> >>> >>> http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/examples/embedding/java/embedding/ExampleFO2PDF.java?view=markup >>> >>> OS: Solaris 10 >>> Server Version: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.7d >>> Tomcat : Apache Tomact/6.0.16 >>> PHP: version 5.2.9 >>> PHP-Java-Bridge : version 5.4.3.3 >>> >>> I compiled the the ExampleFO2PDF.java => ExampleFO2PDF.class >>> and then I created a jar file => ExampleFO2PDF.jar >>> >>> Since, I've installed PHP-Java-Bridge, I can create a PHP script to call >>> the >>> Java class. >>> Is there anyone who already tried to create a PDF file from FO file using >>> PHP ? >>> >>> Any help would be appreciated. >>> >>> btw, I can create a PDF file using command line: >>> fop -fo foo.fo -pdf foo.pdf >>> I cann see the pdf file from URL: >>> http://myhost.com:8080/fop/fop?fo=/opt/coolstack/fop/foo.fo >>> >>> Al >>> >>> >> >> >> >> -- >> Sam Fuqua >> ΣΝ ΘΗ 454 >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] >> >> >> > > > > -- > Sam Fuqua > ΣΝ ΘΗ 454 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > -- Sam Fuqua ΣΝ ΘΗ 454
