php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14754 java.* configuration values from php.ini lost on subsequent executions
Submitted: 2001-12-29 12:25 UTC Modified: 2003-07-29 07:23 UTC
Votes:27
Avg. Score:4.6 ± 0.7
Reproduced:24 of 24 (100.0%)
Same Version:13 (54.2%)
Same OS:9 (37.5%)
From: j dot kase at privador dot com Assigned:
Status: No Feedback Package: Java related
PHP Version: 4.2.1 & 4.3.0-dev OS: Windows XP Home / Apache 1.3.24
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2001-12-29 12:25 UTC] j dot kase at privador dot com
This is similar to bug#6990, but since I could no longer append to it, I am opening a new report.

The symptoms are the same as descibed in #6990 - on initial execution, all the values from php.ini are imported correctly, including the java.* values so that I can execute custom Java classes from PHP (very cool feature btw). However, after running the page a few times, it gives me the error "Fatal error: Unable to create Java Virtual Machine", which most likely means that it has blown up the paths to JDK and classes which I have specified in php.ini, and cannot create a JVM.

The trigger which invokes the error seems to be the moment when I change and recompile my Java class. Sometimes it also triggers the error after I update just my PHP code, but not my Java class.

Restarting Apache fixes the error each and every time (for a short period - then it occurs exactly the same way), but obviously this is not the viable solution that I am looking for.

Bug#6990 also mentions something about placing the [Java] section of php.ini (i.e. configuration for a dynamic module) before or after loading the extension code (in my case, Extension=php_java.dll). This has zero effect - no matter whether the [Java] section is before or after the Extension statement, it behaves exactly the same way.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-29 12:59 UTC] j dot kase at privador dot com
Another note. Users with Linux systems experiencing the same bug reported receiving errors and successes interchangeably - something like 3 errors, 1 success, 3 errors, 1 success etc. This is not true for me - I only keep getting errors until I restart Apache.
 [2002-02-24 06:16 UTC] yohgaki@php.net
Please test with  PHP 4.1.1+JDK 1.2 and report the result back 
Please do not forget  updating PHP version. Thanks.
 [2002-02-24 11:44 UTC] j dot kase at privador dot com
Installed PHP 4.1.1 and Java(TM) Development Kit 1.2.2_011 from Sun (filename jdk-1_2_2_011-win.exe).

Problem remains the same - after recompiling Java class I get "Unable to create Java Virtual Machine". After restarting Apache, it works again until I recompile Java class.

I am not sure that I have myself configured everything correctly, so here is the [Java] section from my php.ini just in case.

[Java]
java.class.path = "e:/program files/php/java/php_java.jar;e:/webs/javaclasses/"
java.home = e:/jdk
java.library = e:/jdk\jre\bin\classic\jvm.dll 
java.library.path = "e:/program files/php/extensions;"
 [2002-02-28 23:34 UTC] adam dot swick at pantellos dot com
I am not sure if this will help you, but I received similar, but reproducible behavior when performing the following:

1.  Load a PHP page in the browser that calls Java -- works fine.
2.  Wait a few minutes and refresh the page -- receive "Fatal error: Unable to create Java Virtual Machine".
3.  Restart Apache and move back to step 1.

I noticed that once I changed Apache back to loading the PHP CGI Binary, the problem went away.  There appears to be a bug running PHP-Java when PHP is loaded as an Apache module.

This was tested on Apache/1.3.20 Server and PHP 4.1.1.
 [2002-08-08 10:08 UTC] kalowsky@php.net
Is this bug still valid for you in the recent releases?
 [2002-08-25 11:01 UTC] j dot kase at privador dot com
Tested with the following:
* Windows XP Home
* Apache 1.3.24
* PHP 4.2.1
* Java SDK 1.4.0

The bug is still valid. Actually, even recompiling the Java class is not necessary - even if the class is run correctly, hitting Refresh in the browser multiple times (simulating heavy load) eventually causes the error to persist until Apache restart.

Another observation - I change my class code and recompile, but PHP still uses the old class method code and returns outdated results, suggesting some kind of caching is taking place somewhere. I'm not sure if the two things are related or not.
 [2002-09-07 00:13 UTC] kalowsky@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-09-26 20:06 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2002-10-08 11:12 UTC] bharathlg at hotmail dot com
Iam still facing this bug even after trying with the snapshot specified.Iam running on apache 1.3.26 and win2K.
I first experienced this on Php 4.2.2.

Actually I took a closer look at the source.It seems to me that the reference to the global pointer to jvm( java.c ) seems to be reset resulting in the call to jvm_create after the first request(when it shouldnt, as the pointer should still be valid as we are not releasing the jvm pointer). Since there was no call to jvm_destroy, I guess some internal resource has been locked up resulting in JNI_CreateVM returning -1(undefined error in JNI.h) on the subsequent calls.

Any help would be highly appeciated
 [2002-10-08 14:51 UTC] kalowsky@php.net
Marking as open and updating version
 [2002-10-24 06:23 UTC] rodgar at airtel dot net
I experimented this from php 4.2.2. Now, I'm running php 4.2.4 (the snapshot from 23-Oct-2002 17:22) on Apache 1.3.27 and WinNT 4.0 and the error still appears.
 [2002-10-27 12:31 UTC] pugztoma at pit dot ktu dot lt
I have experienced the same problem.
But switched from hotspot jvm to classic
and problem disappeared.
I am using:
php 4.2.1, apache 1.3.xx
Win2k,
php.ini
[Java]
java.class.path = E:\php4.2.1\extensions\php_java.jar
java.home = E:\jdk1.3\jre
java.library = E:\jdk1.3\jre\bin\classic\jvm.dll
 [2002-11-05 09:58 UTC] rodgar at airtel dot net
I have switched from hotspot jvm to classic jvm but the problem continues.
 [2002-11-08 15:55 UTC] sean at sbdconsultants dot com
Some people have suggested that switching to use PHP in CGI-mode alleviates this problem.  (However, I am unwilling to do this to solve the problem anyway.)  Does this recommendation maybe shed some light on the cause?
 [2002-11-22 13:21 UTC] tjw at webteam dot net
Configuring apache with "MaxRequestPerChild 1" and "KeepAlive Off"
will also fix this problem.  Granted, it's probably worse than running php in cgi mode performance-wise, but it's more secure.
 [2003-07-29 07:23 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-12-08 07:20 UTC] ishtiaq_ahmad at elixir dot com
This caused by Multi instance of JVM, check ur server Support Multiple instance of same Class 
OR
Add the following Line of Code
before the Line
****= new java("SomeClass");

out.flush();
$myobj = new Java("phptest");

Enjoy........

AHMED
 [2003-12-23 02:06 UTC] hwin at 21cn dot com
my system is windows 2000 + apache 1.29 + php 4.3.4
i have follow these method to resolve the problem,  but problem is continues: "Fatal error: Unable to create Java Virtual Machine in xxxxx"!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 23:01:26 2024 UTC