[463126] JAX-RS Facet Install Page servlet-class field validation is too
strict
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
index bfc8da6..da5e6ef 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSFacetInstallDataModelProvider.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -17,7 +17,8 @@
  * 20100519   313576 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS tools- validation problems
  * 20110817   355026 kchong@ca.ibm.com - Keith Chong, [JAXRS] JAXRSFacetInstallDataModelProvider dispose method does not remove all listeners it adds
  * 20120214   371661 jenyoung@ca.ibm.com - Jennifer Young, [JAXRS] Performance issue since dispose method is not being called
- * 20140709   431081 jgwest@ca.ibm.com - Jonathan West,  "Further Configuration" state when adding JAX-RS Facet should be "available", not "required"  
+ * 20140709   431081 jgwest@ca.ibm.com - Jonathan West,  "Further Configuration" state when adding JAX-RS Facet should be "available", not "required"
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict 
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
 
@@ -202,14 +203,13 @@
 	}
 
 	private IStatus validateServletInfo(String servletName, String servletClassName) {
+		
 		if (servletName == null || servletName.trim().length() == 0) {
 			errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletName;
 			return createErrorStatus(errorMessage);
 		}
-		if (servletClassName == null || servletClassName.trim().length() == 0) {
-			errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletClassName;
-			return createErrorStatus(errorMessage);
-		}
+
+		// ServletClassName is not required in some cases, for example, if servlet name is a javax.ws.rs.core.Application.
 
 		return OK_STATUS;
 	}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
index c8d3e02..0add6ff 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJ2EEUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -14,6 +14,7 @@
  * 20100325   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
  * 20100408   308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
  * 20100618   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict  
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
 
@@ -158,12 +159,15 @@
 	 * @return Servlet servlet - if passed servlet was null, will return created
 	 *         servlet
 	 */
-	@SuppressWarnings("unchecked")
-	public static Servlet createOrUpdateServletRef(final WebApp webApp,
-			final IDataModel config, Servlet servlet) {
+	public static Servlet createOrUpdateServletRef(final WebApp webApp,  final IDataModel config, Servlet servlet) {
 
 		String displayName = getDisplayName(config);
 		String className = getServletClassname(config);
+
+		// For 2.3 and 2.4, return empty element rather than null
+		if(className == null || className.trim().length() == 0 ) {
+			className = JAXRSUtils.JAXRS_SERVLET_CLASS; // The default name of the JAX-RS servlet class
+		}
 		
 		return createOrUpdateServletRef(webApp, displayName, className, servlet);
 	}
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
index 1a5ebb8..e37f99b 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSJEEUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -17,6 +17,7 @@
  * 20100408   308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
  * 20100618   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
  * 20140813   441729 kchong@ca.ibm.com - Keith Chong, JAX-RS Facet install may fail to update the web.xml with servlet info.
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict  
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
 
@@ -123,17 +124,22 @@
 	 * @return Servlet servlet - if passed servlet was null, will return created
 	 *         servlet
 	 */
-	@SuppressWarnings("unchecked")
 	public static Servlet createOrUpdateServletRef(final WebApp webApp,
 			final IDataModel config, org.eclipse.jst.javaee.web.Servlet servlet) {
 
 		String displayName = getDisplayName(config);
 		String className = getServletClassname(config);
+		
+		// For Web 3.0+, return null, rather than empty, as the className is not required in some scenarios.
+		if(className == null || className.trim().length() == 0) {
+			if(isWebApp30orHigher(webApp)) {
+				className = null;
+			}
+		}
 
 		return createOrUpdateServletRef(webApp, displayName, className, servlet);
 	}
 	
-	@SuppressWarnings("unchecked")
 	public static Servlet createOrUpdateServletRef(final WebApp webApp,
 			String displayName, String className, org.eclipse.jst.javaee.web.Servlet servlet) {
 
@@ -231,6 +237,24 @@
 		return false;
 	}
 
+	public static boolean isWebApp30orHigher(final Object webAppObj) {
+		
+		if (webAppObj instanceof WebApp) {
+			WebApp w = (WebApp)webAppObj;
+			
+			if(w.getVersion() == WebAppVersionType._30_LITERAL) {		
+				return true;
+			}
+			
+			if(w.getVersion() == WebAppVersionType._31) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+
+	
 	/**
 	 * Creates servlet-mappings for the servlet for 2.5 WebModules or greater
 	 * 
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
index 89db24b..d0cf253 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.core/src/org/eclipse/jst/ws/jaxrs/core/internal/project/facet/JAXRSUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -13,6 +13,7 @@
  * 20100325   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
  * 20100408   308565 kchong@ca.ibm.com - Keith Chong, JAX-RS: Servlet name and class not updated
  * 20100618   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict 
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.core.internal.project.facet;
 
@@ -69,8 +70,11 @@
 	protected static String getServletClassname(IDataModel config) {
 		String className = config
 				.getStringProperty(IJAXRSFacetInstallDataModelProperties.SERVLET_CLASSNAME);
-		if (className == null || className.trim().equals("")) //$NON-NLS-1$
+
+		if (className == null || className.trim().equals("")) { //$NON-NLS-1$
 			className = JAXRS_SERVLET_CLASS;
+		}
+		
 		return className.trim();
 	}
 
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
index d348037..66d03d8 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSFacetInstallPage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -24,7 +24,8 @@
  * 20110822   349541 atosak@ca.ibm.com - Atosa Khoddamhazrati, JAX-RS Facet assumes a project has a runtime when enabling the facet
  * 20120206   365103 jenyoung@ca.ibm.com - Jennifer Young, JAX-RS configuration UI should have the Update Deployment descriptor check box available
  * 20120427   377916 jenyoung@ca.ibm.com - Jennifer Young, The JAX-RS install operation config should be updated whenever there are provider set changes
- * 20140709   431081 jgwest@ca.ibm.com - Jonathan West,  "Further Configuration" state when adding JAX-RS Facet should be "available", not "required" * 
+ * 20140709   431081 jgwest@ca.ibm.com - Jonathan West,  "Further Configuration" state when adding JAX-RS Facet should be "available", not "required" *
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict 
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet;
 
@@ -381,6 +382,16 @@
 
   private String getJAXRSServletClassname()
   {
+	  String text = servletInfoGroup.txtJAXRSServletClassName.getText();
+
+	  if(text == null || text.trim().length() == 0) {
+		  if(isJEE6orGreater()) {
+			  return null;
+		  } else {
+			  return "";
+		  }
+	  }
+
 	  return servletInfoGroup.txtJAXRSServletClassName.getText().trim();
   }
 
diff --git a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
index 2ac7680..84f513d 100644
--- a/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
+++ b/bundles/org.eclipse.jst.ws.jaxrs.ui/src/org/eclipse/jst/ws/jaxrs/ui/internal/project/facet/JAXRSLibraryPropertyPage.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2009, 2014 IBM Corporation and others.
+ * Copyright (c) 2009, 2015 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
@@ -21,6 +21,7 @@
  * 20100618   307059 ericdp@ca.ibm.com - Eric D. Peters, JAX-RS properties page- fields empty or incorrect
  * 20110823   349718 kchong@ca.ibm.com - Keith Chong, Upon selection, the JAX-RS Configuration page is blank when Project Facets page has unapplied changes
  * 20140813   441729 kchong@ca.ibm.com - Keith Chong, JAX-RS Facet install may fail to update the web.xml with servlet info.
+ * 20150325   463126 jgwest@ca.ibm.com - Jonathan West,  JAX-RS Facet Install Page servlet-class field validation is too strict 
  *******************************************************************************/
 package org.eclipse.jst.ws.jaxrs.ui.internal.project.facet;
 
@@ -264,7 +265,16 @@
     List<String> listOfMappings = Arrays.asList(servletInfoGroup.lstJAXRSServletURLPatterns.getItems());
     if (JAXRSJEEUtils.isWebApp25orHigher(webAppObj))
     {
-      provider.modify(new UpdateWebXMLForJavaEE(project, initialInstallDelegateLibraryProviderID , servletInfoGroup.txtJAXRSServletName.getText(), servletInfoGroup.txtJAXRSServletClassName.getText(), listOfMappings),
+    	
+    	String className = servletInfoGroup.txtJAXRSServletClassName.getText(); 
+    	if(JAXRSJEEUtils.isWebApp30orHigher(webAppObj)) {
+			// For Web 3.0+, return null, rather than empty, as the className is not required in some scenarios.
+			if(className == null || className.trim().length() == 0) {
+				className = null;
+			}
+    	}
+    	
+      provider.modify(new UpdateWebXMLForJavaEE(project, initialInstallDelegateLibraryProviderID , servletInfoGroup.txtJAXRSServletName.getText(), className, listOfMappings),
           IModelProvider.FORCESAVE);
     }
     else
@@ -288,10 +298,8 @@
 			String errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletName;
 			return createErrorStatus(errorMessage);
 		}
-		if (ServletClassName == null || ServletClassName.trim().length() == 0) {
-			String errorMessage = Messages.JAXRSFacetInstallDataModelProvider_ValidateServletClassName;
-			return createErrorStatus(errorMessage);
-		}
+		
+		// ServletClassName is not required in some cases, for example, if servlet name is a javax.ws.rs.core.Application.
 		return Status.OK_STATUS;
 	}
 	private IStatus createErrorStatus(String msg) {