Velocity
  1. Velocity
  2. VELOCITY-551

IncludeNotFound event handler not including the "notfound" page

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Linux (Fedora Core 5) / OSX 10.4.9
      Java 6
      Tomcat 6.0.10
      Struts2

      Description

      The IncludeNotFound event handler claims in the log "Can't find include not found
      page: " even though the "notfound" page exists.

      I've tracked this in the source:
      ------------------------------------------------
      boolean exists = (rs.getLoaderNameForResource(includeResourcePath) != null);
      if (!exists)
      {
      if (rs.getLoaderNameForResource(notfound) == null)

      { return notfound; }

      else

      { /** * can't find not found, so display nothing */ rs.getLog().error("Can't find include not found page: " + notfound); return null; }

      }
      else
      return includeResourcePath;
      ---------------------------------------------------

      I think the condition:

      if (rs.getLoaderNameForResource(notfound) == null)

      should read:

      if (rs.getLoaderNameForResource(notfound) != null)

      Changing this fixed the problem for me.

        Activity

        Hide
        Will Glass-Husain added a comment -

        Thanks! Did you confirm "ant test" worked?

        Show
        Will Glass-Husain added a comment - Thanks! Did you confirm "ant test" worked?
        Hide
        Michiel Toneman added a comment -

        Sorry, I haven't. Velocity 1.5 doesn't build for me on Java 6 and I have no time at the moment to spend on it.

        ------------------------------------------------
        compile-test:
        [javac] Compiling 4 source files to /Users/michiel/src/velocity-1.5/bin/test-classes
        [javac] /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java:31: org.apache.velocity.test.sql.HsqlDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
        [javac] public class HsqlDataSource implements DataSource {
        [javac] ^
        [javac] Note: /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java uses unchecked or unsafe operations.
        [javac] Note: Recompile with -Xlint:unchecked for details.
        [javac] 1 error
        ------------------------------------------------

        Show
        Michiel Toneman added a comment - Sorry, I haven't. Velocity 1.5 doesn't build for me on Java 6 and I have no time at the moment to spend on it. ------------------------------------------------ compile-test: [javac] Compiling 4 source files to /Users/michiel/src/velocity-1.5/bin/test-classes [javac] /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java:31: org.apache.velocity.test.sql.HsqlDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource [javac] public class HsqlDataSource implements DataSource { [javac] ^ [javac] Note: /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] 1 error ------------------------------------------------
        Hide
        Will Glass-Husain added a comment -

        Patch applied. The odd thing is, we had a unit test for this but the unit test was wrong. Thanks for catching it.

        Show
        Will Glass-Husain added a comment - Patch applied. The odd thing is, we had a unit test for this but the unit test was wrong. Thanks for catching it.
        Hide
        Will Glass-Husain added a comment -

        Also – quick note on the other issue. I tried building and running under JDK 1.6 – worked fine. If you try again, try "ant clean" then "ant test" and see if that works.

        Show
        Will Glass-Husain added a comment - Also – quick note on the other issue. I tried building and running under JDK 1.6 – worked fine. If you try again, try "ant clean" then "ant test" and see if that works.
        Hide
        Michiel Toneman added a comment -

        Hi Will,

        Thanks for fixing.... Still having the issue with the compile-test target, even after ant clean.

        compile-test:
        [javac] Compiling 79 source files to /Users/michiel/src/velocity-1.5/bin/test-classes
        [javac] /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java:31: org.apache.velocity.test.sql.HsqlDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource
        [javac] public class HsqlDataSource implements DataSource {

        This seems very similar to (e.g.):

        http://opensource.atlassian.com/projects/spring/browse/SPR-1841

        I was able to get the test cases to work (compile and run) by quickly changing HsqlDataSource.java:

        26,27d25
        < import java.sql.BaseQuery;
        < import java.sql.QueryObjectGenerator;
        79,94d76
        <
        < public <T extends BaseQuery> T createQueryObject(Class<T> arg0) throws SQLException

        { < // TODO Auto-generated method stub < return null; < }
        <
        < public <T extends BaseQuery> T createQueryObject(Class<T> arg0, DataSource arg1) throws SQLException { < // TODO Auto-generated method stub < return null; < }

        <
        < public QueryObjectGenerator getQueryObjectGenerator() throws SQLException

        { < // TODO Auto-generated method stub < return null; < }

        <

        By the way, I'm using ant version 1.7.0

        Show
        Michiel Toneman added a comment - Hi Will, Thanks for fixing.... Still having the issue with the compile-test target, even after ant clean. compile-test: [javac] Compiling 79 source files to /Users/michiel/src/velocity-1.5/bin/test-classes [javac] /Users/michiel/src/velocity-1.5/bin/test-src/org/apache/velocity/test/sql/HsqlDataSource.java:31: org.apache.velocity.test.sql.HsqlDataSource is not abstract and does not override abstract method <T>createQueryObject(java.lang.Class<T>,javax.sql.DataSource) in javax.sql.DataSource [javac] public class HsqlDataSource implements DataSource { This seems very similar to (e.g.): http://opensource.atlassian.com/projects/spring/browse/SPR-1841 I was able to get the test cases to work (compile and run) by quickly changing HsqlDataSource.java: 26,27d25 < import java.sql.BaseQuery; < import java.sql.QueryObjectGenerator; 79,94d76 < < public <T extends BaseQuery> T createQueryObject(Class<T> arg0) throws SQLException { < // TODO Auto-generated method stub < return null; < } < < public <T extends BaseQuery> T createQueryObject(Class<T> arg0, DataSource arg1) throws SQLException { < // TODO Auto-generated method stub < return null; < } < < public QueryObjectGenerator getQueryObjectGenerator() throws SQLException { < // TODO Auto-generated method stub < return null; < } < By the way, I'm using ant version 1.7.0

          People

          • Assignee:
            Unassigned
            Reporter:
            Michiel Toneman
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development