Hi,

I have installed Apache 2.2.2, PHP 5.1.4, j2ee (java version 1.5.0_03, javac version 1.5.0_06), JavaBridge 3.1.8rc3 and Apache FOP 0.92beta in Window XP SP2.

I can use FOP from command line in server, e.g. c:\fop test.fo test.pdf
I can also use java and javac from command line. Also PHP works with Java normally from browser, e.g.
<?php
java_require('http://Myserver/HelloWorld.jar');
$myObj = new Java('HelloWorld');
echo (String) $myObj->getHelloWorld();
?>
displays correctly "Hello World" into the browser window. Here Helloworld.jar was created from HelloWorld.class
public class HelloWorld {String hw = "Hello World";public String getHelloWorld(){return hw;}}

But the following PHP code
<?php
$pdf = "test.pdf";
$fo = "test.fo";
$options = array($fo,$pdf);
$java = new Java("org.apache.fop.apps.CommandLine", $options);
$java->run();
?>
doesn’t work.
It generates an error message.
Fatal error: Uncaught [o(Exception):"java.lang.Exception: CreateInstance failed: new org.apache.fop.apps.CommandLine(o(Request$PhpArray)). Cause: java.lang.ClassNotFoundException: Could not find org.apache.fop.apps.CommandLine in java_require() path. Please check the path and the SEL and File permissions. Responsible VM: [email]1.5.0_06@http://java.sun.com[/email]/" at: #-7 php.java.bridge.DynamicJavaBridgeClassLoader.loadClass(DynamicJavaBridgeClassLoader.java:449) #-6 php.java.bridge.SimpleJavaBridgeClassLoader.forName(SimpleJavaBridgeClassLoader.java:184) #-5 php.java.bridge.JavaBridge.CreateObject(JavaBridge.java:522) #0 C:\wwwroot\test.php(5): Java::__construct('org.apache.fop....', Array) #1 {main}] thrown in C:\wwwroot\test.php on line 5

Why can I not call Apache FOP from PHP to create a pdf file?

In server the environmental variables are as follows:
JAVA_HOME=C:\Program Files\Java2EE\jdk and
Path variable includes C:\Program Files\Java2EE\jdk\bin;
C:\Program Files\Java2EE\jdk\lib;
C:\Program Files\Fop;
C:\Program Files\Fop\lib;
C:\Program Files\Fop\build\fop.jar;
C:\Program Files\Fop\lib\xml-apis-1.3.02.jar;
C:\Program Files\Fop\lib\xercesImpl-2.7.1.jar;
C:\Program Files\Fop\lib\xalan-2.7.0.jar;
C:\Program Files\Fop\lib\serializer-2.7.0.jar;
C:\Program Files\Fop\lib\batik-all-1.6.jar;
C:\Program Files\Fop\lib\xmlgraphics-commons-1.0.jar;
C:\Program Files\Fop\lib\avalon-framework-4.2.0.jar;
C:\Program Files\Fop\lib\commons-io-1.1.jar;
C:\Program Files\Fop\lib\commons-logging-1.0.4.jar
I have not set the CLASSPATH variable in Windows.

I have also Java settings for JavaBridge in php.ini
extension=php_java.dll
java.java = "C:\Program Files\Java2EE\jdk\bin\javaw.exe"
java.java_home = "C:\Program Files\Java2EE\jdk"
java.log_level = 3
java.libpath = "C:\php5\ext"
java.class.path = "C:\php5\ext\JavaBridge.jar"

keke

    10 days later

    If you unzip the fop.jar, you will find the "namespace" by directories... if you check the directories, you will see that in the "apps" namespace... there is no "CommandLine" class...

    It will never work... whatever your configuration...

      Write a Reply...