[118632] runtimedef file support
diff --git a/plugins/org.eclipse.jst.server.generic.core/plugin.properties b/plugins/org.eclipse.jst.server.generic.core/plugin.properties
index d4fcff6..71d7ea3 100644
--- a/plugins/org.eclipse.jst.server.generic.core/plugin.properties
+++ b/plugins/org.eclipse.jst.server.generic.core/plugin.properties
@@ -14,6 +14,7 @@
 externalLaunchConfigurationTypeName=Generic Server(External Launch)
 launchConfigurationTypeName=Generic Server
 extensionPointServerdefinition=Server definition
+extensionPointRuntimedefinition=Runtime definition
 extensionPointGenericpublisher=Generic Publisher
 # ====================================================================
 
diff --git a/plugins/org.eclipse.jst.server.generic.core/plugin.xml b/plugins/org.eclipse.jst.server.generic.core/plugin.xml
index 723f523..7499e89 100644
--- a/plugins/org.eclipse.jst.server.generic.core/plugin.xml
+++ b/plugins/org.eclipse.jst.server.generic.core/plugin.xml
@@ -3,6 +3,7 @@
 <plugin>
 
  <extension-point id="serverdefinition" name="%extensionPointServerdefinition" schema="schema/serverdefinition.exsd"/>
+ <extension-point id="runtimedefinition" name="%extensionPointRuntimedefinition" schema="schema/runtimedefinition.exsd"/>
  <extension-point id="genericpublisher" name="%extensionPointGenericpublisher" schema="schema/genericpublisher.exsd"/>
 	
  <extension point="org.eclipse.debug.core.launchConfigurationTypes">
diff --git a/plugins/org.eclipse.jst.server.generic.core/schema/runtimedefinition.exsd b/plugins/org.eclipse.jst.server.generic.core/schema/runtimedefinition.exsd
new file mode 100644
index 0000000..93ed0ef
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.generic.core/schema/runtimedefinition.exsd
@@ -0,0 +1,120 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jst.server.generic.core">
+<annotation>
+      <appInfo>
+         <meta.schema plugin="org.eclipse.jst.server.generic.core" id="runtimedefinition" name="Runtime Definition"/>
+      </appInfo>
+      <documentation>
+         This extension point defines a new generic server runtime definition file.
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <complexType>
+         <sequence>
+            <element ref="runtimedefinition" minOccurs="1" maxOccurs="unbounded"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  a fully qualified identifier of the target extension point
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  an optional identifier of the extension instance
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  an optional name of the extension instance
+               </documentation>
+               <appInfo>
+                  <meta.attribute translatable="true"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="runtimedefinition">
+      <complexType>
+         <sequence>
+         </sequence>
+         <attribute name="id" type="string" use="required">
+            <annotation>
+               <documentation>
+                  runtime id
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="definitionfile" type="string" use="required">
+            <annotation>
+               <documentation>
+                  location of the generic server runtime definition file
+               </documentation>
+               <appInfo>
+                  <meta.attribute kind="resource"/>
+               </appInfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="since"/>
+      </appInfo>
+      <documentation>
+         2.0
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="examples"/>
+      </appInfo>
+      <documentation>
+         &lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.jst.server.generic.core.runtimedefinition&quot;&gt;
+  &lt;runtimedefinition id=&quot;org.eclipse.jst.server.generic.runtime.jonas4&quot; definitionfile=&quot;/runtimes/jonas.runtimedef&quot;&gt;
+  &lt;/runtimedefinition&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="apiInfo"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="implementation"/>
+      </appInfo>
+      <documentation>
+         
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appInfo>
+         <meta.section type="copyright"/>
+      </appInfo>
+      <documentation>
+         Copyright (c) 2006 Cape Clear Software. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
+&lt;a href=&quot;http://www.eclipse.org/legal/epl-v10.html&quot;&gt;http://www.eclipse.org/legal/epl-v10.html&lt;/a&gt;
+      </documentation>
+   </annotation>
+
+</schema>
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServer.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServer.java
index 1560268..ce92cbc 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServer.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/GenericServer.java
@@ -16,6 +16,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -30,6 +31,7 @@
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.wst.server.core.IModule;
 import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.IServer;
 import org.eclipse.wst.server.core.ServerPort;
 import org.eclipse.wst.server.core.ServerUtil;
 import org.eclipse.wst.server.core.model.IURLProvider;
@@ -222,8 +224,15 @@
 	 * @return server runtime
 	 */
     public ServerRuntime getServerDefinition(){
-		String rtTypeId = getServer().getRuntime().getRuntimeType().getId();
-		return CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(rtTypeId,getInstanceProperties());
+        IServer server = getServer();
+		String rtTypeId = server.getRuntime().getRuntimeType().getId();
+        String serverTypeId = server.getServerType().getId();
+        /**
+         * Pass both the serverType id and runtimeType id and ServerTypeDefinitionManager 
+         * will figure out how to give us back the correct ServerRuntime.
+         */
+		return CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(
+                serverTypeId, rtTypeId, getInstanceProperties());
 	}
 
     private GenericServerRuntime getRuntimeDelegate(){
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/ServerTypeDefinitionManager.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/ServerTypeDefinitionManager.java
index 7e378df..7b535ec 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/ServerTypeDefinitionManager.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/core/internal/ServerTypeDefinitionManager.java
@@ -17,6 +17,7 @@
 import org.eclipse.core.runtime.IRegistryChangeEvent;
 import org.eclipse.core.runtime.IRegistryChangeListener;
 import org.eclipse.jst.server.generic.internal.core.util.ExtensionPointUtil;
+import org.eclipse.jst.server.generic.internal.core.util.ServerRuntimeMergeUtil;
 import org.eclipse.jst.server.generic.internal.xml.XMLUtils;
 import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime;
 /**
@@ -29,14 +30,23 @@
 {
 	private XMLUtils fXmlUtils;
 	
-	private class RegistryChangeListener implements IRegistryChangeListener{
-		public void registryChanged(IRegistryChangeEvent event) {
-			IExtensionDelta[] deltas = event.getExtensionDeltas(CorePlugin.PLUGIN_ID, ExtensionPointUtil.SERVERDEFINITION_EXTENSION_ID);
-			if(deltas!=null && deltas.length>0){
-				handleServerDefinitionsChanged();
-			}
-		}		
-	}
+	/**
+	 * Watch for changes to serverdefinition and runtimedefinition extensions.
+	 */
+	private class RegistryChangeListener implements IRegistryChangeListener {
+        public void registryChanged(IRegistryChangeEvent event) {
+            IExtensionDelta[] deltas = event.getExtensionDeltas(CorePlugin.PLUGIN_ID, ExtensionPointUtil.SERVERDEFINITION_EXTENSION_ID);
+            if (deltas != null && deltas.length > 0) {
+                handleDefinitionsChanged();
+            }
+            else {
+                deltas = event.getExtensionDeltas(CorePlugin.PLUGIN_ID, ExtensionPointUtil.RUNTIMEDEFINITION_EXTENSION_ID);
+                if (deltas != null && deltas.length > 0) {
+                    handleDefinitionsChanged();
+                }
+            }
+        }
+    }
 	
 	protected ServerTypeDefinitionManager(URL serverDefinitionURL){
 		super();
@@ -44,19 +54,66 @@
 		ExtensionPointUtil.addRegistryListener(new RegistryChangeListener());
 	}
 
-	/**
-	 * Returns the ServerRuntime that represents the .serverdef file
-	 * for a given runtime type.
-	 * @param id runtime type id
-	 * @param properties user provided properties
-	 * @return server runtime that is initialized with user properties 
-	 */
-	public ServerRuntime getServerRuntimeDefinition(String id, Map properties){
-		ServerRuntime definition =  fXmlUtils.getServerTypeDefinition(id);
-		if(definition !=null)
+    /**
+     * Returns either: 
+     * 
+     * 1. the ServerRuntime that represents the .serverdef file for a given 
+     *    runtime type, based on the runtimeTypeId.
+     *    
+     * 2. the ServerRuntime that represents both the .serverdef file for a
+     *    given server type, based on the serverTypeId, combined with the 
+     *    .runtimedef file for the runtime type, based on the runtimeTypeId.   
+     * 
+     * The implementation looks for (1) first, if that combination is not
+     * found, then (2) is returned.
+     * 
+     * @param serverTypeId server type id
+     * @param runtimeTypeId runtime type id
+     * @param properties user provided properties
+     * @return server runtime that is initialized with user properties 
+     */
+    public ServerRuntime getServerRuntimeDefinition(String serverTypeId, String runtimeTypeId, Map properties) {
+        
+        ServerRuntime serverdef = fXmlUtils.getServerTypeDefinition(serverTypeId);
+        
+        if (serverdef != null) {
+            ServerRuntime runtimedef = fXmlUtils.getRuntimeTypeDefinition(runtimeTypeId);
+            serverdef = ServerRuntimeMergeUtil.combine(serverdef, runtimedef);
+        }
+        else {
+            // Fall back to the original usage
+            serverdef = fXmlUtils.getServerTypeDefinition(runtimeTypeId);
+        }
+        
+        if (serverdef != null) {
+            serverdef.setPropertyValues(properties);
+        }
+        
+        return serverdef;
+    }
+    
+    /**
+     * Returns the ServerRuntime that represents the .serverdef file
+     * for a given runtime type.
+     * 
+     * @param runtimeTypeId runtime type id
+     * @param properties user provided properties
+     * @return server runtime that is initialized with user properties 
+     */
+    public ServerRuntime getServerRuntimeDefinition(String runtimeTypeId, Map properties) {
+        ServerRuntime definition = fXmlUtils.getRuntimeTypeDefinition(runtimeTypeId);
+        
+        if (definition == null) {
+            // Fall back to the original usage
+            definition = fXmlUtils.getServerTypeDefinition(runtimeTypeId);
+        }
+        
+        if (definition != null) {
             definition.setPropertyValues(properties);
-		return definition;
-	}
+        }
+        
+        return definition;
+    }
 	
 	/**
 	 * Returns all the ServerRuntimes registered a .serverdef.
@@ -67,7 +124,7 @@
 		 return (ServerRuntime[])definitionList.toArray(new ServerRuntime[definitionList.size()]);
 	}
 	
-	private void handleServerDefinitionsChanged(){	
+	private void handleDefinitionsChanged(){	
 		XMLUtils utils = new XMLUtils();
 		fXmlUtils = utils;
 	}
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java
index cedf0ed..f96bb96 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ExtensionPointUtil.java
@@ -27,15 +27,24 @@
      * serverdefinition extension id
      */
     public static final String SERVERDEFINITION_EXTENSION_ID = "serverdefinition"; //$NON-NLS-1$
+    public static final String RUNTIMEDEFINITION_EXTENSION_ID = "runtimedefinition"; //$NON-NLS-1$
     private static final String GENERICPUBLISHER_EXTENSION_ID = "genericpublisher"; //$NON-NLS-1$
 
     /**
      * Returns serverdefinition extensions
-     * @return serverdefinitionExtensions
+     * @return serverdefinition Extensions
      */
     public static IExtension[] getGenericServerDefinitionExtensions(){
         return getExtensions(CorePlugin.PLUGIN_ID+"."+SERVERDEFINITION_EXTENSION_ID); //$NON-NLS-1$
     }
+
+    /**
+     * Returns runtimedefinition extensions
+     * @return runtimedefinition Extensions
+     */
+    public static IExtension[] getGenericServerRuntimeDefinitionExtensions(){
+        return getExtensions(CorePlugin.PLUGIN_ID+"."+RUNTIMEDEFINITION_EXTENSION_ID); //$NON-NLS-1$
+    }
     
     /**
      * Returns publisher extensions
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java
new file mode 100644
index 0000000..ad24b6d
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/core/util/ServerRuntimeMergeUtil.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright (c) 2006 Cape Clear Software. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.eclipse.jst.server.generic.internal.core.util;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jst.server.generic.servertype.definition.Classpath;
+import org.eclipse.jst.server.generic.servertype.definition.Property;
+import org.eclipse.jst.server.generic.servertype.definition.ServerRuntime;
+
+/**
+ * Combines a runtimedef files
+ * 
+ * - properties
+ * - classpaths
+ * 
+ * entries with a serverdef, if the serverdef does not already have 
+ * them - contains check is done by id.
+ * 
+ * @author <a href="mailto:david.black@capeclear.com">David Black</a>
+ */
+public class ServerRuntimeMergeUtil {
+
+    /**
+     * Combines a runtime definition and a server definition 
+     * into a single logical <code>ServerRuntime</code>.
+     * 
+     * @param serverdef
+     * @param runtimedef
+     * @return serverdef
+     */
+    public static ServerRuntime combine(ServerRuntime serverdef, ServerRuntime runtimedef) {
+        /** 
+         * Add properties from runtimedef to serverdef if not already present,
+         * this ensures that:
+         * 
+         * (1) while we are affecting the cached copy of serverdef, it is always
+         *     required to be combined with its runtimedef (if there is one), and
+         *     we check that the property has not already been added
+         *     
+         * (2) serverdef properties can override runtimedef properties    
+         */
+        List properties = runtimedef.getProperty();
+        if (properties != null) {
+            Iterator iter = properties.iterator();
+            while (iter.hasNext()) {
+                Property prop = (Property) iter.next();
+                addPropertyIfNotPresent(serverdef.getProperty(), prop);
+            }
+        }
+        
+        /** 
+         * Add classpaths from runtimedef to serverdef if not already present,
+         * this ensures that:
+         * 
+         * (1) while we are affecting the cached copy of serverdef, it is always
+         *     required to be combined with its runtimedef (if there is one), and
+         *     we check that the classpath has not already been added (by id)
+         *     
+         * (2) serverdef classpath can override runtimedef classpath by id    
+         */
+        List classpaths = runtimedef.getClasspath();
+        if (classpaths != null) {
+            Iterator iter = classpaths.iterator();
+            while (iter.hasNext()) {
+                Classpath classpath = (Classpath)iter.next();
+                addClasspathIfNotPresent(serverdef.getClasspath(), classpath);
+            }
+        }
+        
+        return serverdef;
+    }
+
+    private static void addClasspathIfNotPresent(List classpaths, Classpath classpath) {
+        if (!containsClasspath(classpaths, classpath.getId())) {
+            classpaths.add(classpath);
+        }
+    }
+
+    private static boolean containsClasspath(List properties, String id) {
+        boolean found = false;
+        Iterator iter = properties.iterator();
+        while (iter.hasNext()) {
+            Classpath classpath = (Classpath) iter.next();
+            if (classpath.getId().equals(id)) {
+                found = true;
+                break;
+            }
+        }
+        return found;
+    }
+    
+    private static void addPropertyIfNotPresent(List properties, Property prop) {
+        if (!containsProperty(properties, prop.getId())) {
+            properties.add(prop);
+        }
+    }
+
+    private static boolean containsProperty(List properties, String id) {
+        boolean found = false;
+        Iterator iter = properties.iterator();
+        while (iter.hasNext()) {
+            Property prop = (Property) iter.next();
+            if (prop.getId().equals(id)) {
+                found = true;
+                break;
+            }
+        }
+        return found;
+    }
+
+}
diff --git a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/xml/XMLUtils.java b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/xml/XMLUtils.java
index 247d777..94d0bd1 100644
--- a/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/xml/XMLUtils.java
+++ b/plugins/org.eclipse.jst.server.generic.core/src/org/eclipse/jst/server/generic/internal/xml/XMLUtils.java
@@ -14,6 +14,8 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
+
 import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.core.runtime.IExtension;
 import org.eclipse.core.runtime.IStatus;
@@ -33,14 +35,15 @@
 import org.osgi.framework.Bundle;
 
 /**
- * Utility for handling the xml data from .serverdef files
+ * Utility for handling the xml data from .serverdef and .runtimedef files.
  * 
  * @author Gorkem Ercan
  */
 public class XMLUtils {
 
 	
-    private ArrayList definitions;
+    private ArrayList serverDefinitions;
+    private ArrayList runtimeDefinitions;
 
 
 	/**
@@ -50,28 +53,52 @@
 		refresh();
 	}
 
+	/**
+	 * Load all the serverdefinition and runtimedefinition extensions.
+	 */
 	private void refresh() {
-		definitions= new ArrayList();
-         IExtension[] extensions = ExtensionPointUtil.getGenericServerDefinitionExtensions();
-        for (int i = 0; extensions!=null && i < extensions.length; i++) {
-            java.net.URI definitionFile=null;
-            IExtension extension = extensions[i];
+        serverDefinitions = new ArrayList();
+        
+        IExtension[] serverDefExtensions = ExtensionPointUtil.getGenericServerDefinitionExtensions();
+        
+        for (int i = 0; serverDefExtensions != null && i < serverDefExtensions.length; i++) {
+            java.net.URI definitionFile = null;
+            IExtension extension = serverDefExtensions[i];
             IConfigurationElement[] elements = ExtensionPointUtil.getConfigurationElements(extension);
+            
             for (int j = 0; j < elements.length; j++) {
                 IConfigurationElement element = elements[j];
                 definitionFile = getDefinitionFile(element);
-                ServerRuntime runtime =readFile(definitionFile);
-                    if(runtime!=null){
-                        runtime.setId(element.getAttribute("id")); //$NON-NLS-1$
-                        runtime.setConfigurationElementNamespace(element.getNamespace());
-                        definitions.add(runtime);
-                    }
+                ServerRuntime runtime = readFile(definitionFile);
+                if (runtime != null) {
+                    runtime.setId(element.getAttribute("id")); //$NON-NLS-1$
+                    runtime.setConfigurationElementNamespace(element.getNamespace());
+                    serverDefinitions.add(runtime);
                 }
             }
+        }
 
-       }
-
-
+        runtimeDefinitions = new ArrayList();
+        
+        IExtension[] runtimeDefExtensions = ExtensionPointUtil.getGenericServerRuntimeDefinitionExtensions();
+        
+        for (int i = 0; runtimeDefExtensions != null && i < runtimeDefExtensions.length; i++) {
+            java.net.URI definitionFile = null;
+            IExtension extension = runtimeDefExtensions[i];
+            IConfigurationElement[] elements = ExtensionPointUtil.getConfigurationElements(extension);
+            
+            for (int j = 0; j < elements.length; j++) {
+                IConfigurationElement element = elements[j];
+                definitionFile = getDefinitionFile(element);
+                ServerRuntime runtime = readFile(definitionFile);
+                if (runtime != null) {
+                    runtime.setId(element.getAttribute("id")); //$NON-NLS-1$
+                    runtime.setConfigurationElementNamespace(element.getNamespace());
+                    runtimeDefinitions.add(runtime);
+                }
+            }
+        }
+    }
 
     private java.net.URI getDefinitionFile(IConfigurationElement element) {
         
@@ -126,12 +153,11 @@
 
     }
 
-
 	/**
-	 * @return ArrayList
+	 * @return <code>java.util.List</code> of <code>ServerRuntime</code>s.
 	 */
-	public ArrayList getServerTypeDefinitions() {
-		return definitions;
+	public List getServerTypeDefinitions() {
+		return serverDefinitions;
 	}
 
     /**
@@ -141,6 +167,28 @@
      */
     public ServerRuntime getServerTypeDefinition(String id) {
     	Iterator defs = getServerTypeDefinitions().iterator();
+        while (id != null && defs.hasNext()) {
+            ServerRuntime elem = (ServerRuntime) defs.next();
+            if (id.equals(elem.getId()))
+                return elem;
+        }
+        return null;
+    }
+
+    /**
+     * @return <code>java.util.List</code> of <code>ServerRuntime</code>s.
+     */
+    public List getRuntimeTypeDefinitions() {
+        return runtimeDefinitions;
+    }
+
+    /**
+     * Get the memory presentation for the .runtimedef file
+     * @param id
+     * @return runtime 
+     */
+    public ServerRuntime getRuntimeTypeDefinition(String id) {
+        Iterator defs = getRuntimeTypeDefinitions().iterator();
         while (defs.hasNext()) {
             ServerRuntime elem = (ServerRuntime) defs.next();
             if (id.equals(elem.getId()))
diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java
index f340557..50834ed 100644
--- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java
+++ b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/GenericServerWizardFragment.java
@@ -69,13 +69,14 @@
             runtime= (GenericServerRuntime)wc.getAdapter(GenericServerRuntime.class);
             if(runtime==null)
             	runtime= (GenericServerRuntime)wc.loadAdapter(GenericServerRuntime.class,new NullProgressMonitor());
-        }        
-        String id = runtime.getRuntime().getRuntimeType().getId();
-        if(id==null){   
+        }
+        String serverTyepId = server.getServerType().getId();
+        String runtimeTypeId = runtime.getRuntime().getRuntimeType().getId();
+        if(runtimeTypeId==null){   
             return null;
         }
         Map runtimeProperties = runtime.getServerInstanceProperties();
-		ServerRuntime definition = getServerTypeDefinition(id,runtimeProperties);
+		ServerRuntime definition = getServerTypeDefinition(serverTyepId, runtimeTypeId, runtimeProperties);
         return definition;
     }
 
diff --git a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java
index 1a910d1..1132884 100644
--- a/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java
+++ b/plugins/org.eclipse.jst.server.generic.ui/src/org/eclipse/jst/server/generic/ui/internal/ServerDefinitionTypeAwareWizardFragment.java
@@ -77,4 +77,18 @@
 	{
 	    return CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(definitionID,properties);
 	}
+
+    /**
+     * Retuns the ServerRuntime.
+     * @param serverTypeId
+     * @param runtimeTypeId
+     * @param properties
+     * @return
+     */ 
+    protected ServerRuntime getServerTypeDefinition(String serverTypeId, String runtimeTypeId, Map properties)
+    {
+        return CorePlugin.getDefault().getServerTypeDefinitionManager().getServerRuntimeDefinition(serverTypeId, runtimeTypeId, properties);
+    }
+
 }
+