[422998] Can't generate Client into a plain Java Project with newer Java
version - For 3.6
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUI.properties b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUI.properties
index c0a4757..73ac123 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUI.properties
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUI.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2004, 2010 IBM Corporation and others.
+# Copyright (c) 2004, 2013 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
@@ -220,6 +220,9 @@
 MSG_CLIENT_RUNTIME_DOES_NOT_SUPPORT_TEMPLATE=The {0} Web service runtime in {1} does not support the client project type {2}.
 MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_TEMPLATE=The {0} server does not support the client project type {1}.
 
+
+MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION=The {0} server does not support the Java Utility project {1} due to differing Java facet version.
+
 MSG_SAME_CLIENT_AND_SERVICE_EARS=Your selected service and client {0} modules have the same name.  Proceeding with this configuration may result in runtime errors.
 MSG_SAME_CLIENT_AND_SERVICE_COMPONENTS=Your selected service and client {0} modules have the same name.  Proceeding with this configuration will result in runtime errors.
 MSG_SAME_CLIENT_AND_SERVICE_PROJECTS=Your selected service and client projects are the same.  Proceeding with this configuration will result in errors.
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUIMessages.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUIMessages.java
index 7259339..7117f4a 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUIMessages.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/ConsumptionUIMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 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
@@ -142,6 +142,7 @@
     public static String MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT;
     public static String MSG_CLIENT_RUNTIME_DOES_NOT_SUPPORT_TEMPLATE;
     public static String MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_TEMPLATE;
+    public static String MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION;    
 	public static String MSG_SAME_CLIENT_AND_SERVICE_EARS;
 	public static String MSG_SAME_CLIENT_AND_SERVICE_COMPONENTS;
 	public static String MSG_SAME_CLIENT_AND_SERVICE_PROJECTS;
@@ -406,6 +407,8 @@
     public static String MSG_LOADING_WEB_SERVICE;
 
 
+    
+    
 	static {
 		NLS.initializeMessages(BUNDLE_NAME, ConsumptionUIMessages.class);
 	}
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
index 9ddc496..7306baf 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/common/ValidationUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 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
@@ -57,6 +57,7 @@
 import org.eclipse.emf.ecore.resource.Resource;
 import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
 import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
 import org.eclipse.jst.j2ee.internal.project.J2EEProjectUtilities;
 import org.eclipse.jst.j2ee.project.JavaEEProjectUtilities;
 import org.eclipse.jst.j2ee.webservice.internal.WebServiceConstants;
@@ -86,6 +87,7 @@
 import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
 import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
 import org.eclipse.wst.common.project.facet.core.VersionFormatException;
+import org.eclipse.wst.common.project.facet.core.internal.ProjectFacetVersion;
 import org.eclipse.wst.server.core.IRuntime;
 import org.eclipse.wst.server.core.IRuntimeType;
 import org.eclipse.wst.server.core.IServerType;
@@ -356,10 +358,24 @@
 
 					// Check if the server supports it.
 					if (serverId != null && serverId.length() > 0) {
+			        	  
 						if (!valUtils.doesServerSupportProject(serverId, projectName)) {
-							return StatusUtils.errorStatus(NLS.bind(
-													ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT,
-													new String[] { serverLabel, projectName }));
+							// Server does not support the project...
+							
+							boolean isJavaUtilProject = project != null ? FacetUtils.isJavaProject(project) : false ;
+			    		  
+							// If this error is due to differing Java facet versions on a Java utility project, display a specific error message
+							if(isJavaUtilProject && doesServerSupportClientProject(serverId, projectName, true)) {
+								return StatusUtils.errorStatus(NLS.bind(
+										ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION,
+										new String[] { serverLabel, projectName }));
+			    			  
+							} else {
+								// Otherwise display a general error
+								return StatusUtils.errorStatus(NLS.bind(
+										ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT,
+										new String[] { serverLabel, projectName }));
+							}
 						}
 					}
 				} else {
@@ -584,6 +600,40 @@
 		return Status.OK_STATUS;
 
 	}
+
+
+  /**
+   * Returns whether or not the provided server type supports the facet versions on the provided client project
+   * @param serverFactoryId server type id
+   * @param projectName name of a project that may or may not exist.
+   * @param ignoreJavaVersionFacet Whether or not to ignore differences in java facet version
+   * @return boolean <code>true</code> if the server type supports the facet versions on the project (facets versions are inferred from a Java project), 
+   * <code>false</code> if the server type does not support the facet versions or facet versions on the project cannot be determined.   */
+  public boolean doesServerSupportClientProject(String serverFactoryId, String projectName, boolean ignoreJavaVersionFacet) {
+    Set facets = FacetUtils.getFacetsForProject(projectName);
+
+    if (ignoreJavaVersionFacet && facets != null) {
+
+      Set facetsCopy = new HashSet();
+      facetsCopy.addAll(facets);
+      for (Iterator it = facetsCopy.iterator(); it.hasNext();) {
+        ProjectFacetVersion pfv = (ProjectFacetVersion) it.next();
+        String facetId = pfv.getProjectFacet().getId();
+        if (facetId != null && facetId.equalsIgnoreCase(JavaFacetUtils.JAVA_FACET.getId())) {
+          it.remove();
+        }
+      }
+
+      facets = facetsCopy;
+
+    }
+
+    if (facets == null) {
+      return true;
+    } else {
+      return doesServerSupportFacets(serverFactoryId, facets);
+    }
+  }
   
   /**
    * Returns whether or not the provided server type supports the facet versions on the provided project
@@ -610,6 +660,7 @@
   public boolean doesServerSupportFacets(String serverFactoryId, Set facets)
   {
     Set runtimes = FacetUtils.getRuntimes(new Set[]{facets});
+    
     Iterator itr = runtimes.iterator();
     IServerType st = ServerCore.findServerType(serverFactoryId);        
     String runtimeTypeId = st.getRuntimeType().getId();
diff --git a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java
index 4b0bc85..12b756a 100644
--- a/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java
+++ b/bundles/org.eclipse.jst.ws.consumption.ui/src/org/eclipse/jst/ws/internal/consumption/ui/widgets/extensions/ClientExtensionDefaultingCommand.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2009 IBM Corporation and others.
+ * Copyright (c) 2004, 2013 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
@@ -31,6 +31,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jem.util.emf.workbench.ProjectUtilities;
 import org.eclipse.jst.ws.internal.common.ServerUtils;
+import org.eclipse.jst.ws.internal.consumption.common.FacetUtils;
 import org.eclipse.jst.ws.internal.consumption.ui.ConsumptionUIMessages;
 import org.eclipse.jst.ws.internal.consumption.ui.common.ValidationUtils;
 import org.eclipse.jst.ws.internal.consumption.ui.wsrt.RuntimeDescriptor;
@@ -631,15 +632,32 @@
             runtimeLabel }));
         env.getStatusHandler().reportError(status);
       }
+      
+      IProject clientProject = ProjectUtilities.getProject(clientProjectName_);
+      
       //If the project exists, ensure it supports the Web service type, Web service runtime, and server.
-      if (clientProjectName_ != null && ProjectUtilities.getProject(clientProjectName_).exists()) {
+      if (clientProjectName_ != null && clientProject.exists()) {
     	  ValidationUtils vUtil = new ValidationUtils();
+    	  
           if (!vUtil.doesServerSupportProject(serverId,clientProjectName_)) {
-    	  status = StatusUtils.errorStatus(NLS.bind(
-					ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT,
-					new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),clientProjectName_ }));
-    	  env.getStatusHandler().reportError(status);
-          }
+
+        	  // If this error is due to differing Java facet versions, display a specific error message
+    		  boolean isJavaUtilProject = clientProject != null ? FacetUtils.isJavaProject(clientProject) : false ;
+    		  if(isJavaUtilProject && vUtil.doesServerSupportClientProject(serverId, clientProjectName_, true)) {
+	        	  status = StatusUtils.errorStatus(NLS.bind(
+	        			  ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT_JAVA_UTIL_VERSION,
+						new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),clientProjectName_ }));
+    			  
+    		  } else {
+    			  // otherwise display a general error message
+	        	  status = StatusUtils.errorStatus(NLS.bind(
+						ConsumptionUIMessages.MSG_CLIENT_SERVER_DOES_NOT_SUPPORT_PROJECT,
+						new String[] { WebServiceRuntimeExtensionUtils2.getServerLabelById(serverId),clientProjectName_ }));
+    		  }
+    		  
+    		  // Show error
+    		  env.getStatusHandler().reportError(status);
+          }		  
       }
       // Determine if the selected server type has only stub runtimes associated
       // with it and if a server instance is not selected.