# HG changeset patch # User robcast # Date 1405949539 -7200 # Node ID 32eb36e6c9d2b4f43554edcea973a50202dd64a4 # Parent 09424acc221675007c7c300dcae0e45074032c6e fix problem that getRealPath of Tomcat 8 needs paths to start with '/'. diff -r 09424acc2216 -r 32eb36e6c9d2 servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java --- a/servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java Thu Jul 17 15:17:32 2014 +0200 +++ b/servlet/src/main/java/digilib/conf/DigilibServletConfiguration.java Mon Jul 21 15:32:19 2014 +0200 @@ -183,7 +183,8 @@ String fn = c.getInitParameter("config-file"); if (fn == null) { logger.debug("readConfig: no param config-file"); - fn = ServletOps.getConfigFile("digilib-config.xml", c); + fn = ServletOps.getConfigFileName("digilib-config.xml", c); + if (fn == null) fn = ""; } File f = new File(fn); if (f.canRead()) { @@ -314,7 +315,7 @@ */ // set up the logger File logConf = ServletOps.getConfigFile((File) config.getValue("log-config-file"), context); - if (logConf.canRead()) { + if (logConf != null && logConf.canRead()) { DOMConfigurator.configure(logConf.getAbsolutePath()); config.setValue("log-config-file", logConf); } diff -r 09424acc2216 -r 32eb36e6c9d2 servlet/src/main/java/digilib/servlet/ServletOps.java --- a/servlet/src/main/java/digilib/servlet/ServletOps.java Thu Jul 17 15:17:32 2014 +0200 +++ b/servlet/src/main/java/digilib/servlet/ServletOps.java Mon Jul 21 15:32:19 2014 +0200 @@ -87,7 +87,7 @@ // is the filename absolute? if (!f.isAbsolute()) { // relative path -> use getRealPath to resolve in WEB-INF - String fn = sc.getRealPath(f.getPath()); + String fn = sc.getRealPath("/" + f.getPath()); if (fn == null) { // TODO: use getResourceAsStream? return null; @@ -112,7 +112,7 @@ // is the filename absolute? if (!f.isAbsolute()) { // relative path -> use getRealPath to resolve in WEB-INF - filename = sc.getRealPath(filename); + filename = sc.getRealPath("/" + filename); } return filename; } @@ -141,8 +141,8 @@ } } // relative path -> use getRealPath to resolve in WEB-INF - String newfn = sc.getRealPath("WEB-INF/" + fn); - if (fn == null) { + String newfn = sc.getRealPath("/WEB-INF/" + fn); + if (newfn == null) { // TODO: use getResourceAsStream? return null; } @@ -160,12 +160,12 @@ * @param sc * @return */ - public static String getConfigFile(String filename, ServletContext sc) { + public static String getConfigFileName(String filename, ServletContext sc) { File f = new File(filename); // is the filename absolute? if (!f.isAbsolute()) { // relative path -> use getRealPath to resolve in WEB-INF - filename = sc.getRealPath("WEB-INF/" + filename); + filename = sc.getRealPath("/WEB-INF/" + filename); } return filename; } diff -r 09424acc2216 -r 32eb36e6c9d2 webapp/src/main/webapp/server/dlConfig.jsp --- a/webapp/src/main/webapp/server/dlConfig.jsp Thu Jul 17 15:17:32 2014 +0200 +++ b/webapp/src/main/webapp/server/dlConfig.jsp Mon Jul 21 15:32:19 2014 +0200 @@ -90,7 +90,9 @@ } else { if (!f.isAbsolute()) { // relative path -> use getRealPath to resolve - f = new File(pageContext.getServletContext().getRealPath(f.getPath())); + String fn = pageContext.getServletContext().getRealPath("/" + f.getPath()); + if (fn == null) fn = ""; + f = new File(fn); } if (f.canRead()) { val = f.toString(); diff -r 09424acc2216 -r 32eb36e6c9d2 webapp/src/main/webapp/server/dlRequest.jsp --- a/webapp/src/main/webapp/server/dlRequest.jsp Thu Jul 17 15:17:32 2014 +0200 +++ b/webapp/src/main/webapp/server/dlRequest.jsp Mon Jul 21 15:32:19 2014 +0200 @@ -72,7 +72,7 @@