[353681] EJB Client creation and removal is too tied to EARs
diff --git a/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EJBClientJARRemovalOperation.java b/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EJBClientJARRemovalOperation.java
index 09f3696..92151c2 100644
--- a/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EJBClientJARRemovalOperation.java
+++ b/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EJBClientJARRemovalOperation.java
@@ -284,35 +284,38 @@
 		list.add(clientProject.getName() + IJ2EEModuleConstants.JAR_EXT);
 		
 		IProject[] earProjects = EarUtilities.getReferencingEARProjects( ejbProject );
-		UpdateManifestOperation removeOp = new EJBClientManifestUtility().getRemoveOperation(ejbProject, earProjects[0], list, clientProject);
-		
-		try {
-			removeOp.execute( createSubProgressMonitor(1), null);
-		} catch (ExecutionException e) {
-			EjbPlugin.logError( e );
-		}
-		
-		ArchiveManifest clientMf = J2EEProjectUtilities.readManifest(clientProject);
-		if (clientMf == null)
-			return;
-		String[] mfEntries = clientMf.getClassPathTokenized();
-		if (mfEntries.length == 0)
-			return;
-		
-		createSubProgressMonitor( earProjects.length );
-		
-		//copy all JAR dependencies not already contained by the ejb module,
-		//from the client JAR to the ejb module	
-
-		for (int i = 0; i < earProjects.length; i++) {
-			List result = EJBClientJarCreationHelper.normalize(mfEntries, earProjects[i], ejbProject, false);
-			UpdateManifestOperation addOp = new EJBClientManifestUtility().getAddOperation(ejbProject, earProjects[0], result);
+		if (earProjects != null && earProjects.length > 0)
+		{
+			UpdateManifestOperation removeOp = new EJBClientManifestUtility().getRemoveOperation(ejbProject, earProjects[0], list, clientProject);
 			
-			try{
-				addOp.execute( createSubProgressMonitor(1), null );
-			}catch (ExecutionException e) {
+			try {
+				removeOp.execute( createSubProgressMonitor(1), null);
+			} catch (ExecutionException e) {
 				EjbPlugin.logError( e );
 			}
+			
+			ArchiveManifest clientMf = J2EEProjectUtilities.readManifest(clientProject);
+			if (clientMf == null)
+				return;
+			String[] mfEntries = clientMf.getClassPathTokenized();
+			if (mfEntries.length == 0)
+				return;
+			
+			createSubProgressMonitor( earProjects.length );
+			
+			//copy all JAR dependencies not already contained by the ejb module,
+			//from the client JAR to the ejb module	
+	
+			for (int i = 0; i < earProjects.length; i++) {
+				List result = EJBClientJarCreationHelper.normalize(mfEntries, earProjects[i], ejbProject, false);
+				UpdateManifestOperation addOp = new EJBClientManifestUtility().getAddOperation(ejbProject, earProjects[0], result);
+				
+				try{
+					addOp.execute( createSubProgressMonitor(1), null );
+				}catch (ExecutionException e) {
+					EjbPlugin.logError( e );
+				}
+			}
 		}
 	}
 
@@ -322,14 +325,18 @@
 	 */
 	private void moveIncomingJARDependencies() throws InvocationTargetException, InterruptedException {
 		
-		InvertClientJARDependencyCompoundOperation op = 
-			new InvertClientJARDependencyCompoundOperation( EarUtilities.getReferencingEARProjects( ejbProject ),
-						clientProject,
-						ejbProject );
-		try {
-			op.execute(createSubProgressMonitor(1), null);
-		} catch (ExecutionException e) {
-			EjbPlugin.logError( e );
+		IProject[] earProjects = EarUtilities.getReferencingEARProjects( ejbProject );
+		if (earProjects != null && earProjects.length > 0)
+		{
+			InvertClientJARDependencyCompoundOperation op = 
+				new InvertClientJARDependencyCompoundOperation( earProjects,
+							clientProject,
+							ejbProject );
+			try {
+				op.execute(createSubProgressMonitor(1), null);
+			} catch (ExecutionException e) {
+				EjbPlugin.logError( e );
+			}
 		}
 	}
 
diff --git a/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EjbClientJarCreationOperation.java b/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EjbClientJarCreationOperation.java
index e83d5c6..6cd12eb 100644
--- a/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EjbClientJarCreationOperation.java
+++ b/plugins/org.eclipse.jst.j2ee.ejb/ejbarchive/org/eclipse/jst/j2ee/internal/ejb/archiveoperations/EjbClientJarCreationOperation.java
@@ -122,9 +122,12 @@
 			
 			javadm.setProperty( JavaFacetInstallDataModelProvider.SOURCE_FOLDER_NAME,
 					javaSourceFolder);
-			
 
-			utildm.setProperty( IUtilityFacetInstallDataModelProperties.EAR_PROJECT_NAME, earprojects[0].getName());
+			javadm.setProperty( JavaFacetInstallDataModelProvider.DEFAULT_OUTPUT_FOLDER_NAME,
+					javaSourceFolder);
+
+			if (earprojects.length > 0)
+				utildm.setProperty( IUtilityFacetInstallDataModelProperties.EAR_PROJECT_NAME, earprojects[0].getName());
 			
 			utildm.setProperty( IUtilityFacetInstallDataModelProperties.FACET_RUNTIME, runtime );
 			dm.setProperty(UtilityProjectCreationDataModelProvider.FACET_RUNTIME, runtime);
@@ -151,7 +154,7 @@
 	            moveOutgoingJARDependencies();
 				EJBClientJarCreationHelper.copyOutgoingClasspathEntries( ejbproject,
 								ProjectUtilities.getProject(projectName), true);
-				modifyEJBModuleJarDependency(model, earprojects[0], monitor);
+				modifyEJBModuleJarDependency(model, monitor);
 				IProject clientProject = ProjectUtilities.getProject( model.getStringProperty( PROJECT_NAME ) );
 	            moveIncomingJARDependencies( ejbproject, clientProject );
 	            
@@ -242,7 +245,7 @@
 
 	}
 
-	private void modifyEJBModuleJarDependency(IDataModel model, IProject earProject,
+	private void modifyEJBModuleJarDependency(IDataModel model, 
 				IProgressMonitor aMonitor) throws InvocationTargetException, InterruptedException {