You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ben <ne...@gmail.com> on 2004/10/07 09:16:13 UTC

Toolbox loaded but not working

Hi

Could somebody please tell me what I am doing wrong here and why I
can't use the toolbox?

Here are my configurations:

web.xml:
--------
<servlet>
	<servlet-name>velocity</servlet-name>
	<servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
	<init-param>
		<param-name>org.apache.velocity.toolbox</param-name>
		<param-value>/WEB-INF/toolbox.xml</param-value>
	</init-param>
	<init-param>
		<param-name>org.apache.velocity.properties</param-name>
		<param-value>/WEB-INF/classes/velocity.properties</param-value>
	</init-param>
	<load-on-startup>10</load-on-startup>
</servlet>
<servlet-mapping>
	<servlet-name>velocity</servlet-name>
	<url-pattern>*.vm</url-pattern>
</servlet-mapping>

velocity.properties:
--------------------
velocimacro.library = /WEB-INF/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.log.invalid.reference = true
runtime.log.error.stacktrace = true
runtime.log.warn.stacktrace = true
runtime.log.info.stacktrace = true

toolbox.xml:
------------
<?xml version="1.0"?>

<toolbox>
	<tool>
		<key>link</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
	</tool>
	<tool>
		<key>text</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.MessageTool</class>
	</tool>
	<tool>
		<key>messages</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.ActionMessagesTool</class>
	</tool>
	<tool>
		<key>errors</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.ErrorsTool</class>
	</tool>
	<tool>
		<key>form</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.FormTool</class>
	</tool>
	<tool>
		<key>validator</key>
		<scope>request</scope>
		<class>org.apache.velocity.tools.struts.ValidatorTool</class>
	</tool>
</toolbox>

index.vm:
---------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>$text.webapp.prefix: $text.index.title</title>
</head>
<body>
<a href="$link.setURI("/")">Home</a>
</body>
</html>

ApplicationResources.properties:
--------------------------------
webapp.prefix=Company
index.title=Home

Velocity log:
-------------
[info] VelocityViewServlet: Custom Properties File:
/WEB-INF/classes/velocity.properties
[info] ************************************************************** 
[info] Starting Jakarta Velocity v1.4
[info] RuntimeInstance initializing.
[info] Default Properties File:
org\apache\velocity\runtime\defaults\velocity.properties
[info] Trying to use logger class
org.apache.velocity.tools.view.servlet.ServletLogger
[info] Using logger class org.apache.velocity.tools.view.servlet.ServletLogger
[info] Default ResourceManager initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
[info] Resource Loader Instantiated:
org.apache.velocity.tools.view.servlet.WebappLoader
[info] WebappLoader : initialization starting.
[info] WebappLoader : initialization complete.
[info] ResourceCache : initialized. (class
org.apache.velocity.runtime.resource.ResourceCacheImpl)
[info] Default ResourceManager initialization complete.
[info] Loaded System Directive: org.apache.velocity.runtime.directive.Literal
[info] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
[info] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
[info] Loaded System Directive: org.apache.velocity.runtime.directive.Include
[info] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
[info] Created: 20 parsers.
[info] Velocimacro : initialization starting.
[info] Velocimacro : adding VMs from VM library template :
/WEB-INF/VM_global_library.vm
[info] ResourceManager : found /WEB-INF/VM_global_library.vm with
loader org.apache.velocity.tools.view.servlet.WebappLoader
[info] Velocimacro :  VM library template macro registration complete.
[info] Velocimacro : allowInline = true : VMs can be defined inline in templates
[info] Velocimacro : allowInlineToOverride = false : VMs defined
inline may NOT replace previous VM definitions
[info] Velocimacro : allowInlineLocal = false : VMs defined inline
will be  global in scope if allowed.
[info] Velocimacro : messages on  : VM system will output logging messages
[info] Velocimacro : autoload off  : VM system will not automatically
reload global library macros
[info] Velocimacro : initialization complete.
[info] Velocity successfully started.
[info] ServletToolboxManager: Using config file '/WEB-INF/toolbox.xml'
[debug] XMLToolboxManager: Loading toolbox...
[debug] XMLToolboxManager: Toolbox loaded.
[info] ServletToolboxManager: Toolbox setup complete.
[info] VelocityViewServlet: Default content-type is: text/html
[info] VelocityViewServlet: No custom properties found. Using default
Velocity configuration.
[info] VelocityViewServlet: No toolbox entry in configuration.
[info] VelocityViewServlet: Default content-type is: text/html
[info] ResourceManager : found /index.vm with loader
org.apache.velocity.tools.view.servlet.WebappLoader
[warn] org.apache.velocity.runtime.exception.ReferenceException:
reference : template = /index.vm [line 4,column 8] :
$text.webapp.prefix is not a valid reference.
[warn] org.apache.velocity.runtime.exception.ReferenceException:
reference : template = /index.vm [line 4,column 29] :
$text.index.title is not a valid reference.
[warn] org.apache.velocity.runtime.exception.ReferenceException:
reference : template = /index.vm [line 7,column 9] : $link.setURI("/")
is not a valid reference.

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


Re: Toolbox loaded but not working

Posted by Ben <ne...@gmail.com>.
Please ignore this, I just found out what I did wrong and fixed the problem.

Thanks.


On Thu, 7 Oct 2004 17:16:13 +1000, Ben <ne...@gmail.com> wrote:
> Hi
> 
> Could somebody please tell me what I am doing wrong here and why I
> can't use the toolbox?
> 
> Here are my configurations:
> 
> web.xml:
> --------
> <servlet>
>         <servlet-name>velocity</servlet-name>
>         <servlet-class>org.apache.velocity.tools.view.servlet.VelocityViewServlet</servlet-class>
>         <init-param>
>                 <param-name>org.apache.velocity.toolbox</param-name>
>                 <param-value>/WEB-INF/toolbox.xml</param-value>
>         </init-param>
>         <init-param>
>                 <param-name>org.apache.velocity.properties</param-name>
>                 <param-value>/WEB-INF/classes/velocity.properties</param-value>
>         </init-param>
>         <load-on-startup>10</load-on-startup>
> </servlet>
> <servlet-mapping>
>         <servlet-name>velocity</servlet-name>
>         <url-pattern>*.vm</url-pattern>
> </servlet-mapping>
> 
> velocity.properties:
> --------------------
> velocimacro.library = /WEB-INF/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.log.invalid.reference = true
> runtime.log.error.stacktrace = true
> runtime.log.warn.stacktrace = true
> runtime.log.info.stacktrace = true
> 
> toolbox.xml:
> ------------
> <?xml version="1.0"?>
> 
> <toolbox>
>         <tool>
>                 <key>link</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.StrutsLinkTool</class>
>         </tool>
>         <tool>
>                 <key>text</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.MessageTool</class>
>         </tool>
>         <tool>
>                 <key>messages</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.ActionMessagesTool</class>
>         </tool>
>         <tool>
>                 <key>errors</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.ErrorsTool</class>
>         </tool>
>         <tool>
>                 <key>form</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.FormTool</class>
>         </tool>
>         <tool>
>                 <key>validator</key>
>                 <scope>request</scope>
>                 <class>org.apache.velocity.tools.struts.ValidatorTool</class>
>         </tool>
> </toolbox>
> 
> index.vm:
> ---------
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>$text.webapp.prefix: $text.index.title</title>
> </head>
> <body>
> <a href="$link.setURI("/")">Home</a>
> </body>
> </html>
> 
> ApplicationResources.properties:
> --------------------------------
> webapp.prefix=Company
> index.title=Home
> 
> Velocity log:
> -------------
> [info] VelocityViewServlet: Custom Properties File:
> /WEB-INF/classes/velocity.properties
> [info] **************************************************************
> [info] Starting Jakarta Velocity v1.4
> [info] RuntimeInstance initializing.
> [info] Default Properties File:
> org\apache\velocity\runtime\defaults\velocity.properties
> [info] Trying to use logger class
> org.apache.velocity.tools.view.servlet.ServletLogger
> [info] Using logger class org.apache.velocity.tools.view.servlet.ServletLogger
> [info] Default ResourceManager initializing. (class
> org.apache.velocity.runtime.resource.ResourceManagerImpl)
> [info] Resource Loader Instantiated:
> org.apache.velocity.tools.view.servlet.WebappLoader
> [info] WebappLoader : initialization starting.
> [info] WebappLoader : initialization complete.
> [info] ResourceCache : initialized. (class
> org.apache.velocity.runtime.resource.ResourceCacheImpl)
> [info] Default ResourceManager initialization complete.
> [info] Loaded System Directive: org.apache.velocity.runtime.directive.Literal
> [info] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
> [info] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
> [info] Loaded System Directive: org.apache.velocity.runtime.directive.Include
> [info] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
> [info] Created: 20 parsers.
> [info] Velocimacro : initialization starting.
> [info] Velocimacro : adding VMs from VM library template :
> /WEB-INF/VM_global_library.vm
> [info] ResourceManager : found /WEB-INF/VM_global_library.vm with
> loader org.apache.velocity.tools.view.servlet.WebappLoader
> [info] Velocimacro :  VM library template macro registration complete.
> [info] Velocimacro : allowInline = true : VMs can be defined inline in templates
> [info] Velocimacro : allowInlineToOverride = false : VMs defined
> inline may NOT replace previous VM definitions
> [info] Velocimacro : allowInlineLocal = false : VMs defined inline
> will be  global in scope if allowed.
> [info] Velocimacro : messages on  : VM system will output logging messages
> [info] Velocimacro : autoload off  : VM system will not automatically
> reload global library macros
> [info] Velocimacro : initialization complete.
> [info] Velocity successfully started.
> [info] ServletToolboxManager: Using config file '/WEB-INF/toolbox.xml'
> [debug] XMLToolboxManager: Loading toolbox...
> [debug] XMLToolboxManager: Toolbox loaded.
> [info] ServletToolboxManager: Toolbox setup complete.
> [info] VelocityViewServlet: Default content-type is: text/html
> [info] VelocityViewServlet: No custom properties found. Using default
> Velocity configuration.
> [info] VelocityViewServlet: No toolbox entry in configuration.
> [info] VelocityViewServlet: Default content-type is: text/html
> [info] ResourceManager : found /index.vm with loader
> org.apache.velocity.tools.view.servlet.WebappLoader
> [warn] org.apache.velocity.runtime.exception.ReferenceException:
> reference : template = /index.vm [line 4,column 8] :
> $text.webapp.prefix is not a valid reference.
> [warn] org.apache.velocity.runtime.exception.ReferenceException:
> reference : template = /index.vm [line 4,column 29] :
> $text.index.title is not a valid reference.
> [warn] org.apache.velocity.runtime.exception.ReferenceException:
> reference : template = /index.vm [line 7,column 9] : $link.setURI("/")
> is not a valid reference.
>

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