|
From: <php...@li...> - 2008-10-28 16:13:13
|
Hi, I'm new to php-java-bridge, but i'm very interested in it to use Jasper Report on php. I have a running dev/test debian etch server with apache2 and php5 and i would like to install php-java-bridge without tomcat or jdr. This is the snippet of doc from README.GNU_JAVA from which i take this idea. ### In case you don't want to ship a JVM or JRE with your product, you can use GNU gcc to compile the java part and your classes into native code. In the directory php-java-bridge_p.x.y type: gcj --version # must be gcj 3.3.3 or above (gcj 4.1 recommended). phpize && ./configure && make && su -c "make install" This creates a native, dynamic linked back-end in the PHP extension directory. ### Here is what i currently have done : ### apt-get install gcj php5-dev gcc autoconf libtool automake make wget http://downloads.sourceforge.net/php-java-bridge/php-java-bridge_5.3.2.1.2.orig.tar.gz?modtime=1223900873&big_mirror=0 tar xzvf php-java-bridge_5.3.2.1.2.orig.tar.gz cd php-java-bridge_5.3.2.1.2.orig phpize && ./configure && make && make install ### Everything is ok so far. But when i try to use java in my php script, it hangs : ### <?php $system = new Java('java.lang.System'); ?> ### *Fatal error*: Class 'Java' not found in */home/day/[...]/test.php* on line *4* ### I'm sure it's a simple thing due to me being a newbie, like how should I configure php.ini for this to work ? (I have done nothing between the make install part and the php part.) Would anyone have an idea ? I have searched in the archives but not found anything i could use. David Pradier |
|
From: <php...@li...> - 2008-10-28 20:51:51
|
Hi,
> *Fatal error*: Class 'Java' not found in
this PHP error message means that you don't have a Java class. Either write your own class or use the one provided by the PHP/Java Bridge. Please see our FAQ for details.
Regards,
Jost Boekemeier
|
|
From: <php...@li...> - 2008-10-30 16:12:14
|
php...@li... a écrit :
> Hi,
>
>> *Fatal error*: Class 'Java' not found in
>>
> this PHP error message means that you don't have a Java class. Either write your own class or use the one provided by the PHP/Java Bridge. Please see our FAQ for details.
> Regards,
> Jost Boekemeier
>
Hi Jost,
thanks for your help. Following your mail, i have reread a lot of the
forums and the docs.
And it's better :-) !
But not enough... Here I am now, this script :
###
<?php
require_once("java/Java.inc");
java_require("/usr/share/java/ext/");
$compileManager = new
JavaClass("net.sf.jasperreports.engine.JasperCompileManager");
print "<br/>Point 1<br/><br/>";
$report = $compileManager->compileReport("/tmp/jreport/test.jrxml");
print "<br/>Point 2<br/><br/>";
?>
###
gives this error :
###
Point 1
*Fatal error*: Uncaught [[o:Exception]:"java.lang.Exception: Invoke
failed: [[c:JasperCompileManager]]->compileReport((o:String)[o:String]).
Cause: java.lang.ClassNotFoundException: Unresolved external reference:
java.lang.NoClassDefFoundError:
net.sf.jasperreports.engine.xml.JRXmlLoader. -- Unable to call the
method, see the README section "Java platform issues" for details. VM:
1.4.2@http://gcc.gnu.org/java/" at: #-6
php.java.bridge.JavaBridge.getUnresolvedExternalReferenceException(JavaBridge.java:433)
#-5 php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1080) #-4
php.java.bridge.Request.handleRequest(Request.java:409) #0
/usr/share/php/java/Java.inc(300):
java_ThrowExceptionProxyFactory->getProxy(4, 'net.sf.jasperre...',
'Unresolved exte...', true) #1 /usr/share/php/java/Java.inc(454):
java_Arg->getResult(true) #2 /usr/share/php/java/Java.inc(460):
java_Client->getWrappedResult(true) #3
/usr/share/php/java/Java.inc(664): java_Client->getResult() #4
/usr/share/php/java/Java.inc(1779): java_Client->invokeMethod(3, 'compi
in */usr/share/php/java/Java.inc* on line *263*
###
I think the problem comes from my configuration of php-java-bridge, as
net.sf.jasperreports.engine.xml.JRXmlLoader is in the same .jar file
than net.sf.jasperreports.engine.JasperCompileManager. Excepted this
error, everything went smoothly and i haven't noted any other error.
Here is what i did since the beginning :
I am on a debian etch server.
I have installed the gcj php5-dev gcc autoconf libtool automake make
packages.
I have phpized php-java-bridge.
# wget
http://downloads.sourceforge.net/php-java-bridge/php-java-bridge_5.3.2.1.2.orig.tar.gz?modtime=1223900873&big_mirror=0
# tar xzvf php-java-bridge_5.3.2.1.2.orig.tar.gz
# cd php-java-bridge_5.3.2.1.2.orig
# phpize && ./configure && make
I have put Java.Inc in /usr/share/php/java/
I have put my jar files in /usr/share/java/ext/ (even JavaBridge.jar)
I have launched the servlet :
# cd /root/php-java-bridge/php-java-bridge-5.3.2.1.2.orig/modules/
# ./java SERVLET:8080 3 JavaBridge.log
JavaBridge.log says :
Oct 29 12:24:58 JavaBridge INFO : VM :
1.4.2@http://gcc.gnu.org/java/
Oct 29 12:24:58 JavaBridge INFO : logFile : JavaBridge.log
Oct 29 12:24:58 JavaBridge INFO : default logLevel : 3
Oct 29 12:24:58 JavaBridge INFO : socket : SERVLET:8080
Oct 29 12:24:58 JavaBridge INFO : java.ext.dirs : /usr/share/java/ext
Oct 29 12:24:58 JavaBridge INFO : php.java.bridge.base: /root
Oct 29 12:24:58 JavaBridge INFO : thread pool size : 20
Oct 29 12:24:58 JavaBridge INFO : JavaBridgeRunner started on port
INET_LOCAL:8080
Here I have a question : is "php.java.bridge.base: /root" correct or
problematic ?
Another information :
| echo java("java.lang.System")->getProperties();
|in apache gives me (i put it one information per line to make it more
readable) :
{
path.separator=:,
java.vm.name=GNU libgcj,
java.vm.specification.name=Java(tm) Virtual Machine Specification,
java.runtime.version=1.4.2,
java.home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre,
java.vm.specification.version=1.0,
line.separator= ,
java.vm.specification.vendor=Sun Microsystems Inc.,
gnu.classpath.home.url=file:///usr/lib/../lib64,
gnu.gcj.progname=./java,
gnu.classpath.version=0.92,
java.specification.version=1.4,
java.library.path=/usr/lib/../lib64/gcj-4.1:/usr/lib/jni,
gnu.classpath.vm.shortname=libgcj,
java.class.version=48.0,
java.specification.name=Java(tm) Platform API Specification,
os.version=2.6.18-6-amd64,
gnu.classpath.home=/usr,
user.home=/root,
file.encoding=UTF-8,
os.name=Linux,
php.java.bridge.promiscuous=true,
user.name=root,
java.class.path=.,
java.io.tmpdir=/tmp,
os.arch=x86_64,
java.fullversion=GNU libgcj 4.1.2 20061115 (prerelease) (Debian 4.1.1-20),
user.language=en,
java.specification.vendor=Sun Microsystems Inc.,
user.dir=/root/php-java-bridge/php-java-bridge-5.3.2.1.2.orig/modules,
java.vm.info=GNU libgcj 4.1.2 20061115 (prerelease) (Debian 4.1.1-20),
java.version=1.4.2,
java.ext.dirs=/usr/share/java/ext,
sun.boot.class.path=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre/lib/rt.jar,
gnu.gcj.user.realname=root,
java.vm.vendor=Free Software Foundation, Inc.,
java.vendor.url=http://gcc.gnu.org/java/,
java.vendor=Free Software Foundation, Inc.,
file.separator=/,
java.vm.version=4.1.2 20061115 (prerelease) (Debian 4.1.1-20),
http.agent=gnu-classpath/0.92 (libgcj/4.1.2 20061115 (prerelease)
(Debian 4.1.1-20)),
gnu.gcj.precompiled.db.path=/var/lib/../lib64/gcj-4.1/classmap.db,
gnu.cpu.endian=little, user.region=GB,
gnu.gcj.runtime.endorsed.dirs=/usr/share/java/gcj-endorsed
}
Particularly, do you think these lines are coherent ?
java.home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre
java.library.path=/usr/lib/../lib64/gcj-4.1:/usr/lib/jni
user.home=/root,
java.class.path=.,
user.dir=/root/php-java-bridge/php-java-bridge-5.3.2.1.2.orig/modules,
gnu.gcj.user.realname=root,
And finally, would you have any direction for me to look ?
David
|
|
From: <php...@li...> - 2008-10-30 16:52:06
|
Hi,
> Cause: java.lang.ClassNotFoundException: Unresolved external reference:
> java.lang.NoClassDefFoundError:
> net.sf.jasperreports.engine.xml.JRXmlLoader. -- Unable to call the
please re-read the FAQ entry "Why do I get a NoClassDefFoundError".
Sorry for beeing terse, but this all information I can pass along, as this is really a Java issue. -- Microsoft (.NET) has learned its lession from the windows "dll hell", Sun has not.
Regards,
Jost Boekemeier
|
|
From: <php...@li...> - 2008-10-30 17:31:01
|
php...@li... a écrit : > Hi, >> Cause: java.lang.ClassNotFoundException: Unresolved external reference: >> java.lang.NoClassDefFoundError: >> net.sf.jasperreports.engine.xml.JRXmlLoader. -- Unable to call the > please re-read the FAQ entry "Why do I get a NoClassDefFoundError". > Sorry for beeing terse, but this all information I can pass along, as this is really a Java issue. -- Microsoft (.NET) has learned its lession from the windows "dll hell", Sun has not. Thanks Jost, a short answer is way better than none. The faq says : Why do I get a NoClassDefFoundError? Because Java doesn't have a module system. All interconnected libraries must be loaded with a single java_require() call. See the README for details. But i AM using a single java_require() call loading all my libraries ! (I have even tested with a single .jar file containing everything to be sure...) Does it mean that as I compiled JavaBridge as a native php, I can't load some other libraries ? I'm confused. I note too that when even if my .jar libraries are in java.ext.dirs, they are not loaded... Oops ! Ok, I have rebooted the servlet and now, the libraries are loaded automatically. I don't use java_require() anymore. I still have problems, but it's better. I'll come back to the mailing list, either failure or success, in some time. David |
|
From: <php...@li...> - 2008-11-02 11:52:42
|
Hi, > But i AM using a single java_require() call loading all my > libraries ! More importantly each class and all dependencies must be loaded by exactly one class loader. I have updated the FAQ entry, please see: http://php-java-bridge.sf.net/pjb/FAQ.html#java-dll-hell > (I have even tested with a single .jar file containing > everything to be sure...) As long as the depedency is missing or loaded from another loader, you will get this error -- or even a ClassCastException, because the same class loaded via two different loaders creates two assignment-incompatible class instances. Regards, Jost Boekemeier |
|
From: <php...@li...> - 2008-11-03 15:35:47
|
php...@li... a écrit : > Hi, >> But i AM using a single java_require() call loading all my >> libraries ! > More importantly each class and all dependencies must be loaded by exactly one class loader. I have updated the FAQ entry, please see: > http://php-java-bridge.sf.net/pjb/FAQ.html#java-dll-hell >> (I have even tested with a single .jar file containing >> everything to be sure...) > As long as the depedency is missing or loaded from another loader, you will get this error -- or even a ClassCastException, because the same class loaded via two different loaders creates two assignment-incompatible class instances. > Regards, > Jost Boekemeier Thanks Jost, i'm currently trying to use tomcat, as there are more tutorials. I'll come back to the list when I've succeeded, if only to point my errors. David |
|
From: <php...@li...> - 2008-11-05 14:05:31
|
David Pradier a écrit :
> Thanks Jost,
> i'm currently trying to use tomcat, as there are more tutorials. I'll
> come back to the list when I've succeeded, if only to point my errors.
Hi,
I've finally managed to have a working debian etch PhpJavaBridge tomcat
jasperreports install :-)
For the record, here are some things i needed to do :
- to enable the servlet : it is necessary to configure or disable the
TOMCAT5_SECURITY in /etc/default/tomcat5,
- to access the servlet : the tomcat port on debian is 8180, not 8080,
- to include the Java.inc file coming from the servlet : put
"allow_url_include = On" in /etc/php5/apache2/php.ini,
- to have the PhpJavaBridge tests working : put "define("JAVA_HOSTS",
"127.0.0.1:8180");" instead of "define("JAVA_HOSTS", "127.0.0.1:8080");"
in /var/lib/tomcat5/webapps/JavaBridge/java/Java.inc
- to load all my java libraries at the same time : put all my
/usr/share/java/*.jar and generally each and every .jar i use in
/var/lib/tomcat5/webapps/JavaBridge/WEB-INF/lib/
I hope this helps somebody.
Regards,
David
|
|
From: <php...@li...> - 2008-11-06 21:02:47
|
> disable the > TOMCAT5_SECURITY in /etc/default/tomcat5, Not really. See FAQ http://php-java-bridge.sourceforge.net/pjb/FAQ.html#tomcat-security. :) |
|
From: <php...@li...> - 2008-11-07 08:24:16
|
php...@li... a écrit : >> disable the >> TOMCAT5_SECURITY in /etc/default/tomcat5, > > Not really. See FAQ http://php-java-bridge.sourceforge.net/pjb/FAQ.html#tomcat-security. :) You're right, it is not needed. A complete production should not disable tomcat security. I had some more troubleshooting to do and didn't want to use some time on tomcat security configuration, as i was already trying to figure how to install some four technos, all of which were totally new for me :-) |