velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Utt <>
Subject Trouble Loading a Template from a WAR file - Velocity 1.4 - WLS 8.12
Date Tue, 15 Jun 2004 14:04:18 GMT
I am having trouble using the Velocity 1.4 package and
loading a template from a WAR file.  I can
successfully use the package with a command line java
application, but when I ported it into a servlet, I
get the infamous "Unable to find resource..." message.

I have tried to load the template with a generic
servlet as well as extending the VelocityServlet and I
seem to be missing an important step.  My .vm Template
files are in my deployed WAR file in the
WEB-INF/classes "folder" and I am running on Weblogic

Below is my servlet code:


public class DataDownloadServlet 
       extends VelocityServlet
  public Template handleRequest( 
         HttpServletRequest request, 
         HttpServletResponse response, 
         Context context ) 
  throws IOException, ServletException 
      //get the pool number to extract the data for.
      String[] reqVals = 

      String uri = request.getRequestURI();

      List beans = 

      Template template = null;
      String templateName = "";

      templateName = "PoolXML.vm";

          template = getTemplate(templateName);

          context.put("pools", beans);

          mergeTemplate(template, context, response);
      catch( ResourceNotFoundException rnfe )
        // couldn't find the template
        System.out.println("Template Not Found: " + 
                            templateName + 
                            ": " + rnfe.getMessage());
        throw new ServletException(rnfe);
      catch( ParseErrorException pee )
        // syntax error : problem parsing the template
        System.out.println("Prob Parsing template "+
                            templateName + 
                            ": " +pee.getMessage());
        throw new ServletException(pee);
      catch( Exception e )
        System.out.println("Weird Problem: " + 
        throw new ServletException(e);
    catch (Exception ex)
      System.out.println("Caughted exception: " + 

      throw new ServletException(ex);
    return null;


I have read about a file, but I
have not used one on my command line app and I was
hoping not to have to use one on the j2ee app, but I
might very well be wrong about that.  Any assistance
will be very much appreciated!

Thanks in advance!


Debugging is twice as hard as writing the code in the first place. Therefore, if you write
the code as cleverly as possible, you are, by definition, not smart enough to debug it. --Kernighan

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message