Index: magnolia-core/src/main/java/info/magnolia/freemarker/FreemarkerServletContextWrapper.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- magnolia-core/src/main/java/info/magnolia/freemarker/FreemarkerServletContextWrapper.java (revision 39ae86d57615b753721054bb9ca1aae55d97664f) +++ magnolia-core/src/main/java/info/magnolia/freemarker/FreemarkerServletContextWrapper.java (revision ) @@ -60,8 +60,12 @@ /** - * Wraps the servlet context expecially for freemarker taglib resolution. This will trick freemarker TaglibFactory class - * to "see" all jars in classpath as if they were jars in /WEB-INF/lib + * Wraps the servlet context especially for freemarker taglib resolution. This will trick freemarker TaglibFactory class + * to "see" all jars in classpath as if they were jars in /WEB-INF/lib. + * + * On Windows systems the implementation of getResourcePaths will return absolute paths including the drive letter. When + * freemarker then calls getResource and getResourceAsStream we must not call the wrapped servlet context because its + * not a valid URL and it will fail with a MalformedURLException. See MAGNOLIA-5651. */ public class FreemarkerServletContextWrapper implements ServletContext { @@ -77,7 +81,10 @@ @Override public URL getResource(String path) throws MalformedURLException { - URL result = parentContext.getResource(path); + URL result = null; + if (path.startsWith("/")) { + result = parentContext.getResource(path); + } if (result == null) { // Trying the absolute path if the parent context fails. File file = new File(path); @@ -90,7 +97,11 @@ @Override public InputStream getResourceAsStream(String path) { - InputStream is = parentContext.getResourceAsStream(path); + + InputStream is = null; + if (path.startsWith("/")) { + is = parentContext.getResourceAsStream(path); + } if (is == null) { // Trying the absolute path if the parent context fails. File file = new File(path);