You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Michael Oliver <ol...@alariussystems.com> on 2005/08/03 18:15:24 UTC

template path

I would like to set a property in the Velocity Engine so I can load a
template from the classpath.

I have a number of different templates that are related to various packages
and classes and it would be easier if I built my jar file with the templates
in the same path as the classes.

I would then name the templates the same and change the template path to
match the package path of the class it relates to.

Is the following the right way?

/*
 * create a new instance of the engine
 */
VelocityEngine ve = new VelocityEngine();
/*
  * configure the engine. In this case, we are using * ourselves as a
  * logger (see logging examples..)
 */
ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, myPackagePath);
		

------------------------------------
Alarius Systems LLC
Mike Oliver
CTO
ollie@alariussystems.com
mikeoliveraz@yahoo.com
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156
tel: (702)643-7425
fax: (702)974-0341
mobile: (518)378-6154
IM: MikeOliverAZ@yahoo.com
http://www.alariussystems.com/
------------------------------------



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


RE: template path

Posted by Michael Oliver <ol...@alariussystems.com>.
Make that the FileResourceLoader shows the path but not the template paths.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com

-----Original Message-----
From: Michael Oliver [mailto:ollie@alariussystems.com] 
Sent: Wednesday, August 03, 2005 2:49 PM
To: 'Velocity Users List'; ollie@alariussystems.com
Subject: RE: template path

I am setting 

ve.setProperty("file.resource.loader.path",
"C:/Java/eclipse/workspace/DataSource/WebContent/WEB-INF/classes/com/alarius
/datasource/");
	
Where 've' is a valid velocity engine and this line occurs before the

Ve.init();
	
and I can confirm my template is located in that directory,

C:\Java\eclipse\workspace\DataSource\WebContent\WEB-INF\classes\com\alarius\
datasource\Hibernate_cfg_xml.vm

yet it throws a ResourceNotFoundException when I try a 

Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
Velocity.ENCODING_DEFAULT,context, sw);
		
I checked in the debugger and the overriding properties shows the path set
above....ARG!

The debugger also shows the resourceManager has this as one of the paths,
but the template paths are all null.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com

-----Original Message-----
From: Michael Oliver [mailto:ollie@alariussystems.com] 
Sent: Wednesday, August 03, 2005 9:15 AM
To: velocity-user@jakarta.apache.org
Subject: template path

I would like to set a property in the Velocity Engine so I can load a
template from the classpath.

I have a number of different templates that are related to various packages
and classes and it would be easier if I built my jar file with the templates
in the same path as the classes.

I would then name the templates the same and change the template path to
match the package path of the class it relates to.

Is the following the right way?

/*
 * create a new instance of the engine
 */
VelocityEngine ve = new VelocityEngine();
/*
  * configure the engine. In this case, we are using * ourselves as a
  * logger (see logging examples..)
 */
ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, myPackagePath);
		

------------------------------------
Alarius Systems LLC
Mike Oliver
CTO
ollie@alariussystems.com
mikeoliveraz@yahoo.com
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156
tel: (702)643-7425
fax: (702)974-0341
mobile: (518)378-6154
IM: MikeOliverAZ@yahoo.com
http://www.alariussystems.com/
------------------------------------



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



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



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


RE: template path

Posted by Michael Oliver <ol...@alariussystems.com>.
I am setting 

ve.setProperty("file.resource.loader.path",
"C:/Java/eclipse/workspace/DataSource/WebContent/WEB-INF/classes/com/alarius
/datasource/");
	
Where 've' is a valid velocity engine and this line occurs before the

Ve.init();
	
and I can confirm my template is located in that directory,

C:\Java\eclipse\workspace\DataSource\WebContent\WEB-INF\classes\com\alarius\
datasource\Hibernate_cfg_xml.vm

yet it throws a ResourceNotFoundException when I try a 

Velocity.mergeTemplate("Hibernate_cfg_xml.vm",
Velocity.ENCODING_DEFAULT,context, sw);
		
I checked in the debugger and the overriding properties shows the path set
above....ARG!

The debugger also shows the resourceManager has this as one of the paths,
but the template paths are all null.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com

-----Original Message-----
From: Michael Oliver [mailto:ollie@alariussystems.com] 
Sent: Wednesday, August 03, 2005 9:15 AM
To: velocity-user@jakarta.apache.org
Subject: template path

I would like to set a property in the Velocity Engine so I can load a
template from the classpath.

I have a number of different templates that are related to various packages
and classes and it would be easier if I built my jar file with the templates
in the same path as the classes.

I would then name the templates the same and change the template path to
match the package path of the class it relates to.

Is the following the right way?

/*
 * create a new instance of the engine
 */
VelocityEngine ve = new VelocityEngine();
/*
  * configure the engine. In this case, we are using * ourselves as a
  * logger (see logging examples..)
 */
ve.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM, this);
ve.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, myPackagePath);
		

------------------------------------
Alarius Systems LLC
Mike Oliver
CTO
ollie@alariussystems.com
mikeoliveraz@yahoo.com
6800 E. Lake Mead Blvd
Apt 1096
Las Vegas, NV 89156
tel: (702)643-7425
fax: (702)974-0341
mobile: (518)378-6154
IM: MikeOliverAZ@yahoo.com
http://www.alariussystems.com/
------------------------------------



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



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