Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xampp,php-java-bridge show notice: Undefined property: java_Client::$cancelProxyCreationTag

i get the following notice when I try to use javaBridge because I want to use java code in php,I followed some tutorials but encoutered following things

Undefined property: java_Client::$cancelProxyCreationTag in D:\xampp\htdocs\java\Java.inc on line 1994

the whole test.php file is as follows, except the notice the other things is normal,

php-java-bridge config...

Java version=1.7.0_55 

Notice: Undefined property: java_Client::$cancelProxyCreationTag in D:\xampp\htdocs\java\Java.inc on line 1994
Java vendor=Oracle Corporation 
OS=Windows 7 6.1 on amd64 
星期三, 八月 27, 2014 at 4:56:58 下午 中国标准时间

Does anybody have encounter the same trouble? thanks!

like image 519
whitekevin Avatar asked Aug 27 '14 09:08

whitekevin


3 Answers

It's simple just add the attribute $cancelProxyCreationTag in the java_Client class

//Java.inc
class java_Client {
...
public $cancelProxyCreationTag;
...
}

This attribute is used in the Java destruct method . its mandatory if you are using the bridge in a loop.

like image 94
Ahmed Rachdi. Avatar answered Oct 14 '22 05:10

Ahmed Rachdi.


You can also do this from the PHP code that's using the bridge in case you don't want to crack open the war/jar files and redeploy.

//...
$workbook = new Java('org.apache.poi.xssf.usermodel.XSSFWorkbook');
$workbook->__client->cancelProxyCreationTag = 0;
//...
like image 29
Rob Ruchte Avatar answered Oct 14 '22 06:10

Rob Ruchte


Solving this problem requires fixing two interrelated issues.

First, there is no java/Java.inc file deployed in the original JavaBridge.war. It is generated, which is problematic due to the bug, which you've encountered, that lurks inside java/Java.inc.

Second, the java/Java.inc file contains a variable that is incremented before it is initialized.

Fix these issues as follows:

  1. Download the JavaBridge.war file.
  2. Extract the java/Java.inc file by calling: java -cp JavaBridge.war TestInstallation, as per the documentation.
  3. Fix any errors that appear (such as a missing php5-cli).
  4. Edit java/Java.inc.
  5. Go to line 1994.
  6. Insert the following code immediately above line 1994:
    if( empty($client->cancelProxyCreationTag) ) {
      $client->cancelProxyCreationTag = 0;
    }

The else block (lines 1989 to 1998) should resemble:

} else {
$result=clone($client->cachedJavaPrototype);
$result->__factory=$cacheEntry->factory;
$result->__java=++$client->asyncCtx;
$result->__signature=$cacheEntry->signature;
// FIX: initialize variable before it is used.
if( empty($client->cancelProxyCreationTag) ) { 
  $client->cancelProxyCreationTag = 0;
} 
$result->__cancelProxyCreationTag=++$client->cancelProxyCreationTag;
return $result;

Save the file.

Next, re-create the .war file as follows:

  1. Create a new, empty, temporary directory
  2. Unzip the original JavaBridge war file into the temporary directory.
  3. Move the java directory into the temporary directory; be sure that it includes the updated Java.inc file!
  4. Archive the broken JavaBridge.war file.
  5. Create a new version of the JavaBridge.

For example, this might resemble:

mkdir temp
unzip ../JavaBridge.war
mv ../java .
mv ../JavaBridge.war /tmp
zip -r ../JavaBridge.war *

The problem should be resolved.

like image 26
Dave Jarvis Avatar answered Oct 14 '22 06:10

Dave Jarvis