I just subscribed to velocity-dev and velocity-user, so please be easy with me
if these are FRB (frequently reported bugs).

First, the trivial.  It will really bothering me that build-velocity would
spooge recursively all over my classpath.  So, I "borrowed" a trick from the
Tomcat folks and took care of that problem.

Second, I didn't see anywhere in the .html documentation regarding the
necessity of having an init-param called 'properties' that contained the
fully-qualified path to my velocity.properties.  So, I fixed both of these
problems with a VelocityServlet patch.  I can understand if I presumed a
little much with that findPropertiesInClasspath() method (since that is a
design decision - but I +1 it :-)), but please leave the JavaDoc in.

Third, I don't know if anyone tests the examples, but it is a major turnoff to
have a new toy and not be able to play with the samples that come with it.
So, I repaired some cosmetic problems (SampleServlet was looking for
sample._w_m, contra sample._v_m that comes in examples), and the
FileTemplateLoader had been moved, so I updated the velocity.properties.

Along those lines, if you didn't have a runtime.log, it puked with (your
favorite, and mine...) a NullPointerException.  If you didn't provide a 
counter.initial.value, it puked with a NumberFormatException (null).
And, if that isn't enough fun for one night, if you didn't have a 
counter.name, it died with a ClassNotFound exception while trying to load
Foreach() in Runtime (MAN, that took me a while to track down).

  I hope these are half as useful to you as the are to me.
  -- /v\atthew
Index: examples/SampleServlet.java
===================================================================
RCS file: /home/cvspublic/jakarta-velocity/examples/SampleServlet.java,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 SampleServlet.java
94c94
<             outty =  getTemplate("sample.wm");
---
>             outty =  getTemplate("sample.vm");
Index: examples/velocity.properties
===================================================================
RCS file: /home/cvspublic/jakarta-velocity/examples/velocity.properties,v
retrieving revision 1.2
diff -r1.2 velocity.properties
7c7
< template.loader=org.apache.velocity.runtime.FileTemplateLoader
---
> template.loader=org.apache.velocity.runtime.loader.FileTemplateLoader
15a16,18
> runtime.log=.
> counter.name=velocityCounter
> counter.initial.value=0
Only in src\java: CVS
Only in src\java/org: CVS
Only in src\java/org/apache: CVS
Only in src\java/org/apache/velocity: CVS
Only in src\java/org/apache/velocity/convert: CVS
Only in src\java/org/apache/velocity/io: CVS
Only in src\java/org/apache/velocity/runtime: CVS
Only in src\java/org/apache/velocity/runtime/compiler: CVS
Only in src\java/org/apache/velocity/runtime/configuration: CVS
Only in src\java/org/apache/velocity/runtime: defaults
Only in src\java/org/apache/velocity/runtime/directive: CVS
Only in src\java/org/apache/velocity/runtime/exception: CVS
Only in src\java/org/apache/velocity/runtime/loader: CVS
Only in src\java/org/apache/velocity/runtime/log: CVS
Only in src\java/org/apache/velocity/runtime/parser: CVS
Only in src\java/org/apache/velocity/runtime/parser: Parser.jj
Only in src\java/org/apache/velocity/runtime/parser: Parser.jjt
Only in src\java/org/apache/velocity/runtime/parser: build
Only in src\java/org/apache/velocity/runtime/parser/node: CVS
Only in src\java/org/apache/velocity/runtime/visitor: CVS
Only in bin\src/org/apache/velocity/servlet: 1VelocityServlet.java
Only in src\java/org/apache/velocity/servlet: CVS
diff -r bin\src/org/apache/velocity/servlet/VelocityServlet.java 
src\java/org/apache/velocity/servlet/VelocityServlet.java
88,95d87
<  * Servlet Initial Parameters:<dl>
<  * <dt>properties
<  * <dd>The fully-qualified path (not relative to your WebApp, and in your
<  * local filesystem's syntax) to the <code>velocity.properties</code> file.<br>
<  * If you don't specify this, I will try to find it in your classpath, but
<  * that's not very friendly.
<  * </dl>
<  *
139,165d130
<     /**
<      * Locates the velocity.properties file via the classpath, ala WebMacro.
<      * This should only be called if the user did <b>not</b> provide their
<      * own path.
<      *@author Matthew L Daniel ([EMAIL PROTECTED])
<      *@return The pathname to the properties file, or null.
<      */
<      private String findPropertyInClasspath()
<      {
<         try
<         {
<             java.net.URL url = VelocityServlet.class.getClassLoader()
<                 .getResource("velocity.properties");
<             // We can't just return the URL.toString() here because it may
<             // contain file: in front of it, which the new File() in
<             // Runtime.init just pukes all over.
<             return (url == null) ?
<                 null :
<                 url.getFile();
<         }
<         catch( Exception e )
<         {
<             return null;
<         }
<      }
< 
< 
180,194d144
<         if( propsFile == null )
<         {
<             propsFile = findPropertyInClasspath();
<             if( propsFile == null )
<             {
<                 // Oh well, we tried...
<                 throw new ServletException(
<                 "You must provide an init-param 'properties'.");
<             }
<             // We can't very well log this, since the Runtime isn't hot...
<             System.err.println(
<             // Yes, I know this is ugly formatting, but would you rather I use
<             // expensive '+'s?
< "Velocity> WARNING: I found your velocity.properties using devious means.");
<         }
Only in src\java/org/apache/velocity/test: CVS
Only in src\java/org/apache/velocity/test/misc: CVS
Only in src\java/org/apache/velocity/test/provider: CVS
Only in src\java/org/apache/velocity/util: CVS
Index: build/build-velocity.bat
===================================================================
RCS file: /home/cvspublic/jakarta-velocity/build/build-velocity.bat,v
retrieving revision 1.8
diff -r1.8 build-velocity.bat
1a2
> if ".%OS%." == ".Windows_NT." setlocal
80a82
> if ".%OS%." == ".Windows_NT." endlocal

Reply via email to