Index: /main/trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 34231)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java	(revision 34232)
@@ -135,14 +135,15 @@
        
     }
-
-
-    /** Constructor.
+    
+    /** Constructor - original. Called when GEMS is launched as a standalone application.
+     * Sets up a very basic static-looking Configuration object, and Dictionary.
+     * Do not call if GEMS is launched through GLI, as this constructor will erase and replace
+     * GLI's carefully configured Configuration and Dictionary causing hard to track down errors.
+     * So don't call this constructor if standalone = false.
      */
     public GEMS(String gsdl_path, String gsdl3_path, String metadata_path, boolean standalone, boolean new_set)
     {
 	self = this;
-	JarTools.initialise(this);        
-	screen_size = Configuration.screen_size;
-
+	JarTools.initialise(this);
 	// Load GLI config file: set up the Configuration so we can set up the Dictionary language
 	// Determine the GLI user directory path
@@ -154,11 +155,47 @@
             gli_user_directory_path += ".gli" + File.separator;
         }	
+
+	// Since GEMS launched standalone, need to set up Configuration and Dictionary
 	new Configuration(gli_user_directory_path, gsdl_path, gsdl3_path,
 			  null /*gsdl3_src_path*/, null /*site_name*/, null /*fedora_info*/); // null for parameters unknown to GEMS
-	    
+
 	// Read Dictionary in the locale specified in the config.xml
 	new Dictionary(Configuration.getLocale("general.locale", true), Configuration.getFont("general.font", true));
-	
-        msm = new MetadataSetManager(gsdl_path,gsdl3_path);       
+	init(metadata_path, standalone, new_set);
+    }
+
+    /** Constructor - overloaded to use existing Configuration and Dictionary
+     * This Constructor is used when GEMS is launched through GLI.
+     * It's crucial for GLI to launch GEMS with this constructor as the other one will erase and
+     * replace GLI's carefully set-up Configuration and Dictionary, resulting in subtle but major
+     * flow-on errors particularly because of the alternate's cutdown version of Configuration.
+     */
+    public GEMS(String metadata_path, boolean new_set)
+    {	
+	self = this;
+	JarTools.initialise(this);
+
+	// When GEMS is launched through GLI (so not standalone)
+	// a Configuration and Dictionary is already set up
+
+	init(metadata_path, false /*standalone*/, new_set);
+    }
+
+    private void init(String metadata_path, boolean standalone, boolean new_set) {
+	screen_size = Configuration.screen_size;
+	
+	//msm = new MetadataSetManager(Configuration.gsdl_path,Configuration.gsdl3_path);
+	         // dangerously side-effecting version of MetadataSetManager constructor that
+	    // erases Configuration all over again (as the original GEMS constructor also did)
+	    // and is noticeable when remote GS3 server cryptically fails because
+	    // Configuration.site_name is suddenly null due to these constructors.
+	    // Creating/adding a new metadata set also prevents GLI > Preferences from opening
+	    // because Configuration.site_name is nulled as a consequence of launching GEMS through GLI
+
+	// Instead, call the MetadataSetManager() constructor as it reuses existing Configuration,
+	// whether this is a basic Configuration created by standalone GEMS
+	// or a carefully and highly configured Configuration object created by GLI launching GEMS.
+	msm = new MetadataSetManager();
+	
         stand_alone = standalone;
 	listeners = new ArrayList();
@@ -219,6 +256,6 @@
         new_prompt.addMetadataSetListener((MetadataSetListener)attribute_table);
         new_prompt.addMetadataSetListener((MetadataSetListener)language_dependent_attribute_table);
-  
-
+	
+	
         // load the initial metadataset
         if (metadata_path !=null && !metadata_path.equals("")){
@@ -320,6 +357,8 @@
 	getContentPane().add(card_pane,BorderLayout.CENTER);
 	setLocation((screen_size.width - SIZE.width) / 2, (screen_size.height - SIZE.height) / 2);
-	if (stand_alone)
+	
+	if (stand_alone) {
 	    setVisible(true);
+	}
     }
 
Index: /main/trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 34231)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gems/MetadataSetManager.java	(revision 34232)
@@ -70,5 +70,15 @@
     private String current_language = GEMSConstants.DEFAULT_LANGUAGE; 
 
-    /** Constructor. */
+    /** Constructor. 
+     * This constructor can be dangerous if launched by a Greenstone application
+     * that already set up the static looking Configuration object, because
+     * this constructor will subtly erase and replace any previously existing
+     * carefully configured Configuration object.
+     * I think this constructor would only be useful if MetadataSetManager is ever launched
+     * as a standalone GS3 application.
+     * If instantiating a MetadataSetManager through GEMS, use the MetadataSetManager() constructor,
+     * including if GEMS is launched through GLI.
+     * Also use MetadataSetManager() if creating a MetadataSetManager object through GLI.
+     */
     public MetadataSetManager(String gsdl_path, String gsdl3_path) {
     	// Determine the GLI user directory path
@@ -87,5 +97,14 @@
         languageList = new ArrayList();
     }
-
+    
+    /** Constructor - overloaded to use any existing Configuration already set up.
+     * This Constructor is used by GEMS when GEMS is launched through GLI.
+     */
+    public MetadataSetManager() {    	     
+	current_language = Configuration.getLanguage(); 
+
+        languageList = new ArrayList();
+    }
+    
     public ArrayList getLanguageList(){
         //already loaded
Index: /main/trunk/gli/src/org/greenstone/gatherer/gui/MetadataSetDialog.java
===================================================================
--- /main/trunk/gli/src/org/greenstone/gatherer/gui/MetadataSetDialog.java	(revision 34231)
+++ /main/trunk/gli/src/org/greenstone/gatherer/gui/MetadataSetDialog.java	(revision 34232)
@@ -138,5 +138,8 @@
 	    String metadata_path = metadata_set.getMetadataSetFile().toString();
 	    if (gems == null){
-		gems = new GEMS(Configuration.gsdl_path,Configuration.gsdl3_path,"", false, false);
+		
+		//gems = new GEMS(Configuration.gsdl_path,Configuration.gsdl3_path,"", false, false, site_name); // dangerous: this version of GEMS constructor only for if GEMS not launched through GLI but standalone
+		// refer to comments in GEMS.java for GEMS constructors
+		gems = new GEMS("", false); // right way to create GEMS app when launched by GLI
 		gems.addGEMSListener(this);
 	    }
@@ -270,5 +273,7 @@
 		    public void actionPerformed(ActionEvent event) {
 			if (gems == null) {
-			    gems = new GEMS(Configuration.gsdl_path, Configuration.gsdl3_path, "", false, false);
+			    //gems = new GEMS(Configuration.gsdl_path, Configuration.gsdl3_path, "", false, false, site_name); // dangerous: this version of GEMS constructor only for if GEMS not launched through GLI but standalone
+			    // refer to comments in GEMS.java for GEMS constructors
+			    gems = new GEMS("", false); // right way to create GEMS app when launched by GLI
 			}
 			gems.newMetadataSet();
