You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Lee, Renee" <Re...@cable.comcast.com> on 2010/09/14 23:04:02 UTC

Velocity-1.6.2.jar + Struts2: Unable to instantiate VelocityEngine! Please help!

Hi,

We are using velocity-1.6.2.jar and velocity-tools-2.0-beta4.jar with
Struts2 as view templates.

However, we get the following errors if we define result type to
"velocity". Any help would be greatly appreciated!!!  --Renee


========== errors in the log =================
INFO  2010-09-13 14:27:17,360 - Initializing velocity using
struts-velocity.properties from classloader
 DEBUG 2010-09-13 14:27:17,360 - Initializing Velocity with the
following properties ...
 DEBUG 2010-09-13 14:27:17,360 -     'userdirective' = 
......
 DEBUG 2010-09-13 14:27:17,360 -     'directive.foreach.counter.name' =
'velocityCount'
 DEBUG 2010-09-13 14:27:17,360 -     'file.resource.loader.path' = '.'
 DEBUG 2010-09-13 14:27:17,360 -     'runtime.log.error.stacktrace' =
'false'
 DEBUG 2010-09-13 14:27:17,360 -     'runtime.log' = 'velocity.log'
 DEBUG 2010-09-13 14:27:17,360 -     'resource.manager.class' =
'org.apache.velocity.runtime.resource.ResourceManagerImpl'
 DEBUG 2010-09-13 14:27:17,360 -
'file.resource.loader.modificationCheckInterval' = '2'
 DEBUG 2010-09-13 14:27:17,360 -     'file.resource.loader.cache' =
'false'
 DEBUG 2010-09-13 14:27:17,360 -
'directive.include.output.errormsg.start' = '<!-- include error :'
 DEBUG 2010-09-13 14:27:17,360 -     'directive.parse.max.depth' = '10'
 DEBUG 2010-09-13 14:27:17,360 -     'runtime.log.logsystem.class' =
'org.apache.velocity.runtime.log.NullLogSystem'
 DEBUG 2010-09-13 14:27:17,360 -
'velocimacro.permissions.allow.inline.local.scope' = 'false'
 DEBUG 2010-09-13 14:27:17,360 -     'runtime.introspector.uberspect' =
'org.apache.velocity.util.introspection.UberspectImpl'
 DEBUG 2010-09-13 14:27:17,360 -     'runtime.log.warn.stacktrace' =
'false'
 DEBUG 2010-09-13 14:27:17,360 -     'resource.manager.cache.class' =
'org.apache.velocity.runtime.resource.ResourceCacheImpl'
 DEBUG 2010-09-13 14:27:17,360 -     'file.resource.loader.description'
= 'Velocity File Resource Loader'
 DEBUG 2010-09-13 14:27:17,376 -     'input.encoding' = 'ISO-8859-1'
 DEBUG 2010-09-13 14:27:17,376 -
'strutsclass.resource.loader.description' = 'Velocity Classpath Resource
Loader'
 DEBUG 2010-09-13 14:27:17,376 -     'runtime.log.invalid.reference' =
'true'
 DEBUG 2010-09-13 14:27:17,376 -     'output.encoding' = 'ISO-8859-1'
 DEBUG 2010-09-13 14:27:17,376 -
'runtime.interpolate.string.literals' = 'true'
 DEBUG 2010-09-13 14:27:17,376 -
'directive.foreach.counter.initial.value' = '1'
 DEBUG 2010-09-13 14:27:17,376 -
'velocimacro.permissions.allow.inline' = 'true'
 DEBUG 2010-09-13 14:27:17,376 -     'runtime.log.info.stacktrace' =
'false'
 DEBUG 2010-09-13 14:27:17,376 -     'velocimacro.context.localscope' =
'false'
 DEBUG 2010-09-13 14:27:17,376 -     'resource.loader' = 'file'
 DEBUG 2010-09-13 14:27:17,376 -     'strutsclass.resource.loader.class'
= 'org.apache.struts2.views.velocity.StrutsResourceLoader'
 DEBUG 2010-09-13 14:27:17,376 -     'velocimacro.library' =
'VM_global_library.vm'
 DEBUG 2010-09-13 14:27:17,376 -     'strutsclass.resource.loader.cache'
= 'true'
 DEBUG 2010-09-13 14:27:17,376 -
'strutsclass.resource.loader.modificationCheckInterval' = '2'
 DEBUG 2010-09-13 14:27:17,376 -
'velocimacro.permissions.allow.inline.to.replace.global' = 'false'
 DEBUG 2010-09-13 14:27:17,376 -
'directive.include.output.errormsg.end' = 'see error log -->'
 ERROR 2010-09-13 14:27:17,407 - [SIKUI_52601] : General Exception
occuerd while validating RE input parameters
 Unable to instantiate VelocityEngine! - Class:
org.apache.velocity.runtime.VelocimacroFactory
File: VelocimacroFactory.java
Method: initVelocimacro
Line: 219 - org/apache/velocity/runtime/VelocimacroFactory.java:219:-1
	at
org.apache.struts2.views.velocity.VelocityManager.newVelocityEngine(Velo
cityManager.java:476)
	at
org.apache.struts2.views.velocity.VelocityManager.init(VelocityManager.j
ava:243)
	at
org.apache.struts2.dispatcher.VelocityResult.doExecute(VelocityResult.ja
va:131)
	at
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSu
pport.java:186)
......
Caused by: org.apache.velocity.exception.VelocityException: Velocimacro
: Error using VM library : VM_global_library.vm
	at
org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(Velocimac
roFactory.java:219)
	at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:26
1)
	at
org.apache.velocity.runtime.RuntimeInstance.init(RuntimeInstance.java:58
9)
	at
org.apache.velocity.app.VelocityEngine.init(VelocityEngine.java:135)
	at
org.apache.struts2.views.velocity.VelocityManager.newVelocityEngine(Velo
cityManager.java:473)
	... 24 more
Caused by: org.apache.velocity.exception.ResourceNotFoundException:
Unable to find resource 'VM_global_library.vm'
	at
org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(Re
sourceManagerImpl.java:483)
	at
org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(Res
ourceManagerImpl.java:354)
	at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1400)
	at
org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.
java:1380)
	at
org.apache.velocity.runtime.VelocimacroFactory.initVelocimacro(Velocimac
roFactory.java:202)
	... 28 more

============ log ends ====================

Following is our configuration files.

=============== structs.xml item ====================

		<action name="PreActivation"
	
class="com.comcast.sik.struts.action.PreActivationAction">
			<interceptor-ref name="params" />
			<interceptor-ref name="servletConfig" />
			<interceptor-ref
name="REInputValidate"></interceptor-ref>
			<result type="velocity"
name="success">/velocity/getset.vm</result>
<========= result type set to "velocity" now
		</action>

================================================

 =============== structs-velocity.properties file ====================
runtime.log.logsystem.class =
org.apache.velocity.runtime.log.AvalonLogSystem,org.apache.velocity.runt
ime.log.SimpleLog4JLogSystem
runtime.log = velocity.log
runtime.log.error.stacktrace = false
runtime.log.warn.stacktrace = false
runtime.log.info.stacktrace = false
runtime.log.invalid.reference = true

input.encoding=ISO-8859-1
output.encoding=ISO-8859-1

directive.foreach.counter.name = velocityCount
directive.foreach.counter.initial.value = 1

directive.include.output.errormsg.start = <!-- include error :
directive.include.output.errormsg.end   =  see error log -->

directive.parse.max.depth = 10

resource.loader = file

# file.resource.loader.class =
org.apache.velocity.runtime.resource.loader.FileResourceLoader 
# we are using, by default, the recommented WebappResourceLoader
file.resource.loader.path = .
file.resource.loader.cache = false
file.resource.loader.modificationCheckInterval = 2

#-----------------------------------------------------------------------
-----
# VELOCIMACRO PROPERTIES
#-----------------------------------------------------------------------
-----
# global : name of default global library.  It is expected to be in the
regular
# template path.  You may remove it (either the file or this property)
if
# you wish with no harm.
#-----------------------------------------------------------------------
-----
velocimacro.library = VM_global_library.vm

velocimacro.permissions.allow.inline = true
velocimacro.permissions.allow.inline.to.replace.global = false
velocimacro.permissions.allow.inline.local.scope = false

velocimacro.context.localscope = false

runtime.interpolate.string.literals = true


#-----------------------------------------------------------------------
-----
# RESOURCE MANAGEMENT
#-----------------------------------------------------------------------
-----
# Allows alternative ResourceManager and ResourceCache implementations
# to be plugged in.
#-----------------------------------------------------------------------
-----
resource.manager.class =
org.apache.velocity.runtime.resource.ResourceManagerImpl
resource.manager.cache.class =
org.apache.velocity.runtime.resource.ResourceCacheImpl

#-----------------------------------------------------------------------
-----
# PLUGGABLE INTROSPECTOR
#-----------------------------------------------------------------------
-----
# Allows alternative introspection and all that can of worms brings
#-----------------------------------------------------------------------
-----

runtime.introspector.uberspect =
org.apache.velocity.util.introspection.UberspectImpl

====================== end of structs-velocity.properties file
==========================

====================== structs-velocity-toolbox.xml file
==========================
<?xml version="1.0" encoding="UTF-8"?>

<toolbox>
	<data type="string">
		<key>version</key>
		<value>1.3</value>
	</data>

	<tool>
		<key>link</key>
		<scope>request</scope>
	
<class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
	</tool>

	<tool>
		<key>slink</key>
		<scope>request</scope>
	
<class>org.apache.velocity.tools.struts.SecureLinkTool</class>
	</tool>

	<tool>
		<key>text</key>
		<scope>request</scope>
	
<class>org.apache.velocity.tools.struts.MessageTool</class>
	</tool>
</toolbox>
======================end of structs-velocity-toolbox.xml file
==========================

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


Re: Velocity-1.6.2.jar + Struts2: Unable to instantiate VelocityEngine! Please help!

Posted by Claude Brisson <cl...@renegat.net>.
The root cause is visible in your log file:

On 14/09/2010 23:04, Lee, Renee wrote:
> Unable to find resource 'VM_global_library.vm'
>    

You need to comment the corresponding line in velocity.properties, or to 
create an empty macro file and give it a correct path, like:

	velocimacro.library = /WEB-INF/VM_global_library.vm


   Claude


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