velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Malcolm Edgar" <malcolm.ed...@gmail.com>
Subject Re: How to use Velocity inside JBOSS
Date Thu, 06 Mar 2008 20:26:37 GMT
+1 on WebappResourceLoader.  This is used principly with Click
Framework, which we deploy on JBoss 3.2 & 4.

regards Malcolm Edgar

On Fri, Mar 7, 2008 at 7:21 AM, Nathan Bubna <nbubna@gmail.com> wrote:
> Using the FileResourceLoader in a webapp is a major pain and not very
>  portable.  You would be much better off using the
>  ClasspathResourceLoader or VelocityTools' WebappResourceLoader.
>
>
>
>  On Wed, Mar 5, 2008 at 8:33 AM, Cristi Cioriia
>  <cristi-cioriia@criticalsoftware.com> wrote:
>  > 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: user-unsubscribe@velocity.apache.org
>  >  For additional commands, e-mail: user-help@velocity.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>  For additional commands, e-mail: user-help@velocity.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message