title: Java Spring MVC ScriptTemplateViewConfigurer can't find javascript resources
body: <p>I'm trying to create a small test webapp with javascript based templates. Since Spring 4.2.0 there is a special ScriptTemplateViewResolver class for this. While deploying my app on local  tomcat (8.0.21) server, I'm getting the following exception:</p>
  
  <pre><code>java.lang.IllegalStateException: Resource /WEB-INF/resources/js/lib/ejs.min.js not found
  at org.springframework.web.servlet.view.script.ScriptTemplateView.loadScripts(ScriptTemplateView.java:234)
  </code></pre>
  
  <p>Here is webapp directory structure:</p>
  
  <pre><code>src/main/java/com/itsl/mercado/pages/PagesController.java   &lt;-- here my controller lives
  src/main/webapp/WEB-INF/pages/index.ejs                     &lt;-- index page template
  src/main/webapp/WEB-INF/pages/index.jsp                     &lt;-- index.jsp is here also (for debug experiment)
  src/main/webapp/WEB-INF/resources/js/lib/ejs.min.js         &lt;-- javascript libraries (EJS in my case)
  src/main/webapp/WEB-INF/resources/js/render.js              &lt;-- javascript render function
  src/main/webapp/WEB-INF/pages-servlet.xml                   &lt;-- servlet context config
  src/main/webapp/WEB-INF/web.xml                             &lt;-- here web.xml lives
  </code></pre>
  
  <p>Here is web.xml:</p>
  
  <pre><code>&lt;web-app version="2.4"
  xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
  &lt;display-name&gt;Spring MVC Application&lt;/display-name&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;pages&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;pages&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And pages-servlet.xml:</p>
  
  <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:context="http://www.springframework.org/schema/context"
     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
      http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  &lt;mvc:annotation-driven /&gt;
  
  &lt;context:component-scan base-package="com.itsl.mercado.pages"/&gt;
  
  &lt;mvc:view-resolvers&gt;
      &lt;mvc:script-template prefix="/WEB-INF/pages/" suffix=".ejs"/&gt;
  &lt;/mvc:view-resolvers&gt;
  &lt;mvc:script-template-configurer engine-name="nashorn" render-function="render"&gt;
      &lt;mvc:script location="/WEB-INF/resources/js/lib/ejs.min.js" /&gt;
      &lt;mvc:script location="/WEB-INF/resources/js/render.js" /&gt;
  &lt;/mvc:script-template-configurer&gt;
  &lt;!--&lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;--&gt;
      &lt;!--&lt;property name="prefix" value="/WEB-INF/pages/"/&gt;--&gt;
      &lt;!--&lt;property name="suffix" value=".jsp"/&gt;--&gt;
  &lt;!--&lt;/bean&gt;--&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>The strange thing is that when I comment ScriptTemplateViewResolver and uncomment InternalResourceViewResolver it manages to find index.jsp, but, however, it fails to find /WEB-INF/resources/js/lib/ejs.min.js</p>
  
  <p>Also, I've tried following in pages-servlet.xml (without any other result):</p>
  
  <pre><code>&lt;mvc:annotation-driven /&gt;
  
  &lt;context:component-scan base-package="com.itsl.mercado.pages"/&gt;
  
  &lt;mvc:view-resolvers&gt;
      &lt;mvc:script-template prefix="/WEB-INF/pages/" suffix=".ejs"/&gt;
  &lt;/mvc:view-resolvers&gt;
  &lt;mvc:script-template-configurer engine-name="nashorn" render-function="render"&gt;
      &lt;mvc:script location="/resources/js/lib/ejs.min.js" /&gt;
      &lt;mvc:script location="/resources/js/render.js" /&gt;
  &lt;/mvc:script-template-configurer&gt;
  &lt;mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"/&gt;
  &lt;mvc:default-servlet-handler /&gt;
  </code></pre>
  
  <p>If anyone has an idea, please, help me to figure out how to deal with the problem. Thanks in advance.                               </p>