dev@glassfish.java.net

Re: How do I switch java during 'asadmin start-domain'

From: Sahoo <Sahoo_at_Sun.COM>
Date: Mon, 03 Nov 2008 16:08:26 +0530

Even though that is the order used by launcher, "asadmin start-domain"
itself requires JDK 6 after Jerome's recent check-in [1] in trunk.
"asadmin start-domain" needs JDK6 in the path, otherwise it fails with
"java.lang.NoClassDefFoundError: javax/xml/stream/XMLStreamException."
This is likely to cause problems to users who have been using asenv.conf
to configure the JDK used by GlassFish.

Thanks,
Sahoo

[1] http://fisheye4.atlassian.com/changelog/glassfish-svn/trunk/v3?cs=23625

Byron Nevins wrote:
>
> Here is the order of precedence for JDKs when starting a domain via
> the Launcher (i.e. asadmin start-domain)
>
> 1. Domain.xml (java-home inside java-config)
> 2. asenv
> 3. JAVA_HOME environmental variable
> 4. System.getProperty("java.home") + "../"
> 5. System.getProperty("java.home")
> 6. null (should be impossible -- 4 or 5 must have a vaild JDK or
> JRE or launcher code could not have run!)
>
> -- Thank You!
>
>
> **** LAUNCHER ****
> private void setJavaExecutable() throws GFLauncherException {
> // first choice is from domain.xml
> if (setJavaExecutableIfValid(javaConfig.getJavaHome()))
> return;
>
> // second choice is from asenv
> if (!setJavaExecutableIfValid(asenvProps.get(JAVA_ROOT_PROPERTY)))
> throw new GFLauncherException("nojvm");
>
> }
>
> ***** ASEnv Reader *******
>
> private void setJavaRoot() {
> // make sure we have a folder with java in it!
> // note that we are not in a position to set it from
> domain.xml yet
>
> // first choice -- whatever is in asenv
> String javaRootName =
> props.get(SystemPropertyConstants.JAVA_ROOT_PROPERTY);
>
> if(isValidJavaRoot(javaRootName))
> return; // we are already done!
>
> // try JAVA_HOME
> javaRootName = System.getenv("JAVA_HOME");
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
> // try java.home with ../
> // usually java.home is pointing at jre and ".." goes to the jdk
> javaRootName = System.getProperty("java.home") + "/..";
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
>
> // try java.home as-is
> javaRootName = System.getProperty("java.home");
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
>
> // TODO - should this be an Exception? A log message?
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY, null);
> }
>
> private boolean isValidJavaRoot(String javaRootName) {
> if(!GFLauncherUtils.ok(javaRootName))
> return false;
>
> // look for ${javaRootName}/bin/java[.exe]
> File f = new File(javaRootName);
>
> if(GFLauncherUtils.isWindows())
> f = new File(f, "bin/java.exe");
> else
> f = new File(f, "bin/java");
>
> return f.exists();
> }
>
>
>
> Sahoo wrote:
>> In GF v1/v2, we could specify the JDK location in asenv.conf. How do
>> we do it in GFv3?
>>
>> Thanks,
>> Sahoo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> --
> Byron Nevins Work 408-276-4089, Home 650-359-1290, Cell 650-784-4123 - Sun Microsystems, Inc.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net For
> additional commands, e-mail: dev-help_at_glassfish.dev.java.net