From scm-return-46227-apmail-geronimo-scm-archive=geronimo.apache.org@geronimo.apache.org Thu May 12 16:04:59 2011 Return-Path: X-Original-To: apmail-geronimo-scm-archive@www.apache.org Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBF1E59C1 for ; Thu, 12 May 2011 16:04:59 +0000 (UTC) Received: (qmail 51262 invoked by uid 500); 12 May 2011 16:04:59 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 51221 invoked by uid 500); 12 May 2011 16:04:59 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 51214 invoked by uid 99); 12 May 2011 16:04:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 May 2011 16:04:59 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 May 2011 16:04:52 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B528423888FD; Thu, 12 May 2011 16:04:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1102362 - in /geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core: GeronimoLaunchConfigurationDelegate.java GeronimoServer.java Date: Thu, 12 May 2011 16:04:30 -0000 To: scm@geronimo.apache.org From: gawor@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110512160430.B528423888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gawor Date: Thu May 12 16:04:30 2011 New Revision: 1102362 URL: http://svn.apache.org/viewvc?rev=1102362&view=rev Log: GERONIMODEVTOOLS-745: Switching JRE via server configuration causes sever startup errors - fill-in JRE_HOME, GERONIMO_HOME info at latest possible moment Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java?rev=1102362&r1=1102361&r2=1102362&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoLaunchConfigurationDelegate.java Thu May 12 16:04:30 2011 @@ -20,6 +20,7 @@ import java.io.File; import java.util.Map; import org.apache.geronimo.st.v30.core.internal.Messages; +import org.apache.geronimo.st.v30.core.internal.Trace; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -85,11 +86,22 @@ public class GeronimoLaunchConfiguration String pgmArgs = getProgramArguments(configuration); String vmArgs = getVMArguments(configuration); String[] envp = getEnvironment(configuration); - + + File jreHome = new File(vm.getInstallLocation(), "jre"); + if (!jreHome.exists()) { + jreHome = vm.getInstallLocation(); + } + + vmArgs = vmArgs.replace("$(JRE_HOME)", jreHome.getAbsolutePath()); + vmArgs = vmArgs.replace("$(GERONIMO_HOME)", server.getRuntime().getLocation().toOSString()); + + Trace.trace(Trace.INFO, "vmArgs=" + vmArgs); + Trace.trace(Trace.INFO, "pgmArgs=" + pgmArgs); + ExecutionArguments execArgs = new ExecutionArguments(vmArgs, pgmArgs); Map vmAttributesMap = getVMSpecificAttributesMap(configuration); String[] classpath = getClasspath(configuration); - + // Create VM config VMRunnerConfiguration runConfig = new VMRunnerConfiguration(mainTypeName, classpath); runConfig.setProgramArguments(execArgs.getProgramArgumentsArray()); @@ -97,7 +109,7 @@ public class GeronimoLaunchConfiguration runConfig.setWorkingDirectory(workingDirName); runConfig.setEnvironment(envp); runConfig.setVMSpecificAttributesMap(vmAttributesMap); - + // Bootpath String[] bootpath = getBootpath(configuration); if (bootpath != null && bootpath.length > 0) Modified: geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java URL: http://svn.apache.org/viewvc/geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java?rev=1102362&r1=1102361&r2=1102362&view=diff ============================================================================== --- geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java (original) +++ geronimo/devtools/eclipse-plugin/trunk/plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/GeronimoServer.java Thu May 12 16:04:30 2011 @@ -16,9 +16,6 @@ */ package org.apache.geronimo.st.v30.core; -import java.io.File; -import java.text.MessageFormat; - import javax.enterprise.deploy.spi.DeploymentManager; import javax.enterprise.deploy.spi.factories.DeploymentFactory; @@ -27,10 +24,6 @@ import org.apache.geronimo.deployment.pl import org.apache.geronimo.st.v30.core.internal.Trace; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jdt.launching.LibraryLocation; import org.eclipse.wst.server.core.util.SocketUtil; /** @@ -70,58 +63,34 @@ public class GeronimoServer extends Gero if (superVMArgs != null && superVMArgs.trim().length() > 0) { return superVMArgs; } - - String runtimeLocation = getServer().getRuntime().getLocation().toString(); - GeronimoRuntimeDelegate geronimoRuntimeDelegate = (GeronimoRuntimeDelegate) getServer().getRuntime().getAdapter(GeronimoRuntimeDelegate.class); - if (geronimoRuntimeDelegate == null) { - geronimoRuntimeDelegate = (GeronimoRuntimeDelegate) getServer().getRuntime().loadAdapter(GeronimoRuntimeDelegate.class,new NullProgressMonitor()); - } - IVMInstall vmInstall = geronimoRuntimeDelegate.getVMInstall(); - - LibraryLocation[] libLocations = JavaRuntime.getLibraryLocations(vmInstall); - IPath vmLibDir = null; - for(int i = 0; i < libLocations.length; i++) { - LibraryLocation loc = libLocations[i]; - IPath libDir = loc.getSystemLibraryPath().removeLastSegments(2); - if(libDir.toOSString().endsWith("lib")) { - vmLibDir = libDir; - break; - } - } - + StringBuilder args = new StringBuilder(); - // -javaagent:"GERONIMO_BASE/bin/jpa.jar" - File agentJar = new File(runtimeLocation + "/lib/agent/transformer.jar"); - if (agentJar.exists()) { - addParm(args, "-javaagent:\"", agentJar.getAbsolutePath(), "\""); - } + addParm(args, "-javaagent:\"$(GERONIMO_HOME)/lib/agent/transformer.jar\""); String pS = System.getProperty("path.separator"); //-Djava.ext.dirs="GERONIMO_BASE/lib/ext;JRE_HOME/lib/ext" - addParm(args, "-Djava.ext.dirs=\"", runtimeLocation, "/lib/ext", pS, vmLibDir.append("ext").toOSString(), "\""); + addParm(args, "-Djava.ext.dirs=\"$(GERONIMO_HOME)/lib/ext", pS, "$(JRE_HOME)/lib/ext\""); //-Djava.endorsed.dirs="GERONIMO_BASE/lib/endorsed;JRE_HOME/lib/endorsed" - addParm(args, "-Djava.endorsed.dirs=\"", runtimeLocation, "/lib/endorsed", pS, vmLibDir.append("endorsed").toOSString(), "\""); + addParm(args, "-Djava.endorsed.dirs=\"$(GERONIMO_HOME)/lib/endorsed", pS, "$(JRE_HOME)/lib/endorsed\""); // Specify the minimum memory options for the Geronimo server addParm(args, "-Xms256m -Xmx512m -XX:MaxPermSize=128m"); // Specify GERONIMO_BASE - addParm(args, "-Dorg.apache.geronimo.home.dir=\"", runtimeLocation, "\""); - + addParm(args, "-Dorg.apache.geronimo.home.dir=\"$(GERONIMO_HOME)\""); + + addParm(args, "-Dkaraf.home=\"$(GERONIMO_HOME)\""); + addParm(args, "-Dkaraf.base=\"$(GERONIMO_HOME)\""); + addParm(args, "-Djava.util.logging.config.file=\"$(GERONIMO_HOME)/etc/java.util.logging.properties\""); + // Karaf arguments addParm(args, getKarafShellArgs()); addParm(args, "-Dkaraf.startRemoteShell=true"); - String serverLocation = getServer().getRuntime().getLocation().toOSString(); - addParm(args, - MessageFormat - .format("-Dorg.apache.geronimo.home.dir=\"{0}\" -Dkaraf.home=\"{0}\" -Dkaraf.base=\"{0}\" -Djava.util.logging.config.file={0}/etc/java.util.logging.properties", - serverLocation)); - - String vmArgs = args.toString(); + String vmArgs = args.toString(); Trace.tracePoint("Exit", "GeronimoServer.getVMArgs", vmArgs); return vmArgs;