You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2011/05/12 18:04:30 UTC

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

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;