Trace cleanup and removing JDT internal references
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/JavaSourceLookupUtil.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/JavaSourceLookupUtil.java
new file mode 100644
index 0000000..3dc381b
--- /dev/null
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/JavaSourceLookupUtil.java
@@ -0,0 +1,207 @@
+/**********************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.jst.server.tomcat.core.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer;
+import org.eclipse.jdt.core.IJavaModel;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
+import org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer;
+import org.eclipse.jdt.launching.sourcelookup.containers.PackageFragmentRootSourceContainer;
+/**
+ * Java source lookup utility. Taken directly from
+ * org.eclipse.jdt.internal.launching.JavaSourceLookupUtil since it is private.
+ */
+public class JavaSourceLookupUtil {
+	/**
+	 * Translates the given runtime classpath entries into associated source
+	 * containers.
+	 * 
+	 * @param entries entries to translate
+	 * @param considerSourceAttachments whether to consider source attachments
+	 *  when comparing against existing packagr fragment roots
+	 */
+	public static ISourceContainer[] translate(IRuntimeClasspathEntry[] entries, boolean considerSourceAttachments) {
+		List containers = new ArrayList(entries.length);
+		for (int i = 0; i < entries.length; i++) {
+			IRuntimeClasspathEntry entry = entries[i];
+			switch (entry.getType()) {
+				case IRuntimeClasspathEntry.ARCHIVE:
+					IPackageFragmentRoot root = getPackageFragmentRoot(entry, considerSourceAttachments);
+					String path = entry.getSourceAttachmentLocation();
+					if (root == null && path == null && considerSourceAttachments) {
+						// use the pkg frag root it there is no source attachment
+						root = getPackageFragmentRoot(entry, false);
+					}
+					if (root == null) {
+						ISourceContainer container = null;
+						if (path == null) {
+							// use the archive itself
+							container = new ExternalArchiveSourceContainer(entry.getLocation(), true);
+						} else {
+							container = new ExternalArchiveSourceContainer(path, true);
+
+						}
+						if (!containers.contains(container)) {
+							containers.add(container);
+						}
+					} else {
+						ISourceContainer container = new PackageFragmentRootSourceContainer(root);
+						if (!containers.contains(container)) {
+							containers.add(container);
+						}
+					}
+					break;
+				case IRuntimeClasspathEntry.PROJECT:
+					IResource resource = entry.getResource();
+					if (resource != null && resource.getType() == IResource.PROJECT) {
+						ISourceContainer container = new JavaProjectSourceContainer(JavaCore.create((IProject)resource));
+						if (!containers.contains(container)) {
+							containers.add(container);
+						}
+					}
+					break;
+				default:
+					// no other classpath types are valid in a resolved path
+					break;
+			}
+		}
+		return (ISourceContainer[]) containers.toArray(new ISourceContainer[containers.size()]);
+	}
+	
+	/**
+	 * Returns whether the given objects are equal, allowing
+	 * for <code>null</code>.
+	 * 
+	 * @param a
+	 * @param b
+	 * @return whether the given objects are equal, allowing
+	 *   for <code>null</code>
+	 */
+	private static boolean equalOrNull(Object a, Object b) {
+		if (a == null) {
+			return b == null;
+		}
+		if (b == null) {
+			return false;
+		}
+		return a.equals(b);
+	}
+	
+	/**
+	 * Returns whether the source attachments of the given package fragment
+	 * root and runtime classpath entry are equal.
+	 * 
+	 * @param root package fragment root
+	 * @param entry runtime classpath entry
+	 * @return whether the source attachments of the given package fragment
+	 * root and runtime classpath entry are equal
+	 * @throws JavaModelException 
+	 */
+	private static boolean isSourceAttachmentEqual(IPackageFragmentRoot root, IRuntimeClasspathEntry entry) throws JavaModelException {
+		return equalOrNull(root.getSourceAttachmentPath(), entry.getSourceAttachmentPath());
+	}
+	
+	/**
+	 * Determines if the given archive runtime classpath entry exists
+	 * in the workspace as a package fragment root. Returns the associated
+	 * package fragment root possible, otherwise
+	 * <code>null</code>.
+	 *  
+	 * @param entry archive runtime classpath entry
+	 * @param considerSourceAttachment whether the source attachments should be
+	 *  considered comparing against package fragment roots
+	 * @return package fragment root or <code>null</code>
+	 */
+	private static IPackageFragmentRoot getPackageFragmentRoot(IRuntimeClasspathEntry entry, boolean considerSourceAttachment) {
+		IResource resource = entry.getResource();
+		if (resource == null) { 
+			// Check all package fragment roots for case of external archive.
+			// External jars are shared, so it does not matter which project it
+			// originates from
+			IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+			try {
+				IJavaProject[] jps = model.getJavaProjects();
+				for (int i = 0; i < jps.length; i++) {
+					IJavaProject jp = jps[i];
+					IProject p =  jp.getProject();
+					if (p.isOpen()) {
+						IPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();
+						for (int j = 0; j < allRoots.length; j++) {
+							IPackageFragmentRoot root = allRoots[j];
+							if (root.isExternal() && root.getPath().equals(new Path(entry.getLocation()))) {
+								if (!considerSourceAttachment || isSourceAttachmentEqual(root, entry)) {
+									// use package fragment root
+									return root;
+								}							
+							}
+						}
+					}
+				}
+			} catch (JavaModelException e) {
+				TomcatPlugin.log(e);
+			}
+		} else {
+			// check if the archive is a package fragment root
+			IProject project = resource.getProject();
+			IJavaProject jp = JavaCore.create(project);
+			try {
+				if (project.isOpen() && jp.exists()) {
+					IPackageFragmentRoot root = jp.getPackageFragmentRoot(resource);
+					IPackageFragmentRoot[] allRoots = jp.getPackageFragmentRoots();
+					for (int j = 0; j < allRoots.length; j++) {
+						if (allRoots[j].equals(root)) {
+							// ensure source attachment paths match
+							if (!considerSourceAttachment || isSourceAttachmentEqual(root, entry)) {
+								// use package fragment root
+								return root;
+							}
+						}
+					}
+
+				}
+				// check all other java projects to see if another project references
+				// the archive
+				IJavaModel model = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot());
+				IJavaProject[] jps = model.getJavaProjects();
+				for (int i = 0; i < jps.length; i++) {
+					IJavaProject jp1 = jps[i];
+					IProject p = jp1.getProject();
+					if (p.isOpen()) {
+						IPackageFragmentRoot[] allRoots = jp1.getPackageFragmentRoots();
+						for (int j = 0; j < allRoots.length; j++) {
+							IPackageFragmentRoot root = allRoots[j];
+							if (!root.isExternal() && root.getPath().equals(entry.getPath())) {
+								if (!considerSourceAttachment || isSourceAttachmentEqual(root, entry)) {
+									// use package fragment root
+									return root;
+								}							
+							}
+						}
+					}
+				}
+			} catch (JavaModelException e) {
+				TomcatPlugin.log(e);
+			}		
+		}		
+		return null;
+	}
+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
index dc4a79c..603dd76 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat40Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -169,7 +169,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error getting server ports", e);
+			Trace.trace(Trace.SEVERE, "Error getting server ports", e);
 		}
 		return ports;
 	}
@@ -202,7 +202,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error getting modules", e);
+			Trace.trace(Trace.SEVERE, "Error getting modules", e);
 		}
 		return list;
 	}
@@ -369,7 +369,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v4.0 configuration to " + path, e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.0 configuration to " + path, e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -428,7 +428,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v4.0 configuration to " + folder.toString(), e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.0 configuration to " + folder.toString(), e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -467,7 +467,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error adding web module " + module.getPath(), e);
+			Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
 		}
 	}
 	
@@ -504,7 +504,7 @@
 			if (!monitor.isCanceled())
 				monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Error localizing configuration", e);
+			Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
 		}
 	}
 	
@@ -564,7 +564,7 @@
 			isServerDirty = true;
 			firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
 		} catch (Exception e) {
-			Trace.trace("Error modifying server port " + id, e);
+			Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
 		}
 	}
 	/**
@@ -593,7 +593,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error modifying web module " + index, e);
+			Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
 		}
 	}
 	
@@ -625,7 +625,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error removing module ref " + index, e);
+			Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
 		}
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
index aad0c74..1ea5ebb 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat41Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -206,7 +206,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error getting project refs", e);
+			Trace.trace(Trace.SEVERE, "Error getting project refs", e);
 		}
 		return list;
 	}
@@ -373,7 +373,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v4.1 configuration to " + path, e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.1 configuration to " + path, e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -432,7 +432,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v4.1 configuration to " + folder.toString(), e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v4.1 configuration to " + folder.toString(), e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -487,7 +487,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error adding web module " + module.getPath(), e);
+			Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
 		}
 	}
 
@@ -523,7 +523,7 @@
 			if (!monitor.isCanceled())
 				monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Error localizing configuration", e);
+			Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
 		}
 	}
 	
@@ -583,7 +583,7 @@
 			isServerDirty = true;
 			firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
 		} catch (Exception e) {
-			Trace.trace("Error modifying server port " + id, e);
+			Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
 		}
 	}
 	/**
@@ -612,7 +612,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error modifying web module " + index, e);
+			Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
 		}
 	}
 
@@ -644,13 +644,13 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error removing module ref " + index, e);
+			Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
 		}
 	}
 
 	protected IStatus backupAndPublish(IPath confDir, boolean doBackup, IProgressMonitor monitor) {
 		MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%publishConfigurationTask"), null);
-		Trace.trace("Backup and publish");
+		Trace.trace(Trace.FINER, "Backup and publish");
 		monitor = ProgressUtil.getMonitorFor(monitor);
 
 		backupAndPublish(confDir, doBackup, ms, monitor, 300);
@@ -665,7 +665,7 @@
 	}
 	
 	protected void publishContextConfig(IPath confDir, MultiStatus ms, IProgressMonitor monitor) {
-		Trace.trace("Apply context configurations");
+		Trace.trace(Trace.FINER, "Apply context configurations");
 		try {
 			confDir = confDir.append("conf");
 			
@@ -701,7 +701,7 @@
 			}
 			monitor.worked(100);
 			
-			Trace.trace("Server.xml updated with context.xml configurations");
+			Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
 			ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%serverPostProcessingComplete"), null));
 		} catch (Exception e) {
 			Trace.trace(Trace.WARNING, "Could not apply context configurations published Tomcat v5.0 configuration from " + confDir.toOSString() + ": " + e.getMessage());
@@ -756,7 +756,7 @@
 			} catch (FileNotFoundException e) {
 				// Ignore, should never occur
 			} catch (IOException e) {
-				Trace.trace("Error reading web module's context.xml file: " + docBase, e);
+				Trace.trace(Trace.SEVERE, "Error reading web module's context.xml file: " + docBase, e);
 			}
 		}
 		return null;
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
index 3f0532c..f7fe860 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat50Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -185,7 +185,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error getting project refs", e);
+			Trace.trace(Trace.SEVERE, "Error getting project refs", e);
 		}
 		return list;
 	}
@@ -352,7 +352,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v5.0 configuration to " + path, e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.0 configuration to " + path, e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -411,7 +411,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v5.0 configuration to " + folder.toString(), e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.0 configuration to " + folder.toString(), e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -466,7 +466,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error adding web module " + module.getPath(), e);
+			Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
 		}
 	}
 
@@ -502,7 +502,7 @@
 			if (!monitor.isCanceled())
 				monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Error localizing configuration", e);
+			Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
 		}
 	}
 	
@@ -562,7 +562,7 @@
 			isServerDirty = true;
 			firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
 		} catch (Exception e) {
-			Trace.trace("Error modifying server port " + id, e);
+			Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
 		}
 	}
 	/**
@@ -591,7 +591,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error modifying web module " + index, e);
+			Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
 		}
 	}
 
@@ -623,13 +623,13 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error removing module ref " + index, e);
+			Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
 		}
 	}
 
 	protected IStatus backupAndPublish(IPath confDir, boolean doBackup, IProgressMonitor monitor) {
 		MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%publishConfigurationTask"), null);
-		Trace.trace("Backup and publish");
+		Trace.trace(Trace.FINER, "Backup and publish");
 		monitor = ProgressUtil.getMonitorFor(monitor);
 
 		backupAndPublish(confDir, doBackup, ms, monitor, 300);
@@ -644,7 +644,7 @@
 	}
 	
 	protected void publishContextConfig(IPath confDir, MultiStatus ms, IProgressMonitor monitor) {
-		Trace.trace("Apply context configurations");
+		Trace.trace(Trace.FINER, "Apply context configurations");
 		try {
 			confDir = confDir.append("conf");
 			
@@ -680,7 +680,7 @@
 			}
 			monitor.worked(100);
 			
-			Trace.trace("Server.xml updated with context.xml configurations");
+			Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
 			ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%serverPostProcessingComplete"), null));
 		} catch (Exception e) {
 			Trace.trace(Trace.WARNING, "Could not apply context configurations published Tomcat v5.0 configuration from " + confDir.toOSString() + ": " + e.getMessage());
@@ -735,7 +735,7 @@
 			} catch (FileNotFoundException e) {
 				// Ignore, should never occur
 			} catch (IOException e) {
-				Trace.trace("Error reading web module's context.xml file: " + docBase, e);
+				Trace.trace(Trace.SEVERE, "Error reading web module's context.xml file: " + docBase, e);
 			}
 		}
 		return null;
@@ -804,7 +804,7 @@
 						if (contextFile.exists()) {
 							subMonitor.subTask(TomcatPlugin.getResource("%deletingContextFile", fileName));
 							if (contextFile.delete()) {
-								Trace.trace("Leftover context file " + fileName + " deleted.");
+								Trace.trace(Trace.FINER, "Leftover context file " + fileName + " deleted.");
 								ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0,
 										TomcatPlugin.getResource("%deletedContextFile", fileName), null));
 								
@@ -825,7 +825,7 @@
 			else {
 				monitor.worked(200);
 			}
-			Trace.trace("Server cleaned");
+			Trace.trace(Trace.FINER, "Server cleaned");
 		} catch (Exception e) {
 			Trace.trace(Trace.SEVERE, "Could not cleanup server at " + confDir.toOSString() + ": " + e.getMessage());
 			ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0,
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
index 87fe6ff..ef0f4d1 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat55Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -183,7 +183,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error getting project refs", e);
+			Trace.trace(Trace.SEVERE, "Error getting project refs", e);
 		}
 		return list;
 	}
@@ -350,7 +350,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v5.5 configuration to " + path, e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.5 configuration to " + path, e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -409,7 +409,7 @@
 				return;
 			monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Could not save Tomcat v5.5 configuration to " + folder.toString(), e);
+			Trace.trace(Trace.SEVERE, "Could not save Tomcat v5.5 configuration to " + folder.toString(), e);
 			throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorCouldNotSaveConfiguration", new String[] {e.getLocalizedMessage()}), e));
 		}
 	}
@@ -464,7 +464,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error adding web module " + module.getPath(), e);
+			Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
 		}
 	}
 
@@ -500,7 +500,7 @@
 			if (!monitor.isCanceled())
 				monitor.done();
 		} catch (Exception e) {
-			Trace.trace("Error localizing configuration", e);
+			Trace.trace(Trace.SEVERE, "Error localizing configuration", e);
 		}
 	}
 	
@@ -560,7 +560,7 @@
 			isServerDirty = true;
 			firePropertyChangeEvent(MODIFY_PORT_PROPERTY, id, new Integer(port));
 		} catch (Exception e) {
-			Trace.trace("Error modifying server port " + id, e);
+			Trace.trace(Trace.SEVERE, "Error modifying server port " + id, e);
 		}
 	}
 	/**
@@ -589,7 +589,7 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error modifying web module " + index, e);
+			Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
 		}
 	}
 
@@ -621,13 +621,13 @@
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error removing module ref " + index, e);
+			Trace.trace(Trace.SEVERE, "Error removing module ref " + index, e);
 		}
 	}
 
 	protected IStatus backupAndPublish(IPath confDir, boolean doBackup, IProgressMonitor monitor) {
 		MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%publishConfigurationTask"), null);
-		Trace.trace("Backup and publish");
+		Trace.trace(Trace.FINER, "Backup and publish");
 		monitor = ProgressUtil.getMonitorFor(monitor);
 
 		backupAndPublish(confDir, doBackup, ms, monitor, 300);
@@ -642,7 +642,7 @@
 	}
 	
 	protected void publishContextConfig(IPath confDir, MultiStatus ms, IProgressMonitor monitor) {
-		Trace.trace("Apply context configurations");
+		Trace.trace(Trace.FINER, "Apply context configurations");
 		try {
 			confDir = confDir.append("conf");
 			
@@ -678,7 +678,7 @@
 			}
 			monitor.worked(100);
 			
-			Trace.trace("Server.xml updated with context.xml configurations");
+			Trace.trace(Trace.FINER, "Server.xml updated with context.xml configurations");
 			ms.add(new Status(IStatus.OK, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%serverPostProcessingComplete"), null));
 		} catch (Exception e) {
 			Trace.trace(Trace.WARNING, "Could not apply context configurations published Tomcat v5.0 configuration from " + confDir.toOSString() + ": " + e.getMessage());
@@ -733,7 +733,7 @@
 			} catch (FileNotFoundException e) {
 				// Ignore, should never occur
 			} catch (IOException e) {
-				Trace.trace("Error reading web module's context.xml file: " + docBase, e);
+				Trace.trace(Trace.SEVERE, "Error reading web module's context.xml file: " + docBase, e);
 			}
 		}
 		return null;
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
index 290f627..34a0c5f 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatConfiguration.java
@@ -75,7 +75,7 @@
 	 */
 	protected IStatus backupAndPublish(IPath confDir, boolean doBackup, IProgressMonitor monitor) {
 		MultiStatus ms = new MultiStatus(TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%publishConfigurationTask"), null);
-		Trace.trace("Backup and publish");
+		Trace.trace(Trace.FINER, "Backup and publish");
 		monitor = ProgressUtil.getMonitorFor(monitor);
 
 		backupAndPublish(confDir, doBackup, ms, monitor, 0);
@@ -106,7 +106,7 @@
 				backupFolder(getFolder(), confDir, backup, ms, monitor, additionalWork);
 			//}
 		} catch (Exception e) {
-			Trace.trace("backupAndPublish() error", e);
+			Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
 			IStatus s = new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorPublishConfiguration", new String[] {e.getLocalizedMessage()}), e);
 			ms.add(s);
 		}
@@ -141,7 +141,7 @@
 						ms.add(FileUtil.copyFile(in, confDir.append(name).toOSString()));
 					}
 				} catch (Exception e) {
-					Trace.trace("backupAndPublish() error", e);
+					Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
 					ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorPublishConfiguration", new String[] {e.getLocalizedMessage()}), e));
 				}
 			}
@@ -175,7 +175,7 @@
 				if (copy)
 					ms.add(FileUtil.copyFile(file.getAbsolutePath(), confDir.append(name).toOSString()));
 			} catch (Exception e) {
-				Trace.trace("backupAndPublish() error", e);
+				Trace.trace(Trace.SEVERE, "backupAndPublish() error", e);
 				ms.add(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorPublishConfiguration", new String[] {e.getLocalizedMessage()}), e));
 			}
 			monitor.worked(100);
@@ -278,11 +278,11 @@
 					PropertyChangeListener listener = (PropertyChangeListener) iterator.next();
 					listener.propertyChange(event);
 				} catch (Exception e) {
-					Trace.trace("Error firing property change event", e);
+					Trace.trace(Trace.SEVERE, "Error firing property change event", e);
 				}
 			}
 		} catch (Exception e) {
-			Trace.trace("Error in property event", e);
+			Trace.trace(Trace.SEVERE, "Error in property event", e);
 		}
 	}
 
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
index 62c22ba..3b45118 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatRuntime.java
@@ -11,7 +11,6 @@
 package org.eclipse.jst.server.tomcat.core.internal;
 
 import java.io.File;
-import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.HashMap;
 import java.util.List;
@@ -20,15 +19,15 @@
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.ILaunchManager;
 import org.eclipse.debug.core.Launch;
-import org.eclipse.debug.core.model.IProcess;
 import org.eclipse.debug.core.model.IStreamsProxy;
-import org.eclipse.jdt.internal.launching.StandardVMType;
 import org.eclipse.jdt.launching.IVMInstall;
 import org.eclipse.jdt.launching.IVMInstallType;
+import org.eclipse.jdt.launching.IVMRunner;
 import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
 import org.eclipse.jst.server.tomcat.core.ITomcatRuntime;
 import org.eclipse.jst.server.tomcat.core.ITomcatRuntimeWorkingCopy;
 
@@ -103,7 +102,7 @@
 	
 		if (!verifyLocation())
 			return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorInstallDir"), null);
-		else if (getVMInstall() == null)
+		if (getVMInstall() == null)
 			return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%errorJRE"), null);
 
 		// check for tools.jar (contains the javac compiler on Windows & Linux) to see whether
@@ -119,7 +118,7 @@
 		// on Mac, tools.jar is merged into classes.zip. if tools.jar wasn't found,
 		// try loading the javac class by running a check inside the VM
 		if (!found)
-			found = checkForCompiler(getVMInstall().getInstallLocation());
+			found = checkForCompiler();
 		
 		if (!found)
 			return new Status(IStatus.WARNING, TomcatPlugin.PLUGIN_ID, 0, TomcatPlugin.getResource("%warningJRE"), null);
@@ -163,8 +162,9 @@
 	 * 
 	 * @return true if the compiler was found
 	 */	
-	protected boolean checkForCompiler(File javaHome) {
+	protected boolean checkForCompiler() {
 		// first try the cache
+		File javaHome = getVMInstall().getInstallLocation();
 		try {
 			Boolean b = (Boolean) sdkMap.get(javaHome);
 			return b.booleanValue();
@@ -174,17 +174,16 @@
 
 		// locate tomcatcore.jar - it contains the class detector main program
 		File file = TomcatPlugin.getFileInPlugin(new Path("tomcatcore.jar"));
-		if (file != null && file.exists()) {	
-			File javaExecutable = StandardVMType.findJavaExecutable(javaHome);
-			String javaExecutablePath = javaExecutable.getAbsolutePath();
-			String[] cmdLine = new String[] {javaExecutablePath, "-classpath", file.getAbsolutePath(), "org.eclipse.jst.server.tomcat.core.internal.ClassDetector", "com.sun.tools.javac.Main"};
-			Process p = null;
+		if (file != null && file.exists()) {
+			IVMRunner vmRunner = getVMInstall().getVMRunner(ILaunchManager.RUN_MODE);
+			VMRunnerConfiguration config = new VMRunnerConfiguration("org.eclipse.jst.server.tomcat.core.internal.ClassDetector", new String[] { file.getAbsolutePath() });
+			config.setProgramArguments(new String[] { "com.sun.tools.javac.Main" });
+			ILaunch launch = new Launch(null, ILaunchManager.RUN_MODE, null);
 			try {
-				p = Runtime.getRuntime().exec(cmdLine);
-				IProcess process = DebugPlugin.newProcess(new Launch(null, ILaunchManager.RUN_MODE, null), p, "Compiler Detection");
-				for (int i= 0; i < 200; i++) {
+				vmRunner.run(config, launch, null);
+				for (int i = 0; i < 200; i++) {
 					// wait no more than 10 seconds (200 * 50 mils)
-					if (process.isTerminated()) {
+					if (launch.isTerminated()) {
 						break;
 					}
 					try {
@@ -193,7 +192,7 @@
 						// ignore
 					}
 				}
-				IStreamsProxy streamsProxy = process.getStreamsProxy();
+				IStreamsProxy streamsProxy = launch.getProcesses()[0].getStreamsProxy();
 				String text = null;
 				if (streamsProxy != null) {
 					text = streamsProxy.getOutputStreamMonitor().getContents();
@@ -207,11 +206,15 @@
 						return found;
 					}
 				}
-			} catch (IOException ioe) {
-				TomcatPlugin.log(ioe);
+			} catch (Exception e) {
+				Trace.trace(Trace.SEVERE, "Error checking for JDK", e);
 			} finally {
-				if (p != null) {
-					p.destroy();
+				if (!launch.isTerminated()) {
+					try {
+						launch.terminate();
+					} catch (Exception ex) {
+						// ignore
+					}
 				}
 			}
 		}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java
index 0216e1c..46773a5 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatSourcePathComputerDelegate.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2004 IBM Corporation and others.
+ * Copyright (c) 2004, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -21,7 +21,6 @@
 import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
 import org.eclipse.jdt.core.IJavaProject;
 import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.launching.JavaSourceLookupUtil;
 import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
 import org.eclipse.jdt.launching.JavaRuntime;
 import org.eclipse.wst.server.core.*;
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
index 7632320..6bf574b 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Trace.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
+ * Copyright (c) 2003, 2005 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Common Public License v1.0
  * which accompanies this distribution, and is available at
@@ -49,23 +49,4 @@
 		if (t != null)
 			t.printStackTrace();
 	}
-	
-	/**
-	 * Trace the given text.
-	 *
-	 * @param s java.lang.String
-	 */
-	public static void trace(String s) {
-		trace(s, null);
-	}
-	
-	/**
-	 * Trace the given exception.
-	 *
-	 * @param s java.lang.String
-	 * @param e java.lang.Throwable
-	 */
-	public static void trace(String s, Throwable t) {
-		trace(FINEST, s, t);
-	}
 }
\ No newline at end of file