File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem with velocity templates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with velocity templates" Watch "Problem with velocity templates" New topic

Problem with velocity templates

Pablo Mu�iz

Joined: Jan 19, 2004
Posts: 5
I'm developing a project with two separate webapps using struts+velocity+jboss.
I've noticed that when I deploy both webapps velocity gets confused and retrieve wrong templates.
In fact, when I access index.vm in webapp_1 I get index.vm of webapp_2.
Reading velocity docs I've figured out VelocityViewServlet uses a singleton model, wich could be why I have this problem.
In both webapps the web.xml looks like this :

Does anyone know why velocity doesn�t looks for the templates in the wright place? Maybe I have something wrong in the configuration?
Is there any way of using velocity in two independent webapps, each using .vm templates in its WAR file?
Thanks in advance.
Greetings, Pablo.
Ken Krebs
Ranch Hand

Joined: Nov 27, 2002
Posts: 451
I don't have any experience with Velocity in webapps at this point but it very well might be that Velocity can't find the properties files. You probably need to place them in /WEB-INF/classes instead of /WEB-INF so they are on the classpath. That's my best guess.

kktec<br />SCJP, SCWCD, SCJD<br />"What we observe is not nature itself, but nature exposed to our method of questioning." - Werner Heisenberg
I agree. Here's the link:
subject: Problem with velocity templates
jQuery in Action, 3rd edition