Hi,
I have been trying to use Velocity in my own project, to generate some
content. Unfortunately, I haven't been able to make everything work by
myself and since I couldn't find any help on the net, I thought about
giving a try here.
So here it's what I'm trying to do: I created a helper class that uses
Velocity to generate some content and I use this helper class inside an
EJB, that is hosted in JBOSS. The way I did it, was to place Velocity
in my classpath and use it directly in my helper class(TemplateUtils)
like this:
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine
.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH,
RESOURCE_LOADER_PATH);
velocityEngine.init();
StringWriter out = new StringWriter();
velocityEngine.mergeTemplate(mailMessageTemplate,
templateContext.getContext(), out);
content = out.getBuffer().toString();
When JBOSS starts, the related Velocity log contains this line:
ERROR [VelocityEngine] ResourceManager : unable to find resource
'VM_global_library.vm' in any resource loader.
INFO [VelocityEngine] Velocimacro : error using VM library template
VM_global_library.vm : org.apache.velocity.exception.Reso
urceNotFoundException: Unable to find resource 'VM_global_library.vm'
I've searched for the file above and found it in JBOSS
\docs\examples\varia\deployment-service\templates.
So, my question would be if I need to perform any special configuration
to use Velocity inside JBOSS(currently I just have velocity 1.5 jar in
my .ear file and use it directly in the helper class as described above)
and where should I place the file configuring the Velocity engine. But
the most important problem I'm facing is that of specifying the
directory where my templates are located. When I specify the directory
absolute path, everything works fine, but when I try to specify it using
a relative path, the templates can't be find. I have defined the
template directory (RESOURCE_LOADER_PATH constant) relative to the class
TemplateUtils, where the Velocity code lies. But I get a
ResourceNotFoundException. So, is it possible to configure the resource
loader path using relative paths?
Thanks for your help.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]