0

We need to call a user defined java function within php code,so javaBridge connection is needed.

we have done the php-javabridge-configuration and it is working fine. http://phprambabu.blogspot.in/2016/04/php-javabridge-configuration.html

To connect php with java class, we are running the java class from eclipse on tomcat server, HTTP port:8086 and mentioning the same port number in java.inc file, and its path is added in php file as "required_once(Java.inc)".

-> this shows error in Java.inc file but changes made in Java.inc seems correct according to other resources found on internet and stackoverflow.

changes in Java.inc

define ("JAVA_HOSTS", "localhost:8086");

...

if(!defined("JAVA_HOSTS")) {
    if(!java_defineHostFromInitialQuery(java_get_base())) {
        if ($java_ini=get_cfg_var("java.hosts")) define("JAVA_HOSTS",$java_ini);
        else define("JAVA_HOSTS","127.0.0.1:8086");
    }
}

php file content snippet

function createBridge() {
    $demo = new java("main.bridge");
    echo 'New Bridge instance created';
    $demo->fn();
    return $demo;
}

Here, running java src folder contains -> "main" folder contains -> "bridge.java" -> fn() function

if mentioned changes are done in java.inc, Fatal error occurs:

Fatal error: HTTP status 403, Access to the specified resource has been forbidden. Apache Tomcat/7.0.72 in C:\xampp\htdocs\JavaBridge\java\Java.inc on line 869

Line 869 refers to 3rd line of below snippet:

function dieWithBrokenConnection($msg) {
    unset($this->protocol->client->protocol);
    trigger_error ($msg?$msg:"unknown error: please see back end log for details",E_USER_ERROR);
}

And we are using Xampp for local server. Please let us know if I'm doing something wrong in between or any other useful stuff that can help us out.

23
  • could you also share error message ?? Commented Apr 2, 2017 at 11:59
  • if mentioned changes are done in java.inc: _Fatal error: HTTP status 403, Access to the specified resource has been forbidden. Apache Tomcat/7.0.72 in C:\xampp\htdocs\JavaBridge\java\Java.inc on line 869 _ Line 869 refers to 3rd line of below snippet: function dieWithBrokenConnection($msg) { unset($this->protocol->client->protocol); trigger_error ($msg?$msg:"unknown error: please see back end log for details",E_USER_ERROR); } Commented Apr 2, 2017 at 14:07
  • can you check if C:\xampp\htdocs\JavaBridge\java\Java.inc exists ?? Also, make sure filename has same case. Commented Apr 2, 2017 at 14:17
  • yes i have cross-checked the location, file exists and have same case. Commented Apr 2, 2017 at 14:28
  • which OS are you using ? could you also check the file permission ? Commented Apr 2, 2017 at 14:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.