Cheers for you help so far Nathan.

The AutoMatchingServlet extends VelocityViewServlet.

I've checked the logs and yes, the WebappLoader is being used and the 
webapp.resource.loader.path is being set to /templates/

So not sure why it doesn't pick up the template.

the directory structure for my automatch webapp is

$CATALINA_HOME/webapps/automatch/
        WEB-INF/
                web.xml
                velocity.properties
        templates/
                trade_profile.vm



the call to getTemplate is simply...

Template template = Velocity.getTemplate("trade_profile.vm");


Here are the relevant sections from the localhost and catalina log files...

localhost.log file:

24-Jul-2008 16:48:01 org.apache.catalina.core.ApplicationContext log
INFO: org.apache.webapp.balancer.BalancerFilter: init(): ruleChain: 
[org.apache.webapp.balancer.RuleChain: 
[org.apache.webapp.balancer.rules.URLStringMatchRule: Target string: News / 
Redirect URL: http://www.cnn.com], 
[org.apache.webapp.balancer.rules.RequestParameterRule: Target param name: 
paramName / Target param value: paramValue / Redirect URL: 
http://www.yahoo.com], [org.apache.webapp.balancer.rules.AcceptEverythingRule: 
Redirect URL: http://jakarta.apache.org]]
24-Jul-2008 16:48:01 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
24-Jul-2008 16:48:01 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
24-Jul-2008 16:48:02 org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
24-Jul-2008 16:48:02 org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity   [info] VelocityViewServlet: Using custom properties at 
'/WEB-INF/velocity.properties'
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : 
*******************************************************************
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Starting Apache Velocity v1.5 (compiled: 2007-02-22 
08:52:29)
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : RuntimeInstance initializing.
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Default Properties File: 
org\apache\velocity\runtime\defaults\velocity.properties
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Trying to use logger class 
org.apache.velocity.tools.view.servlet.ServletLogger
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity   [info] LogSystem has been deprecated. Please use a LogChute 
implementation.
24-Jul-2008 16:48:30 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Default ResourceManager initializing. (class 
org.apache.velocity.runtime.resource.ResourceManagerImpl)
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] ResourceLoader instantiated: 
org.apache.velocity.tools.view.servlet.WebappLoader
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] WebappLoader : initialization starting.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity   [info] WebappLoader : added template path - '/templates/'
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] WebappLoader : initialization complete.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] ResourceCache: initialized (class 
org.apache.velocity.runtime.resource.ResourceCacheImpl)
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : Default ResourceManager initialization complete.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Loaded System Directive: 
org.apache.velocity.runtime.directive.Literal
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Loaded System Directive: 
org.apache.velocity.runtime.directive.Macro
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Loaded System Directive: 
org.apache.velocity.runtime.directive.Parse
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Loaded System Directive: 
org.apache.velocity.runtime.directive.Include
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Loaded System Directive: 
org.apache.velocity.runtime.directive.Foreach
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Created '20' parsers.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : Velocimacro : initialization starting.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : "velocimacro.library" is not set.  
Trying default library: VM_global_library.vm
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : Default library not found.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : allowInline = true : VMs can be defined 
inline in templates
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : allowInlineToOverride = false : VMs 
defined inline may NOT replace previous VM definitions
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : allowInlineLocal = false : VMs defined 
inline will be global in scope if allowed.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  [debug] Velocimacro : autoload off : VM system will not 
automatically reload global library macros
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : Velocimacro : Velocimacro : initialization complete.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity  : RuntimeInstance successfully initialized.
24-Jul-2008 16:48:31 org.apache.catalina.core.ApplicationContext log
INFO:  Velocity   [info] VelocityViewServlet: Default content-type is: text/html

--- --- --- ------ ------ ------ ------ ------ ------ ---

Catalina.log file

24-Jul-2008 16:47:59 org.apache.coyote.http11.Http11BaseProtocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
24-Jul-2008 16:48:00 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 719 ms
24-Jul-2008 16:48:00 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
24-Jul-2008 16:48:00 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.26
24-Jul-2008 16:48:00 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
24-Jul-2008 16:48:02 org.apache.catalina.startup.ContextConfig 
authenticatorConfig
SEVERE: Cannot configure an authenticator for method CUSTFORM5
24-Jul-2008 16:48:02 org.apache.catalina.startup.ContextConfig start
SEVERE: Marking this application unavailable due to previous error(s)
24-Jul-2008 16:48:02 org.apache.catalina.core.StandardContext start
SEVERE: Error getConfigured
24-Jul-2008 16:48:02 org.apache.catalina.core.StandardContext start
SEVERE: Context [/slice] startup failed due to previous errors
24-Jul-2008 16:48:02 org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
24-Jul-2008 16:48:03 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
24-Jul-2008 16:48:03 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/47  config=null
24-Jul-2008 16:48:03 org.apache.catalina.startup.Catalina start
INFO: Server startup in 3141 ms
24-Jul-2008 16:48:31 
org.apache.velocity.tools.view.servlet.ServletToolboxManager getInstance
INFO: Using config file '/WEB-INF/toolbox.xml'
24-Jul-2008 16:48:31 org.apache.velocity.runtime.log.JdkLogChute log
INFO: FileResourceLoader : adding path '.'
24-Jul-2008 16:48:32 org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'trade_profile.vm' in any 
resource loader.




-----Original Message-----
From: Nathan Bubna [mailto:[EMAIL PROTECTED]
Sent: 24 July 2008 16:16
To: Velocity Users List
Subject: Re: velocity.properties isn't being read

Does the AutoMatchingServlet extend the VelocityViewServlet or
VelocityLayoutServlet?  If not, then it needs to do so (or else you
have a more work cut out for you :).  If it does extend one of those,
then i'm very confused as to why this isn't working, and would next
want to see what your logs say when you load the servlet.

On Thu, Jul 24, 2008 at 1:55 AM, LAU, Roger, GBM <[EMAIL PROTECTED]> wrote:
> OK, thanks for that. Here's my web.xml file.
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <web-app 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";
>        version="2.4">
>
>        <display-name>AutoMatching Tool</display-name>
>        <description>
>                AutoMatching Tool
>        </description>
>
>        <servlet>
>                <servlet-name>automatchingServlet</servlet-name>
>
>                
> <servlet-class>gbmft.automatch.AutoMatchingServlet</servlet-class>
>
>                <init-param>
>                        <param-name>org.apache.velocity.toolbox</param-name>
>                        <param-value>/WEB-INF/toolbox.xml</param-value>
>                </init-param>
>
>                <init-param>
>                        <param-name>org.apache.velocity.properties</param-name>
>                        <param-value>/WEB-INF/velocity.properties</param-value>
>                </init-param>
>        </servlet>
>
>        <servlet-mapping>
>                <servlet-name>automatchingServlet</servlet-name>
>                <url-pattern>*.vm</url-pattern>
>        </servlet-mapping>
> </web-app>
>
>
> -----Original Message-----
> From: Nathan Bubna [mailto:[EMAIL PROTECTED]
> Sent: 23 July 2008 17:47
> To: Velocity Users List
> Subject: Re: velocity.properties isn't being read
>
> your velocity.properties file looks fine, and if you are using
> VelocityTools 1.4, then it should say in the logs if it managed to
> load a custom velocity.properties.  So, it looks like your web.xml
> still needs some adjustment.  Could you post that as it currently is?
>
> Finally, you only need to use one of the velocity-tools-*-1.4.jar
> files.  If you are using VelocityStruts, then use the
> velocity-tools-1.4.jar.  If you are just using
> VelocityViewServlet/VelocityLayoutServet and don't need Struts 1.x
> integration, then just use the velocity-tools-view-1.4.jar.  It
> includes all of the classes in the velocity-tools-generic-1.4.jar
> already, so that is unnecessary.
>
> On Wed, Jul 23, 2008 at 9:32 AM, LAU, Roger, GBM <[EMAIL PROTECTED]> wrote:
>> I'm using
>>
>> velocity-tools-1.4.jar
>> velocity-tools-generic-1.4.jar
>> velocity-tools-view-1.4.jar
>>
>> velocity.properties file....
>>
>> # config file
>> #
>> webapp.resource.loader.path = /templates/
>> velocimacro.library = macro_library.vm
>>
>> # Filepath for error template, relative to web application root directory
>> #
>> tools.view.servlet.error.template = error.vm
>>
>> # Directory for layout templates, relative to web application root directory
>> #
>> tools.view.servlet.layout.directory = layout/
>>
>> # Filepath of the default layout template relative to the layout directory
>> # NOT relative to the root directory of the webapp!
>> #
>> tools.view.servlet.layout.default.template =  default.vm
>>
>>
>> Thanks
>> Roger
>>
>> -----Original Message-----
>> From: Nathan Bubna [mailto:[EMAIL PROTECTED]
>> Sent: 23 July 2008 17:26
>> To: Velocity Users List
>> Subject: Re: velocity.properties isn't being read
>>
>> ok, just to keep things straight.  what version of VelocityTools are
>> you using?  and can i see your whole velocity.properties file?
>>
>> On Wed, Jul 23, 2008 at 9:03 AM, LAU, Roger, GBM <[EMAIL PROTECTED]> wrote:
>>> thanks for the fast reply Nathan.
>>>
>>> OK, I've added the following to velocity.properties
>>>
>>> webapp.resource.loader.path = /templates/
>>>
>>> I've updated my web.xml as you suggested. Now when I'm getting this output 
>>> on stdout...
>>>
>>> INFO: Server startup in 1844 ms
>>> 23-Jul-2008 16:54:51 
>>> org.apache.velocity.tools.view.servlet.ServletToolboxManager getInstance
>>> INFO: Using config file '/WEB-INF/toolbox.xml'
>>> 23-Jul-2008 16:54:52 org.apache.velocity.runtime.log.JdkLogChute log
>>> INFO: FileResourceLoader : adding path '.'
>>> 23-Jul-2008 16:54:52 org.apache.velocity.runtime.log.JdkLogChute log
>>> SEVERE: ResourceManager : unable to find resource 'trade_profile.vm' in any 
>>> resource loader.
>>>
>>>
>>> It looks like it's still using the FileResourceLoader.
>>> I also tried adding the following to velocity.properties
>>>
>>> resource.loader = webapp
>>>
>>> and got the same result as above. I then tried the following entry
>>>
>>> resource.loader =
>>>
>>> with the same results. Any ideas?
>>>
>>> -----Original Message-----
>>> From: Nathan Bubna [mailto:[EMAIL PROTECTED]
>>> Sent: 23 July 2008 16:44
>>> To: Velocity Users List
>>> Subject: Re: velocity.properties isn't being read
>>>
>>> answers below...
>>>
>>> On Wed, Jul 23, 2008 at 6:50 AM, LAU, Roger, GBM <[EMAIL PROTECTED]> wrote:
>>>> Hi,
>>>>
>>>> I'm trying to get a webapp to read template files from a template 
>>>> directory located under the web application root /template/
>>>>
>>>> I tried to use the Velocity Singleton with the FileResourceLoader, 
>>>> specifying different paths in velocity.properties such as
>>>>
>>>> file.resource.loader.path = ../webapps/app_name/template/
>>>>
>>>> But no matter what I set the path to, velocity still seems to use the 
>>>> default FileResourceLoader path of '.'
>>>>
>>>> I've confirmed this by placing a template in $CATALINA_HOME/bin
>>>> where velocity is able to find the template correctly. It seems as though 
>>>> the velocity.properties file isn't being read.
>>>>
>>>> Here is my web.xml file. You can see I've got the <init-param>
>>>>
>>>> <web-app 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";
>>>>          version="2.4">
>>>>
>>>>          <servlet>
>>>>                   <servlet-name>automatchingServlet</servlet-name>
>>>>
>>>>                   
>>>> <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>>>>
>>>>                   <init-param>
>>>>                             
>>>> <param-name>org.apache.velocity.toolbox</param-name>
>>>>                             <param-value>/WEB-INF/toolbox.xml</param-value>
>>>>                   </init-param>
>>>>
>>>>                   <init-param>
>>>>                             <param-name>properties</param-name>
>>>>                             
>>>> <param-value>/WEB-INF/velocity.properties</param-value>
>>>>                   </init-param>
>>>
>>> this should be <param-name>org.apache.velocity.properties</param-name>
>>>
>>>>          </servlet>
>>>>
>>>>          <servlet-mapping>
>>>>                   <servlet-name>automatchingServlet</servlet-name>
>>>>                   <url-pattern>*.vm</url-pattern>
>>>>          </servlet-mapping>
>>>> </web-app>
>>>>
>>>> How do I configure the FileResourceLoader to find my template files? I've 
>>>> read several posts and although the WebappResourceLoader would be a good 
>>>> solution, but I'm not able to use a beta version of velocity tools.
>>>
>>> so don't use the beta version. :)  in VelocityTools 1.1 thru 1.4, the
>>> default resource loader is the WebappLoader.   It works just as well
>>> as the WebappResourceLoader in VelocityTools 2.x, because it is the
>>> same class, just renamed to properly fit the conventions for resource
>>> loader naming.  really, there is no need for the FileResourceLoader.
>>> just change the param-name above and add this to your
>>> velocity.properties:
>>>
>>> webapp.resource.loader.path = /template/
>>>
>>> that should do the trick.
>>>
>>>> Thanks
>>>> Roger
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> ***********************************************************************************
>>>> The Royal Bank of Scotland plc. Registered in Scotland No 90312. 
>>>> Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB.
>>>> Authorised and regulated by the Financial Services Authority
>>>>
>>>> This e-mail message is confidential and for use by the
>>>> addressee only. If the message is received by anyone other
>>>> than the addressee, please return the message to the sender
>>>> by replying to it and then delete the message from your
>>>> computer. Internet e-mails are not necessarily secure. The
>>>> Royal Bank of Scotland plc does not accept responsibility for
>>>> changes made to this message after it was sent.
>>>>
>>>> Whilst all reasonable care has been taken to avoid the
>>>> transmission of viruses, it is the responsibility of the recipient to
>>>> ensure that the onward transmission, opening or use of this
>>>> message and any attachments will not adversely affect its
>>>> systems or data. No responsibility is accepted by The
>>>> Royal Bank of Scotland plc in this regard and the recipient should carry
>>>> out such virus and other checks as it considers appropriate.
>>>> Visit our websites at:
>>>> www.rbs.com
>>>> www.rbs.com/gbm
>>>> www.rbsgc.com
>>>> ***********************************************************************************
>>>>
>>>> ______________________________________________________________________
>>>> This email has been scanned by the MessageLabs Email Security System.
>>>> For more information please visit http://www.messagelabs.com/email
>>>> ______________________________________________________________________
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>> ______________________________________________________________________
>>> This email has been scanned by the MessageLabs Email Security System.
>>> For more information please visit http://www.messagelabs.com/email
>>> ______________________________________________________________________
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>> ______________________________________________________________________
>> This email has been scanned by the MessageLabs Email Security System.
>> For more information please visit http://www.messagelabs.com/email
>> ______________________________________________________________________
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to