Configuring JavaBridge on PHP 5.2 and Apache on Linux
Steps to install Java on Linux
- Untar jdk-6u5-ea-bin-b04-linux-i586-27_sep_2007.bin
- Copy it to /var
- So you should now have a /var/jdk1.6.0_05/
- Edit /etc/profile and ~/.bash_profile and add
- PATH=$PATH:/var/jdk1.6.0_05/bin
- CLASSPATH=/var/jdk1.6.0_05/lib:.:/opt/java_classes
- export PATH CLASSPATH
Restart the system for the environment to take effect or just relogin to get the setting on your env
Do an env and you should now see the path and CLASSPATH variable pointing to /var/jdk1.6.0_05/
Test java the installation by
$ java –version
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b04, mixed mode, sharing)
Installing PHP-Java-Bridge
·
- unzip php-java-bridge_4.3.0_j2ee.zip
- run test.sh
- this will create all the files
- if you do a ps –ef you will see a process like
- /var/jdk1.6.0_05/jre/bin/java -jar /root/java-bridge/tmp/ext/JavaBridge.jar SERVLET_LOCAL:8080
- This means the server is started fine
- copy the jars to java classpath
- copy ext/* /var/jdk1.6.0_05/lib/
Testing your installation
Creating a java class
cd /opt/java_classes
Create a new Java File PHP_BRIDGE.java
//begin
public class PHP_BRIDGE{
public String show(String str){
return "Test"+str;
}
public static void main(String[] args){
}
}
#javac PHP_BRIDGE.java
Create a php file to access java class/methods
cd /var/www/html
create a new php file
#file : test.php
require_once('/tvus/vista/jb/java/Java.inc'); @java_reset(); java_require('/opt/java_classes/'); $obj1=new Java(‘PHP_BRIDGE’); echo $obj1->show('this is me'); @java_reset(); ?>
From command line try to run the same
#php-cgi test.php
#jrunscript –l php test.php
"If both these work fine then you are sure that your configuration works fine."
Common Errors The I got stuck with
protocol error: Method Not Allowed The requested method PUT is not allowed for the URL /JavaBridge/JavaBridge.phpjavabridge"Make sure the port 8080 is free and your servlet server is started on 8080 ONLY"
Undefined index: content_length java bridge Or java.lang.ArrayIndexOutOfBoundsException: 5 protocol error: , Invalid document end at col 1. Check the back end log for details. at php.java.bridge.Parser.PUSH(Parser.java:149) at php.java.bridge.Parser.parse(Parser.java:184) at php.java.bridge.Request.handleRequest(Request.java:373) at php.java.bridge.Request.handleRequests(Request.java:481) at php.java.bridge.JavaBridge.run(JavaBridge.java:213) at php.java.bridge.ThreadPool$Delegate.run(ThreadPool.java:58)The server should be started as
java -jar /var/jdk1.6.0_05/lib/JavaBridge.jar SERVLET_LOCAL:8080
and not
java -jar /var/jdk1.6.0_05/lib/JavaBridge.jar INET_LOCAL:8080
8 comments:
hi.
charly palencia
i was working with php-java-bridge, apache and php.
i create a ontology search but, when i'm looking for information many times the program show me that:
protocol error: , Invalid document end at col 10. Check the back end log for details.
i dont know what's that (i'm really new in that )
please help me!!!
hey jab, i'm getting this same error, "protocol error:
Method Not Allowed
The requested method PUT is not allowed for the URL /JavaBridge/javabridge.
Apache Server at 127.0.0.1 Port 80
, Internal error at col 4. Check the back end log for OutOfMemoryErrors. "
but this is on a hosted environment. it works fine locally. what could be causing this? prompt help much appreciated...
p.s. i'm really not a java or server whiz, so please explain for a newbie. :-)
Very ambiguous post. Where is the ext folder?
Try to explain things more clearly.
I would really recommend *against* using this JavaBridge, I tried for about a week to get it going, to no avail. I'm not a Java programmer but am pretty tech savvy, have picked up PHP, AS3 and jQuery pretty easily because of the excellent documentation. This Javabridge has almost no documentation and the forums are moderated by admins who really don't provide helpful support, especially for installation. In the end I figured out how to produce the functionality I needed with pure PHP.
havent followed up this lately.
The set up works but how ever neither do i recommend people using java bridge for real time apps.
I have the same problem
protocol error: , Invalid document end at col 4. Check the back end log for OutOfMemoryErrors.
Javabridge works fine but shows me always that error. Someone can help me?
Thanks
this is just a demo that i got it working..
somehow i am not a big fan of php. If you want to use something like this its better to stick to SOAP or trusted methods rather than something like this..
Hi, OutOfMemoryErrors problem!
look at:http://php-java-bridge.sourceforge.net/OLD/ABOUT.HTM#mode2
here i found the answer:
OutOfMemoryErrors may happen because a cached object cannot be released, either because
1. the object is permanently referenced by a request-handling thread or
2. the object has been entered into the session or application store or
3. the object is referenced by a thread outside of the scope of the PHP/Java Bridge.
I saved some objects in session and i tried to stop javabridge without unset session array.
Bye!
Post a Comment