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

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

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

the entire test.php file is as follows, with the exception of the notification that other things are 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 anyone face the same problems? thanks!

+6
source share
3 answers

Just add the $cancelProxyCreationTag attribute $cancelProxyCreationTag class

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

This attribute is used in the Java destruction method. its a must if you use a bridge in a loop.

+3
source

You can also do this from PHP code using the bridge, in case you do not want to crack the war / jar files and redistribute them.

 //... $workbook = new Java('org.apache.poi.xssf.usermodel.XSSFWorkbook'); $workbook->__client->cancelProxyCreationTag = 0; //... 
+2
source

The solution to this problem requires the elimination of two interrelated problems.

Firstly, there is no java/Java.inc file deployed in the original JavaBridge.war . It is generated, which is problematic due to the error you encountered that is hidden inside java/Java.inc .

Secondly, the java/Java.inc contains a variable that grows before it is initialized.

Fix these issues as follows:

  • Download the JavaBridge.war file.
  • Extract the java/Java.inc file by calling: java -cp JavaBridge.war TestInstallation , according to the documentation .
  • Fix any errors that occur (for example, missing php5-cli).
  • Edit java/Java.inc .
  • Go to line 1994.
  • Paste the following code directly above line 1994:
  if (empty ($ client-> cancelProxyCreationTag)) {
       $ client-> cancelProxyCreationTag = 0;
     }

The else block (lines from 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.

Then recreate the .war file as follows:

  • Create a new, empty, temporary directory
  • Unzip the original JavaBridge war file into a temporary directory.
  • Move the java directory to a temporary directory; make sure it contains the updated Java.inc file!
  • Archive of a broken JavaBridge.war file.
  • Create a new version of JavaBridge.

For example, this may resemble:

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

The problem must be resolved.

+1
source

Source: https://habr.com/ru/post/974413/


All Articles