| Summary: | HTTP Preview Server does not start - "Could not find JRE executable" | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] WTP ServerTools | Reporter: | Robert Elliot <rob> | ||||||||
| Component: | wst.server | Assignee: | Elson Yuen <eyuen7> | ||||||||
| Status: | RESOLVED FIXED | QA Contact: | Elson Yuen <eyuen7> | ||||||||
| Severity: | normal | ||||||||||
| Priority: | P3 | CC: | amirco, arman.arbab, arvera, buckett, chris.mcclune, ckrintz, eclipse-dev, eclipsebugs, ftip, j.edward.rayl, jan.wloka, kimbaudi, l.wayne.james, lee_j_keith, of, ola.redell, softandbyte, stralf, super.zen, taa.eclipse_ide, thatnitind, VolkerMu | ||||||||
| Version: | 3.1 | Keywords: | helpwanted | ||||||||
| Target Milestone: | 3.4.2 | ||||||||||
| Hardware: | PC | ||||||||||
| OS: | Mac OS X - Carbon (unsup.) | ||||||||||
| See Also: | https://git.eclipse.org/r/109136 | ||||||||||
| Whiteboard: | |||||||||||
| Attachments: |
|
||||||||||
|
Description
Robert Elliot
Try setting the java.home to /Library/Java/Home and see if that works. Thanks for the suggestion; could you elaborate? In Info.plist I have the following: <string>-vm</string><string>/Library/Java/Home</string> and typing "echo $JAVA_HOME" at the command line produces /Library/Java/Home. However, I get the same error when I try and launch the HTTP Preview Server. Looking in "Eclipse Installation Details / Configuration" I see this: java.home=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home That is what /Library/Java/Home ultimately resolves to, via several extremely convoluted symlinks: /Library/Java/Home -> /System/Library/Frameworks/JavaVM.framework/Home /System/Library/Frameworks/JavaVM.framework/Home -> Versions/CurrentJDK/Home /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK -> /System/Library/Frameworks/JavaVM.framework/Versions/1.6 /System/Library/Frameworks/JavaVM.framework/Versions/1.6 -> /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0 Is there something else I should be setting? Is it that it doesn't work with a JDK and needs a JRE? If so, is there any way to specify a JRE specifically for the Preview Server, as I need to run Eclipse via a JDK for some other plugins? Hi, I've the same problem. But is there any solution? I think the problem is related to the MAC OS system and the compatibility with JAVA. I am not sure of what the fix would be, but I have found some hits regarding java.home in MAC OS. I still need to look deeper into the preview server but I don't have a MAC OS around to play with so this has been hard to debug. It would be nice if the community can help us on finding out a fix for this problem. I can guide the community on how to debug the problem. I can help to debug this problem if you guide me.
I've got a Mac too.
I found on
org.eclipse.wst.server.preview.adapter.internal.core.PreviewLaunchConfigurationDelegate
The following fragment of source code which returns always null if the platform is a mac:
protected static File getJavaExecutable() {
// do not detect on the Mac OS
if (Platform.getOS().equals(Constants.OS_MACOSX))
return null;
And on the same class there's the call to the method causing the error
// jre
File java = getJavaExecutable();
if (java == null)
throw new CoreException(new Status(IStatus.ERROR, PreviewPlugin.PLUGIN_ID, "Could not find JRE executable"));
Tell me how I can help.
Thx
(In reply to comment #5) Thanks for your help. I would first try to remove that piece of code and setting java.home to something, but some article that I found online seemed to imply some problems around finding or setting java.home for the entire system. I just ran into the same problem? Is there any news on the status of this bug? It is a serious one, because it reduces Eclipse WTP on the Mac to not much more than an editor with keyword highlighting. -Frank Frank, The bug is marked as 'helpwanted' because we haven't had time to work on it in part due to not having the resources (a mac available). It would help if you can help debugging and find a solution for the problem. I have the same problem How can i help you guys to fix this ? I installed some extra web tools last time. (In reply to comment #9) We need someone to look at the code, change it and do test to ensure the problem is fixed. You can use this tutorial to guide yourself on how to download the code: http://www.eclipse.org/webtools/community/tutorials/DevelopingWTP/DevelopingWTP.html The plugin you need to download is org.eclipse.wst.server.preview.adapter. After that refer to Comment #5 to find the class that needs to be modified. There is possibly more classes that need to be changed but you can start with the changes suggested in comment #5 i changed following /org.eclipse.wst.server.preview.adapter/src/org/eclipse/wst/server/preview/adapter/internal/core/PreviewLaunchConfigurationDelegate.java i placed following lines in comment //if (Platform.getOS().equals(Constants.OS_MACOSX)) //return null; import org.eclipse.osgi.service.environment.Constants; was in my test a unused import that i placed in comment. when run that project my http preview worked perfect. I dont know how i can build or resubmit that code can someone do it for me ? 1. test also on windows. 2. test it again on MaxOSX after build. just should when i need to test it on MacOSX ps. i have no idea what can go wrong whit this change. ( i am a newbie programmer ;-) ) Created attachment 188530 [details]
binary of the fix suggested
Here is a binary version of the changes, I would like to hear more testing to ensure that the problem is fully fix. But the changes look safe enough that can be included in a build in the future.
I just would like to here more testing and the levels of MAC OS where the fix was tested.
(In reply to comment #12) I have the same problem on Eclipse Helios and I tried the suggested fix without luck. I might not have done it correctly though. I replaced the file org.eclipse.wst.server.preview.adapter_1.1.0.v20090311b.jar under eclipse/plugins (renamed it to *.jar.old) with the attached one (org.eclipse.wst.server.preview.adapter_1.1.0.v201102081105.jar). I got another error message though: "The selection cannot be run on any server", and I got it even before I got a chance to select the preview server. It is the same error message that I get if I do not have any valid ...preview.adapter...jar file on the path. (In reply to comment #13) Now I continued further and did the fix myself as suggested in 11. WIth my own fix the preview server appears to work fine when executed in the IDE environment, but when I export the .jar file and use it in my original installation I get the same problem as reported in 13 for the fix attached in 12. Suggestions? (In reply to comment #14) > (In reply to comment #13) > Now I continued further and did the fix myself as suggested in 11. WIth my own > fix the preview server appears to work fine when executed in the IDE > environment, but when I export the .jar file and use it in my original > installation I get the same problem as reported in 13 for the fix attached in > 12. > > Suggestions? No need to remove the old jar the platform will pick the latest version. Try leaving the old jar there and just dropping the new one. Also if you have a /eclipse/dropins directory it might be best to place the binary jar there. (In reply to comment #15) > No need to remove the old jar the platform will pick the latest version. Try > leaving the old jar there and just dropping the new one. Also if you have a > /eclipse/dropins directory it might be best to place the binary jar there. OK, did that, tried both the plugin and dropin folder with original file still in plugin folder. In both cases I got the original problem back "Could not find JRE executable". Strange. Makes no sense. Created attachment 201700 [details]
Prob exists in Indigo also
Same problem in Indigo. The reason why the poposed patch (removing the test for OS-X) does not work for all is probably, that you'll need a java.home environment variable.
Under Lion (OS-X 10.7) the JRE is accessible from /Library/Java/Home (can also be added as a standard JRE). I did a quick hack to the bundle:
protected static File getJavaExecutable() {
File javaHome;
// do not detect on the Mac OS
if (Platform.getOS().equals(Constants.OS_MACOSX)) {
try {
javaHome = new File("/Library/Java/Home").getCanonicalFile();
} catch (IOException e) {
return null;
}
} else {
// retrieve the 'java.home' system property. If that directory doesn't exist, return null
try {
javaHome = new File(System.getProperty("java.home")).getCanonicalFile();
} catch (IOException e) {
return null;
}
}
if (!javaHome.exists())
return null;
// find the 'java' executable file under the java home directory. If it can't be
// found, return null
return findJavaExecutable(javaHome);
}
and added the binary to this comment.
- Hendrik
Transfering ownership to Elson, as I can't currently look into it. (In reply to comment #17) Just to confirm that Hendrik's August 18th patch works fine for me. Mac OS X 10.7.2, Eclipse Indigo SR1. (I guess the "do not detect on the Mac OS" comment still needs to be removed before merging this patch.) It would be nice to see this fixed, is there anything I can do to help this along? I have this same problem with Juno JEE and neither patch works for me. Can I get one that replaces this jar please? org.eclipse.wst.server.preview.adapter_1.1.100.v20120517_1638.jar thanks Chandra I have Mac OS X 10.7 Lion and I installed Java, Eclipse Juno 4.2 Classic, and WTP to create Static Web Projects.
When I tried to run my static web project on the HTTP Preview Server, I also got the following error:
'Starting HTTP Preview at localhost' has encountered a problem. Could not find JRE executable.
I verified that java.home is set correctly.
System.getProperty("java.home") returns /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home.
I also set $JAVA_HOME environment variable under ~/.bash_profile: export JAVA_HOME `/usr/libexec/java_home`.
$JAVA_HOME also returns /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home.
I also downloaded the two fixes and put it in my eclipse/dropins folder.
I have spent the last day Googling and trying to fix this problem to no avail. I hope this bug will get fixed.
Created attachment 218743 [details]
HTTP Preview Server bug fix for Eclipse 4.2 Juno
Attached is a proposed bug fix for the HTTP Preview Server in Eclipse 4.2 Juno. Basically the proposed bug fix will set the java.home environment variable to "/Library/Java/Home" for Mac OS X where the JRE is located.
First of all, I also want to confirm that Hendrik's patch works for Eclipse Indigo SR2 on Mac OS X 10.7.4 Lion.
Second, I agree with previous comments that getJavaExecutable() method does not detect the JRE on Mac OS and it should look for the JRE under /Library/Java/Home.
To fix this bug for Eclipse 4.2 Juno, the getJavaExecutable() method in org.eclipse.wst.server.preview.adapter.internal.core.PreviewLaunchConfigurationDelegate.java should be modified so that it sets java.home to /Library/Java/Home.
protected static File getJavaExecutable() {
// set the 'java.home' system property on the Mac OS
if (Platform.getOS().equals(Constants.OS_MACOSX))
System.setProperty("java.home", "/Library/Java/Home");
// retrieve the 'java.home' system property. If that directory doesn't exist, return null
File javaHome;
try {
javaHome = new File(System.getProperty("java.home")).getCanonicalFile();
} catch (IOException e) {
return null;
}
if (!javaHome.exists())
return null;
// find the 'java' executable file under the java home directory. If it can't be
// found, return null
return findJavaExecutable(javaHome);
}
I have created a patch and attached it as a proposed patch (in the form of a .patch file). I don't know how to create a binary of the proposed patch. Also, I don't think I have the authority/permission to create a binary of the proposed patch. Can somebody create a binary of the proposed patch? Or give me instructions on how to do it? This bug is so close to being fixed for Eclipse 4.2 Juno.
I second that this really needs to be fixed for the Mac. Now that Juno is out, there is not an available package binary to replace the existing as there was in Indigo. I can confirm that the patch fixes this issue. I followed the instruction and rebuild this plugin and double-checked that HTTP Preview now worked. Please apply upstream. Cheers Olaf Thanks for submitting the patch. Changes relased to 3.4.2 and 3.5. The last comment in this thread indicates that a patch was released into 3.5, but the latest version of eclipse still has this issue. What gives? (In reply to comment #28) > The last comment in this thread indicates that a patch was released into > 3.5, but the latest version of eclipse still has this issue. What gives? 3.4.2 and 3.5 refer to WTP version numbers, not Eclipse project versions. See http://projects.eclipse.org/projects/webtools for their dates. (In reply to comment #29) > (In reply to comment #28) > > The last comment in this thread indicates that a patch was released into > > 3.5, but the latest version of eclipse still has this issue. What gives? > > 3.4.2 and 3.5 refer to WTP version numbers, not Eclipse project versions. > See http://projects.eclipse.org/projects/webtools for their dates. Ah yes, ok. So I downloaded the 4.3 Kepler release for Mac which looks to include 3.5 of WTP, and the preview server fails to start, complaining about a class not found. Has anyone else seen this? Should a new bug be submitted? Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/jetty/webapp/WebAppContext Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.webapp.WebAppContext at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Kepler is still in active development and won't be released until June. What did you download, specifically what file name(s), and how did you install them? (In reply to comment #31) > Kepler is still in active development and won't be released until June. > What did you download, specifically what file name(s), and how did you > install them? I downloaded the 4.3 M5 pkgs from here: http://www.eclipse.org/downloads/index-developer.php I was planning to test this fix, but ran into another preview server error. the same problem seems to occur with Juno SR2 Tested with Sun JDK 1.6.0_37-b06 and a fresh new workspace (In reply to comment #30) > (In reply to comment #29) > > (In reply to comment #28) > > > The last comment in this thread indicates that a patch was released into > > > 3.5, but the latest version of eclipse still has this issue. What gives? > > > > 3.4.2 and 3.5 refer to WTP version numbers, not Eclipse project versions. > > See http://projects.eclipse.org/projects/webtools for their dates. > > Ah yes, ok. So I downloaded the 4.3 Kepler release for Mac which looks to > include 3.5 of WTP, and the preview server fails to start, complaining about > a class not found. Has anyone else seen this? Should a new bug be submitted? > > Exception in thread "main" java.lang.NoClassDefFoundError: > org/eclipse/jetty/webapp/WebAppContext > Caused by: java.lang.ClassNotFoundException: > org.eclipse.jetty.webapp.WebAppContext > at java.net.URLClassLoader$1.run(URLClassLoader.java:202) > at java.security.AccessController.doPrivileged(Native Method) > at java.net.URLClassLoader.findClass(URLClassLoader.java:190) > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) > at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Hi there! As I read in comment #27, this has been fixed in WTP 3.4.2 and 3.5. I just installed Eclipse Helios (need that version for JavaScript) and as far as I see, Helios comes only with Web Developer tools V 3.2.3 where the bug still arises. Can I install the newer WTP into Helios? Or is there another way to fix this issue with the preview server? Sorry if this is a dumb question. I am a complete newbie in Eclipse AND on the Mac. Eclipse works fine on Win7 (where I am firm), but on my Mac this problem occurs. However, the MacBook is far more comfy to use, so i'd like to get it running there... Thanks, R. Hi I am new to programming and I have encountered the 'could not find JRE executable' problem using my mac. I was trying to run some html code in a HTTP Preview server. I need to use eclipse to create a project that includes HTML, php, javascript and also java. Is there a version that would allow me to do this that has the bug already fixed in the download? Or is it something I will have to try and fix using some of the previous comments? Any help on this would be fantastic. Chris Ok, I just returned to my Mac after a 6months break. Installed the newest release of Eclipse Mars1 4.5.1 JEE, uninstalled the old Java and installed the newest JDK 8u73. But still, when I try to start the preview server I get the message "Starting HTTP preview at localhost" has encountered a problem. Could not find JRE executable Looking into Eclipse/Settings/Java/Installed JREs there is only one entry, "Java SE 8 1.8.0_73 (default)", it's highlighted and the path is correct. Any tips for me? I just downloaded a fresh installation of java 8 and eclipse neon on a new mac. I also get an error when running the HTTP preview server: "Starting HTTP preview at localhost" has encountered a problem. Could not find JRE executable", and I also get a null pointer exception when trying to set up a localhost HTTP server through eclipse. These error messages occur both on the Java EE version and on the Javascript/Web Development Version. New Gerrit change created: https://git.eclipse.org/r/109136 |