Velocity's DataSourceResourceLoader
In the current project I'm on, one of the major requirements is to have the ability to send job postings to job boards such as Monster.com, CareerBuilder.com, etc. - as well as local newspapers. When I first started this project, I went about contacting all of these advertisers and explained that we'd like to automate the process of talking to their system. I found that many of them preferred a simple e-mail with the job posting, but others wanted us to FTP a pre-formatted document to them.
I figure the easiest way to handle this is to use Velocity. By using Velocity, and storing templates in the database, users of the system can either (1) use a default template or (2) customize a template for a specific advertiser. This was all easy enough since we're using Struts Resume as a baseline for this project, and Velocity is already built-in.
I remembered seeing that Velocity had some sort of database ResourceLoader, so I went searching and found the DataSourceResourceLoader:
This loader will load resources from a DataSource such as a database. This loader is not built as part of the standard build as it requires J2EE support. To build this loader, please download the J2EE distribution, move the j2ee.jar into the build/lib directory, and then build the new velocity jar with the jar-j2ee build target. For more information on this loader, please see the javadoc for DataSourceResourceLoader.
After checking out Velocity 1.4.1 RC1 (are they ever going to release this thing?) from CVS, I was able to build a new Velocity JAR. To compile using J2EE 1.4, you have to modify the VelocityServletTest, or delete it. I then replaced velocity-1.4-rc1.jar with this new JAR (which is actually 4KB smaller), configured velocity.properties and Voila - it worked! Clean and easy integration - just the way I like it.
Posted by Ian Spence on May 11, 2004 at 06:45 AM MDT #
Posted by Matt Raible on May 11, 2004 at 02:58 PM MDT #
org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSource' of bean class [org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader]: Bean property 'dataSource' is not writable or has an invalid setter method: Does the parameter type of the setter match the return type of the getter?
Having looked at the source and the posts on velocity's JIRA it seems as though I do indeed have the wrong version.
Any idea where I can get the correct code? Perhaps I should ask the velocity group?
Thanks if you can help!
Posted by Paul Feaviour on March 13, 2006 at 05:09 PM MST #