Tip #-1 How Does GlassFish Pick the JVM to Run In?

 If you start a GlassFish Server by using asadmin, then you may be interested in precisely how the JVM that will run GlassFish Server is chosen.  Note that if you restart via the Admin Console (GUI) you are indirectly using asadmin to restart the server and the following rules apply as well.  If you start the Server some other way, like

java -jar glassfish.jar

then you are in charge of choosing the JVM yourself.

In order of precedence from high to low:

  1. The jdk location specified in domain.xml in the java-config  ("java-home")
  2. The contents of AS_JAVA in the asenv property file (in glassfish/config)
  3. Whatever the env. variable, JAVA_HOME, is pointing at.
  4. The java.home system property is used like so:
    1. Parent directory of java.home -- this is because sometimes the JRE's java is asadmin's JVM and the JDK may be in the directory above.
    2. Contents of java.home

In every case I guarantee a valid java.  E.g. you can set 1,2,3 to garbage and we'll still find a java to use.

Note that we never explicitly use java from the path -- if there is one.  It may be implicitly used though by using #4 above since asadmin itself is definitely running inside of a valid JVM.

p.s.  If you are wondering where the code is -- 90% of it is inside AsenvPropertyReader.java
10% is in GFLauncher.java

-- AsenvPropertyReader can't access domain.xml.  GFLauncher can.  GFLauncher's job is to see if (1) above applies.  If not he defers to AsenvPropertyReader.

Clear?

Comments:

> Clear?
Almost! which versions of GlassFish does this apply to?

Posted by Alexis MP on July 19, 2011 at 06:13 AM PDT #

This Blog applies to all versions of GlassFish starting with 3.0

Posted by Byron Nevins on July 26, 2011 at 11:12 AM PDT #

but, I don't run it. what can i do ? please help me..

Posted by serdar on August 08, 2011 at 02:47 PM PDT #

I am still puzzled by Java locations used by Glassfish - most directly because I cannot find where ${com.sun.aas.javaRoot} is ever defined. Changing the property values you have suggested doesn't seem to have any effect.

The problem: I want Glassfish to use the installed 64-bit jvm, yet I cannot get it to do so. The JVM report indicates that AS_JAVA = C:\glassfish3\jdk7, yet JRE Native Library Path points to C:\Program Files (x86)\Java\jdk1.7.0_01 (this and a few other locations appear to be pre-pended to the Win 7 PATH variable when Glassfish starts).

I have changed Java Home in the JVM general settings to C:\glassfish3\jdk7 also.

Any thoughts/suggestions?

Thanks

Posted by Jack on August 31, 2012 at 04:59 PM PDT #

Nice to know!

However, it appears that asadmin won't even start if the JDK location is *only* specified in 1. After specifying it in 2. asadmin starts nicely.

Posted by guest on November 29, 2012 at 01:41 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

ByronNevins

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today