Title: RE: Error processing template

It looks like you never even get to getTemplate(), as velocity would log that access, and certainly log if it couldn't find it.

Because the error handler from VelServlet is returning the html to you that you see, I bet something is throwing an exception earlier than the getTemplate().

Throw a few println's in and let us know...

geir


    -----Original Message-----
    From:   Ivan [SMTP:[EMAIL PROTECTED]]
    Sent:   Wednesday, January 17, 2001 12:37 PM
    To:     [EMAIL PROTECTED]
    Subject:        Error processing template

    I can't figure out what I'm doing wrong here:  I can't get
    Velocity/Tomcat to serve up a template. The Template and the Login are
    virtually the example servlet.  Near as I can figure, someone in
    Template.merge() is throwing an empty Exception.  (Thanks in advance.)

    Build: Apache-Velocity-20010117
    ==============Template===============
    <html>
    <head><title>Sample velocity page</title></head>
    <body bgcolor="#ffffff">
    <center>
    <h2>Hello from velocity!</h2>
    <i>Here's the list of people</i>
    <table cellspacing="0" cellpadding="5" width="100%">
        <tr>
            <td bgcolor="#eeeeee" align="center">
                Names
            </td>
        </tr>
        #foreach ($name in $theList)
        <tr>
            <td bgcolor="#eeeeee">$name</td>
        </tr>
        #end
    </table>
    </center>
    </html>
    ==================================

    ========Servlet=====================
    public class LoginServlet extends VelocityServlet
    {
        public Template handleRequest( Context ctx )
        {
            Template tmplReturn = null;
     HttpServletRequest request = (HttpServletRequest)ctx.get("req");
     String errorMessage = request.getQueryString();
     if ( errorMessage.length() > 0 )
         {
                ctx.put("inputError", errorMessage );
         }

            String p1 = "Ivan";
            String p2 = "Jen";

            Vector personList = new Vector();
            personList.addElement( p1 );
            personList.addElement( p2 );

            ctx.put("theList", personList );

            try
            {
                // Get the template
                tmplReturn =  getTemplate("webapps/BUCValuProf/login.vm");
            }
            catch( Exception e )
            {
                System.out.println("Error " + e);
            }
            return tmplReturn;
        }
    }
    ===============================================

    =======What I get back============================
    <html><body bgcolor="#ffffff"><h2>Error processing the
    template</h2>null</body></html>
    ===============================================

    ==========velocity log is no help to me=================
    Wed Jan 17 12:10:21 EST 2001   [info] Default Properties File:
    org/apache/velocity/runtime/defaults/velocity.properties
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    runtime.log =
    /opt/jakarta-tomcat-3.2.1/webapps/BUCValuProf/WEB-INF/logs/velocity.log
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.loader = org.apache.velocity.runtime.loader.FileTemplateLoader
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    counter.initial.value = 1
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    counter.name = velocityCounter
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.path = /opt/jakarta-tomcat-3.2.1/webapps/BUCValuProf
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    default.contentType = text/html
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.modificationCheckInterval = 2
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.asciihack = false
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.encoding = UTF8
    Wed Jan 17 12:10:21 EST 2001   [info]    ** Property Override :
    template.cache = false
    Wed Jan 17 12:10:21 EST 2001   [info] Log file being used is:
    /opt/jakarta-tomcat-3.2.1/webapps/BUCValuProf/WEB-INF/logs/velocity.log
    Wed Jan 17 12:10:21 EST 2001   [info] Resource Loader Instantiated:
    org.apache.velocity.runtime.resource.loader.FileResourceLoader
    Wed Jan 17 12:10:21 EST 2001   [info] Resources Loaded From:
    /opt/jakarta-tomcat-3.2.1/.
    Wed Jan 17 12:10:21 EST 2001   [info] Resource Loader Initialized.
    Wed Jan 17 12:10:21 EST 2001   [info] Loaded Pluggable Directive:
    org.apache.velocity.runtime.directive.Literal
    Wed Jan 17 12:10:21 EST 2001   [info] Loaded Pluggable Directive:
    org.apache.velocity.runtime.directive.Macro
    Wed Jan 17 12:10:21 EST 2001   [info] Loaded Pluggable Directive:
    org.apache.velocity.runtime.directive.Parse
    Wed Jan 17 12:10:21 EST 2001   [info] Loaded Pluggable Directive:
    org.apache.velocity.runtime.directive.Include
    Wed Jan 17 12:10:21 EST 2001   [info] Loaded Pluggable Directive:
    org.apache.velocity.runtime.directive.Foreach
    Wed Jan 17 12:10:21 EST 2001   [info] Created: 20 parsers.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : initialization
    starting.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : adding VMs from
    global VM library template : VM_global_library.vm
    Wed Jan 17 12:10:21 EST 2001   [info] Attempting to find
    VM_global_library.vm with
    org.apache.velocity.runtime.resource.loader.FileResourceLoader
    Wed Jan 17 12:10:21 EST 2001  [error] FileResourceLoader Error: cannot
    find resource /opt/jakarta-tomcat-3.2.1/./VM_global_library.vm
    Wed Jan 17 12:10:21 EST 2001  [error] java.lang.Exception: Can't find
    VM_global_library.vm!
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : global VM library
    template macro registration complete.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : no local VM library
    template used.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : allowInline = true :
    VMs can be defined inline in templates
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro :
    allowInlineToOverride = false : VMs defined inline may NOT replace
    previous VM definitions
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : allowInlineLocal =
    false : VMs defined inline will be  global in scope if allowed.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : messages on  : VM
    system will output information messages
    Wed Jan 17 12:10:21 EST 2001   [info] Velocimacro : initialization
    complete.
    Wed Jan 17 12:10:21 EST 2001   [info] Velocity successfully started.
    ======================================================================
    (Tomcat logs are equally uninformative.)


Reply via email to