[333102] Fix annotation support in Tomcat 7.0's "Serve modules without publishing" feature.
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader-src.zip b/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader-src.zip
index 3285035..f65c0f0 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader-src.zip
+++ b/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader-src.zip
Binary files differ
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader.jar b/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader.jar
index ada3130..eab0716 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader.jar
+++ b/plugins/org.eclipse.jst.server.tomcat.core/org.eclipse.jst.server.tomcat.runtime.70.loader.jar
Binary files differ
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 77218d1..0d48d4f 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, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
  * 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
@@ -642,11 +642,12 @@
 	 * publishing.
 	 * 
 	 * @param baseDir path to catalina instance directory
+	 * @param homeDir path to catalina install directory
 	 * @param monitor a progress monitor or null
 	 * @return result of operation
 	 */
-	protected IStatus updateContextsToServeDirectly(IPath baseDir, String loader, IProgressMonitor monitor) {
-		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, loader, false, monitor);
+	protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
+		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
 	}
 
 	/**
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 a773860..8dfadfa 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, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
  * 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
@@ -682,8 +682,8 @@
 	 * @param monitor a progress monitor or null
 	 * @return result of operation
 	 */
-	protected IStatus updateContextsToServeDirectly(IPath baseDir, String loader, IProgressMonitor monitor) {
-		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, loader, false, monitor);
+	protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
+		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
 	}
 
 	/**
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java
index 030669d..89550ba 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat60Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2007, 2010 IBM Corporation and others.
+ * Copyright (c) 2007, 2011 IBM Corporation and others.
  * 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
@@ -682,8 +682,8 @@
 	 * @param monitor a progress monitor or null
 	 * @return result of operation
 	 */
-	protected IStatus updateContextsToServeDirectly(IPath baseDir, String loader, IProgressMonitor monitor) {
-		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, loader, false, monitor);
+	protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
+		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, false, monitor);
 	}
 
 	/**
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java
index 675c4ab..a0af5f1 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/Tomcat70Configuration.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
+ * Copyright (c) 2011 IBM Corporation and others.
  * 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
@@ -682,8 +682,8 @@
 	 * @param monitor a progress monitor or null
 	 * @return result of operation
 	 */
-	protected IStatus updateContextsToServeDirectly(IPath baseDir, String loader, IProgressMonitor monitor) {
-		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, loader, true, monitor);
+	protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
+		return TomcatVersionHelper.updateContextsToServeDirectly(baseDir, tomcatVersion, loader, true, monitor);
 	}
 
 	/**
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 7a59bba..37816d8 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
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2008 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
  * 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
@@ -195,7 +195,7 @@
 	}
 
 	
-	protected IStatus updateContextsToServeDirectly(IPath baseDir, String loader, IProgressMonitor monitor) {
+	protected IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, IProgressMonitor monitor) {
 		// Default implementation assumes nothing to do
 		return Status.OK_STATUS;
 	}
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java
index ad87e57..8774f85 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatPublishModuleVisitor.java
@@ -56,6 +56,11 @@
     protected final IPath baseDir;
     
     /**
+     * Tomcat version (from "server.info" property in org.apache.catalina.util.ServerInfo.properties).
+     */
+    protected final String tomcatVersion;
+    
+    /**
      * Server instance in which to modify the context
      */
     protected final ServerInstance serverInstance;
@@ -90,10 +95,15 @@
     /**
      * Instantiate a new TomcatPublishModuleVisitor
      * 
-     * @param catalinaBase catalina base path
+     * @param baseDir catalina base path
+     * @param tomcatVersion tomcat version
+     * @param serverInstance ServerInstance containing server.xml contents
+     * @param sharedLoader string value for shared.loader catalina configuration property
+     * @param enableMetaInfResources flag to indicate if Servlet 3.0 "META-INF/resources" feature should be supported
      */
-    TomcatPublishModuleVisitor(IPath catalinaBase, ServerInstance serverInstance, String sharedLoader, boolean enableMetaInfResources) {
-        this.baseDir = catalinaBase;
+    TomcatPublishModuleVisitor(IPath baseDir, String tomcatVersion, ServerInstance serverInstance, String sharedLoader, boolean enableMetaInfResources) {
+        this.baseDir = baseDir;
+        this.tomcatVersion = tomcatVersion;
         this.serverInstance = serverInstance;
         this.sharedLoader = sharedLoader;
         this.enableMetaInfResources = enableMetaInfResources;
@@ -269,6 +279,7 @@
 		// Build list of additional resource paths and check for additional jars
 		StringBuffer rpBuffer = new StringBuffer();
 
+		boolean isTomcat7 = tomcatVersion.startsWith("7.");
 		// Add WEB-INF/classes elements to both settings
 		for (Iterator iterator = virtualClassClasspathElements.iterator();
 				iterator.hasNext();) {
@@ -277,6 +288,13 @@
 				vcBuffer.append(";");
 			}
 			vcBuffer.append(element);
+			if (isTomcat7) {
+				if (rpBuffer.length() > 0) {
+					rpBuffer.append(";");
+				}
+				// Add to resource paths too, so resource artifacts can be found
+				rpBuffer.append("/WEB-INF/classes").append("|").append(element);
+			}
         }
         if (vcBuffer.length() > 0 && virtualJarClasspathElements.size() > 0) {
         	vcBuffer.append(";");
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java
index 7a2e895..41f9e8d 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatServerBehaviour.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2011 IBM Corporation and others.
  * 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
@@ -449,10 +449,12 @@
 		// Include or remove loader jar depending on state of serving directly 
 		status = tvh.prepareForServingDirectly(baseDir, getTomcatServer());
 		if (status.isOK()) {
+			String serverTypeID = getServer().getServerType().getId();
 			// If serving modules directly, update server.xml accordingly (includes project context.xmls)
 			if (ts.isServeModulesWithoutPublish()) {
+				String tomcatVersion = TomcatVersionHelper.getCatalinaVersion(getServer().getRuntime().getLocation(), serverTypeID);
 				status = getTomcatConfiguration().updateContextsToServeDirectly(
-						baseDir, tvh.getSharedLoader(baseDir), monitor);
+						baseDir, tomcatVersion, tvh.getSharedLoader(baseDir), monitor);
 			}
 			// Else serving normally. Add project context.xmls to server.xml
 			else {
@@ -462,8 +464,7 @@
 			}
 			if (status.isOK() && ts.isSaveSeparateContextFiles()) {
 				// Determine if context's path attribute should be removed
-				String id = getServer().getServerType().getId();
-				boolean noPath = id.indexOf("55") > 0 || id.indexOf("60") > 0;
+				boolean noPath = serverTypeID.indexOf("55") > 0 || serverTypeID.indexOf("60") > 0;
 				boolean serverStopped = getServer().getServerState() == IServer.STATE_STOPPED;
 				// TODO Add a monitor
 				TomcatVersionHelper.moveContextsToSeparateFiles(baseDir, noPath, serverStopped, null);
diff --git a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java
index a5ae929..9b53b01 100644
--- a/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java
+++ b/plugins/org.eclipse.jst.server.tomcat.core/tomcatcore/org/eclipse/jst/server/tomcat/core/internal/TomcatVersionHelper.java
@@ -1,5 +1,5 @@
 /**********************************************************************
- * Copyright (c) 2007, 2010 SAS Institute, Inc and others.
+ * Copyright (c) 2007, 2011 SAS Institute, Inc and others.
  * 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
@@ -826,7 +826,7 @@
 	 * @param monitor a progress monitor
 	 * @return result of update operation
 	 */
-	public static IStatus updateContextsToServeDirectly(IPath baseDir, String loader, boolean enableMetaInfResources, IProgressMonitor monitor) {
+	public static IStatus updateContextsToServeDirectly(IPath baseDir, String tomcatVersion, String loader, boolean enableMetaInfResources, IProgressMonitor monitor) {
 
 		IPath confDir = baseDir.append("conf");
 		IPath serverXml = confDir.append("server.xml");
@@ -845,7 +845,7 @@
 
 			// care about top-level modules only
 			TomcatPublishModuleVisitor visitor = new TomcatPublishModuleVisitor(
-					baseDir, publishedInstance, loader, enableMetaInfResources);
+					baseDir, tomcatVersion, publishedInstance, loader, enableMetaInfResources);
 			Context [] contexts = publishedInstance.getContexts();
 			for (int i = 0; i < contexts.length; i++) {
 				String moduleId = contexts[i].getSource();
@@ -1019,8 +1019,8 @@
 		return context;
 	}
 
-	private static Map catalinaJarVersion = new ConcurrentHashMap();
-	private static Map catalinaJarLastModified = new HashMap();
+	private static Map<IPath, String> catalinaJarVersion = new ConcurrentHashMap<IPath, String>();
+	private static Map<IPath, Long> catalinaJarLastModified = new ConcurrentHashMap<IPath, Long>();
 	private static volatile long lastCheck = 0;
 
 	/**
@@ -1075,13 +1075,13 @@
 			}
 		}
 		if (catalinaJarPath != null) {
-			versionSubString = (String)catalinaJarVersion.get(catalinaJarPath);
+			versionSubString = catalinaJarVersion.get(catalinaJarPath);
 			long checkTime = System.currentTimeMillis();
 			// Use some logic to try to determine if a cached value is stale
 			// If last check was more than a couple of seconds ago, check the jar time stamp 
 			if (versionSubString != null && (checkTime - lastCheck > 2000)) {
 				long curLastModified = jarFile.lastModified();
-				Long oldLastModified = (Long)catalinaJarLastModified.get(catalinaJarPath);
+				Long oldLastModified = catalinaJarLastModified.get(catalinaJarPath);
 				// If jar time stamps differ, discard the cached version string
 				if (oldLastModified == null || curLastModified != oldLastModified.longValue()) {
 					versionSubString = null;
@@ -1108,17 +1108,11 @@
 									catalinaJarVersion.put(catalinaJarPath, versionSubString);
 									catalinaJarLastModified.put(catalinaJarPath, new Long(jarFile.lastModified()));
 								}
-								else {
-									return Status.CANCEL_STATUS;
-								}
 							}
 						}
 					}
-					else {
-						return Status.CANCEL_STATUS;
-					}
 				} catch (IOException e) {
-					return Status.CANCEL_STATUS;
+					// Ignore and handle as unknown version
 				}
 				finally {
 					if (is != null) {
@@ -1132,12 +1126,25 @@
 				}
 			}
 			if (versionSubString != null) {
-				String versionTest = (String)versionStringMap.get(serverType);
-				if (versionTest != null && !versionSubString.startsWith(versionTest)) {
-					return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
-							NLS.bind(Messages.errorInstallDirWrongVersion2,
-									versionSubString, versionTest.substring(0, versionTest.length() -1)));
+				// If we have an actual version, test the version
+				if (versionSubString.length() > 0) {
+					String versionTest = (String)versionStringMap.get(serverType);
+					if (versionTest != null && !versionSubString.startsWith(versionTest)) {
+						return new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID,
+								NLS.bind(Messages.errorInstallDirWrongVersion2,
+										versionSubString, versionTest.substring(0, versionTest.length() -1)));
+					}
 				}
+				// Else we have an unknown version
+				else {
+					return Status.CANCEL_STATUS;
+				}
+			}
+			else {
+				// Cache blank version string for unknown version
+				catalinaJarVersion.put(catalinaJarPath, "");
+				catalinaJarLastModified.put(catalinaJarPath, new Long(jarFile.lastModified()));
+				return Status.CANCEL_STATUS;
 			}
 		}
 		// Else server type is not supported or jar doesn't exist
@@ -1147,4 +1154,26 @@
 		
 		return Status.OK_STATUS;
 	}
+
+	public static String getCatalinaVersion(IPath installPath, String serverType) {
+		for (Map.Entry<IPath, String> entry : catalinaJarVersion.entrySet()) {
+			IPath jarPath = entry.getKey();
+			if (installPath.isPrefixOf(jarPath)) {
+				return entry.getValue();
+			}
+		}
+		// If not found, we need to initialize the data for this server
+		IStatus result = checkCatalinaVersion(installPath, serverType);
+		// If successful, search again
+		if (result.isOK()) {
+			for (Map.Entry<IPath, String> entry : catalinaJarVersion.entrySet()) {
+				IPath jarPath = entry.getKey();
+				if (installPath.isPrefixOf(jarPath)) {
+					return entry.getValue();
+				}
+			}
+		}
+		// Return unknown version
+		return "";
+	}
 }