Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/FLyrDefault.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/FLyrDefault.java	(revision 41806)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/FLyrDefault.java	(revision 41807)
@@ -261,7 +261,13 @@
 	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getName()
 	 */
 	public String getName() {
-		return (String) this.metadataContainer.getDynValue(METADATA_NAME);
+            String name = "(unknow)";
+            try {
+                name = (String) this.metadataContainer.getDynValue(METADATA_NAME);
+            } catch( Throwable th) {
+                logger.warn("Can't retrive the layer name.");
+            }
+            return name;
 	}
 
 	/*
@@ -927,6 +933,7 @@
 	// ========================================================
 	
 	public void saveToState(PersistentState state) throws PersistenceException {
+            try {
 		state.set("parentLayer", parentLayer);
 		state.set("status",status);
 		state.set("minScale", minScale);
@@ -936,9 +943,20 @@
 		state.set("name", getName());
 		state.set("crs", getProjection());
 		state.set("properties",properties.getExtendedProperties());
+            } catch(PersistenceException ex) {
+                logger.warn("Can't save to persistent state the layer '"+this.getName()+"'.");
+                throw ex;
+            } catch(RuntimeException ex) {
+                logger.warn("Can't save to persistent state the layer '"+this.getName()+"'.");
+                throw ex;
+            }
 	}
 
 	public void loadFromState(PersistentState state) throws PersistenceException {
+            try {
+		this.setDynValue(METADATA_NAME, state.getString("name"));
+		this.setDynValue(METADATA_CRS, state.get("crs"));
+		
 		this.parentLayer = (FLayers) state.get("parentLayer");
 		this.status = (FLayerStatus) state.get("status");
 		this.minScale = state.getDouble("minScale");
@@ -946,10 +964,14 @@
 		this.transparency = state.getInt("transparency");
 		this.ct = (ICoordTrans) state.get("coordTrans");
 
-		this.setDynValue(METADATA_NAME, state.getString("name"));
-		this.setDynValue(METADATA_CRS, state.get("crs"));
-		
                 this.properties.setExtendedProperties(new Hashtable((Map)state.get("properties")));
+            } catch(PersistenceException ex) {
+                logger.warn("Can't load from persietent state the layer '"+this.getName()+"'.");
+                throw ex;
+            } catch(RuntimeException ex) {
+                logger.warn("Can't load from persietent state the layer '"+this.getName()+"'.");
+                throw ex;
+            }
 
 	}
 
Index: trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java
===================================================================
--- trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java	(revision 41806)
+++ trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/FLyrVect.java	(revision 41807)
@@ -419,104 +419,102 @@
 
     public void saveToState(PersistentState state) throws PersistenceException {
 
-        if (!this.isAvailable()) {
+        FeatureStore featureStore = null;
+
+        if ( !this.isAvailable() ) {
+            logger.info("The '" + this.getName() + "' layer is not available, it will persist not.");
             return;
         }
+        
+        try {
+            super.saveToState(state);
 
-        super.saveToState(state);
+            if ( getLegend() != null ) {
+                state.set("legend", getLegend());
+            }
 
-        if (getLegend() != null) {
-            state.set("legend", getLegend());
-        }
+            featureStore = getFeatureStore();
 
-        FeatureStore fst = null;
-        fst = getFeatureStore();
+            if ( featureStore != null ) {
+                state.set("featureStore", featureStore);
+            }
 
-        if (fst != null) {
-            state.set("featureStore", fst);
-        }
+            state.set("isLabeled", isLabeled);
 
-        state.set("isLabeled", isLabeled);
+            if ( strategy != null ) {
+                state.set("labelingStrategy", strategy);
+            }
 
-        if (strategy != null) {
-            state.set("labelingStrategy", strategy);
-        }
+            if ( getLinkProperties() != null ) {
+                state.set("linkProperties", getLinkProperties());
+            }
 
-        if (getLinkProperties() != null) {
-            state.set("linkProperties", getLinkProperties());
+            state.set("typeShape", typeShape);
+        } catch (PersistenceException ex) {
+            logger.warn("Can't persist to state the layer '" + this.getName() + "'.", ex);
+            throw ex;
+        } catch (RuntimeException ex) {
+            logger.warn("Can't persist to state the layer '" + this.getName() + "'.", ex);
+            throw ex;
         }
 
-        // state.set("bHasJoin", bHasJoin);
-        state.set("typeShape", typeShape);
     }
 
 
     public void loadFromState(PersistentState state) throws PersistenceException {
 
         DataStore store = null;
-        try {
-            super.loadFromState(state);
-        	store = (DataStore) state.get("featureStore");
-        } catch (PersistenceRuntimeException e) {
-            logger.debug("Unable to load store from persistence in layer: " + this.getName(), e);
-			this.setAvailable(false);
-			return;
-		}
+        IVectorLegend vectorLegend = null;
+        ILabelingStrategy labelingStrategy = null;
+        Boolean isLabeled = Boolean.FALSE;
 
         try {
-            this.bindToDataStore(store);
-        } catch (LoadLayerException e) {
-            throw new PersistenceException("While loading FLyrVect from state.",
-                e);
-        }
-        
-        IVectorLegend lgnd = null;
-        
-        try {
-            lgnd = (IVectorLegend) state.get("legend");
-        } catch (PersistenceRuntimeException pre) {
-            /*
-             * For example, symbol image file not found
-             */
-            logger.debug("Unable to instantiate persisted lagend.", pre);
-            this.setAvailable(false);
-            return;
-        }
-        
-        try {
-            this.setLegend(lgnd);
-        } catch (LegendLayerException e) {
-            throw new PersistenceException("While loading FLyrVect from state.", e);
-        }
+                super.loadFromState(state);
+                store = (DataStore) state.get("featureStore");
 
-        Boolean isLbl = new Boolean(false);
-        ILabelingStrategy lblst = null;
+            try {
+                this.bindToDataStore(store);
+            } catch (LoadLayerException e) {
+                throw new PersistenceException("Can't bind layer '"+this.getName()+"' to store '"+store.getFullName()+"'.",e);
+            }
 
-        try {
-            isLbl = (Boolean) state.get("isLabeled");
-            if (isLbl.booleanValue()) {
-                lblst = (ILabelingStrategy) state.get("labelingStrategy");
+
+            vectorLegend = (IVectorLegend) state.get("legend");
+
+            try {
+                this.setLegend(vectorLegend);
+            } catch (LegendLayerException e) {
+                throw new PersistenceException("Can't set vector legend to the layer.", e);
             }
-        } catch (Exception ex) {
-            throw new PersistenceException("While loading FLyrVect from state.",
-                ex);
-        }
 
-        /*
-         * String _labelFieldName = null;
-         * String _labelfield = null;
-         */
 
-        if (isLbl.booleanValue()) {
-            this.setIsLabeled(true);
-            this.setLabelingStrategy(lblst);
-        } else {
-            this.setIsLabeled(false);
-            this.setLabelingStrategy(null);
-        }
+            try {
+                isLabeled = (Boolean) state.get("isLabeled");
+                if ( isLabeled.booleanValue() ) {
+                    labelingStrategy = (ILabelingStrategy) state.get("labelingStrategy");
+                }
+            } catch (Exception ex) {
+                throw new PersistenceException("Can't load labeling strategi from persistent state.",
+                        ex);
+            }
 
-        typeShape = state.getInt("typeShape");
+            if ( isLabeled.booleanValue() ) {
+                this.setIsLabeled(true);
+                this.setLabelingStrategy(labelingStrategy);
+            } else {
+                this.setIsLabeled(false);
+                this.setLabelingStrategy(null);
+            }
 
+            typeShape = state.getInt("typeShape");
+
+        } catch (Throwable e) {
+            String storeName = (store == null)? "unknow" : store.getFullName();
+            logger.warn("can't load layer '" + this.getName() + "' (store="+storeName+") from persisted state.", e);
+            this.setAvailable(false);
+            return;
+        }
+
     }
 
     /**
