You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Marc Logemann <de...@logemann.info> on 2002/06/26 12:53:44 UTC

relative folders and more...

> The way I do it is use the file resource loader, set my path to be
> /WEB-INF/templates, and then in my init(), munge the path via

>            String root = getServletContext().getRealPath(value);

yeah i ve done it the roughly the same way now, i define the path in the *.resource.loader.path
like WEB-INF/templates and then do the following in loadConfiguration()

      String path = p.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
      if (path != null) {
         path = getServletContext().getRealPath(path);
         if (path != null) {
            p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
         }
      }
      return p;

its based on servlet example2 and works quite well.

One thing i am astonished about is the point when i place the velocity log file inside
the webapp, i cant delete the webapp folder contents while tomcat is running. Even when i
stop my webapp context, the logfile is blocked. Only a complete stop of the tomcat
server releases the lock on the log file.

This is of course a little bit frustrating, cause i am doing some emulated hot-deploy
during development via tomcat ant tasks.

Does anyone know when and how the velocity log file will be released exactly?


---
greetings from
Marc Logemann
Homebase @ www.logemann.info


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: relative folders and more...

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 6/26/02 6:53 AM, "Marc Logemann" <de...@logemann.info> wrote:

>> The way I do it is use the file resource loader, set my path to be
>> /WEB-INF/templates, and then in my init(), munge the path via
> 
>>            String root = getServletContext().getRealPath(value);
> 
> yeah i ve done it the roughly the same way now, i define the path in the
> *.resource.loader.path
> like WEB-INF/templates and then do the following in loadConfiguration()
> 
>     String path = p.getProperty(Velocity.FILE_RESOURCE_LOADER_PATH);
>     if (path != null) {
>        path = getServletContext().getRealPath(path);
>        if (path != null) {
>           p.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, path);
>        }
>     }
>     return p;
> 
> its based on servlet example2 and works quite well.

Great.

> 
> One thing i am astonished about is the point when i place the velocity log
> file inside
> the webapp, i cant delete the webapp folder contents while tomcat is running.
> Even when i
> stop my webapp context, the logfile is blocked. Only a complete stop of the
> tomcat
> server releases the lock on the log file.
> 
> This is of course a little bit frustrating, cause i am doing some emulated
> hot-deploy
> during development via tomcat ant tasks.
> 
> Does anyone know when and how the velocity log file will be released exactly?
> 

It probably means that Tomcat isn't destroying the Velocity singleton in the
webapp.  What version of Tomcat?

Is this running under windows?  I thought you could kill the vel.log file
while things were running.  Maybe it's logkit (the default logger)? If so,
one cheap solution would be to try to use the dependency-free velocity jar,
put log4j into the webapp (along with commons-collections) and then try it
to see if it's really logkit...

If that doesn't do it, you could try to get away with rolling your own
version of VelocityServlet, switching to the non-Singleton usage pattern of
Velocity.  Then the velocity engine can be destroyed when the servlet is.

Caveats : 1) I'm just guessing 2) the above doesn't guarantee anything as
you don't know when the Vel instance would be GC'd.  Maybe you'll need some
kind of shutdown? (ug...)

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>