Skip to content

Loading…

Fixes issue #18 #19

Open
wants to merge 1 commit into from

3 participants

@yortx

This commit fixes issue #18. It just replaces the use of the deprecated File.toURL() with the suggested File.toURI().toURL().
This allows sitemesh to find the configuration file in cases when the war file contains, for example, the '#' character (useful in tomcat to deploy to a subfolder).

@brianv0

Please merge this!

This fixes problems in tomcat where you deploy to a nested directory.
For example:
when deploying two applications with paths:

/rest/api1
/rest/api2

Tomcat deploys as:
/path/to/my/war/rest#api1/WEB-INF/sitemesh.xml
/path/to/my/war/rest#api2/WEB-INF/sitemesh.xml

The deprecated toURL call omits everything after # and you get an error on startup.

@eschulma

I need this also...and I see there are two pull requests for the exact same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 3, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/java/com/opensymphony/module/sitemesh/factory/DefaultFactory.java
View
6 src/java/com/opensymphony/module/sitemesh/factory/DefaultFactory.java
@@ -143,7 +143,7 @@ private Element loadSitemeshXML()
is = config.getServletContext().getResourceAsStream(configFileName);
}
else if (configFile.exists() && configFile.canRead()) {
- is = configFile.toURL().openStream();
+ is = configFile.toURI().toURL().openStream();
}
if (is == null){ // load the default sitemesh configuration
@@ -181,7 +181,7 @@ private void loadExcludes()
is = config.getServletContext().getResourceAsStream(excludesFileName);
}
else if (excludesFile.exists() && excludesFile.canRead()) {
- is = excludesFile.toURL().openStream();
+ is = excludesFile.toURI().toURL().openStream();
}
if (is == null){
@@ -308,4 +308,4 @@ private String replaceProperties(String str) {
}
return str;
}
-}
+}
Something went wrong with that request. Please try again.