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!
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.
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;
//...
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:
java/Java.inc
file by calling: java -cp JavaBridge.war TestInstallation
, as per the documentation.java/Java.inc
.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:
java
directory into the temporary directory; be sure that it includes the updated Java.inc
file!JavaBridge.war
file.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With