velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From laredotornado <laredotorn...@gmail.com>
Subject Classpath troubles (ResourceNotFoundException)
Date Mon, 11 Jul 2011 14:12:18 GMT

Hi,

I'm trying to test something using Velocity 1.6.2 in JUnit 4, but I'm having
trouble getting Velocity to find my email template.  I have verified in the
JUnit test that both my velocity.properties and emailTemplate.vm file can be
found on the classpath, yet I get a "ResourceNotFoundException" on the
'Velocity.getTemplate("email_template.vm");' line of the code below ...

	@Test
	public void testJob() throws Exception {
		try {
			InputStream stream =
Thread.currentThread().getContextClassLoader().getResourceAsStream("email_template.vm");
			log.info("stream:" + stream);
			
			InputStream stream2 =
Thread.currentThread().getContextClassLoader().getResourceAsStream("velocity.properties");
			log.info("stream2:" + stream2);
			
			Velocity.init();
			
			final Template template = Velocity.getTemplate("email_template.vm");

Here is my velocity.properties file

=============Begin velocity.properties =========================
#
# velocity.properties - example configuration
#


# uncomment the next two lines to load templates from the
# classpath (WEB-INF/classes)
resource.loader=class
class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
==============End velocity.properties =========================



Any ideas?  I'm using Maven 3.0.3 and placing the velocity.properties file
in my src/test/resources directory.  The email template file lives in the
same place.  Thanks for any advice, - Dave
-- 
View this message in context: http://old.nabble.com/Classpath-troubles-%28ResourceNotFoundException%29-tp32037826p32037826.html
Sent from the Velocity - User mailing list archive at Nabble.com.


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


Mime
View raw message