Anonymous avatar Anonymous committed a8cf2e9

Cleaning up the configuration exceptions thrown (too many before), making the
xwork exception message cleaner, ensuring an accurate url in location objects

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@995 e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (2)

src/java/com/opensymphony/xwork/XworkException.java

         if (msg == null && getCause() != null) {
             msg = getCause().getMessage();
         }
-        return msg + " - " + location.toString();
+        
+        if (msg != null) {
+            return msg + " - " + location.toString();
+        } else {
+            return location.toString();
+        }
     }
 }

src/java/com/opensymphony/xwork/config/providers/XmlConfigurationProvider.java

 package com.opensymphony.xwork.config.providers;
 
 import com.opensymphony.util.FileManager;
+import com.opensymphony.util.ClassLoaderUtil;
 import com.opensymphony.util.TextUtils;
 import com.opensymphony.xwork.Action;
 import com.opensymphony.xwork.ActionSupport;
 import com.opensymphony.xwork.ObjectFactory;
+import com.opensymphony.xwork.XworkException;
 import com.opensymphony.xwork.config.*;
 import com.opensymphony.xwork.config.entities.*;
 import com.opensymphony.xwork.util.DomHelper;
 
         try {
             loadConfigurationFile(configFileName, null);
+        } catch (ConfigurationException e) {
+            throw e;
         } catch (Exception e) {
             LOG.fatal("Could not load XWork configuration file, failing", e);
             throw new ConfigurationException("Error loading configuration file " + configFileName, e);
                 }
 
                 InputSource in = new InputSource(is);
-                in.setSystemId(fileName);
+                
+                //FIXME: we shouldn't be doing this lookup twice
+                in.setSystemId(ClassLoaderUtil.getResource(fileName, getClass()).toString());
+                
                 Map dtdMappings = new HashMap();
                 dtdMappings.put("-//OpenSymphony Group//XWork 1.1.1//EN", "xwork-1.1.1.dtd");
                 dtdMappings.put("-//OpenSymphony Group//XWork 1.1//EN", "xwork-1.1.dtd");
                 dtdMappings.put("-//OpenSymphony Group//XWork 1.0//EN", "xwork-1.0.dtd");
                 
                 doc = DomHelper.parse(in, dtdMappings);
+            } catch (XworkException e) {
+                if (includeElement != null) {
+                    throw new ConfigurationException(e, includeElement);
+                } else {
+                    throw new ConfigurationException(e);
+                }
             } catch (Exception e) {
                 final String s = "Caught exception while loading file " + fileName;
                 LOG.error(s, e);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.