Actually, that's very useful. You're running Velocity 1.3.1. Support for
pluggable introspectors didn't start until Velocity 1.4.
WILL
----- Original Message -----
From: "James Kebinger" <[EMAIL PROTECTED]>
To: <velocity-user@jakarta.apache.org>
Sent: Tuesday, September 27, 2005 7:57 PM
Subject: Re: Using Velocity with Jython (and uberspect)
As promised, here's my velocity.log. Doesn't seem to be any reference
to any attempt to start the uberspect class - any insight?
Tue Sep 27 01:53:40 EDT 2005 [debug] AvalonLogSystem initialized
using logfile 'velocity.log'
Tue Sep 27 01:53:40 EDT 2005 [info]
**************************************************************
Tue Sep 27 01:53:40 EDT 2005 [info] Starting Jakarta Velocity v1.3.1
Tue Sep 27 01:53:40 EDT 2005 [info] RuntimeInstance initializing.
Tue Sep 27 01:53:40 EDT 2005 [info] Default Properties File:
org/apache/velocity/runtime/defaults/velocity.properties
Tue Sep 27 01:53:40 EDT 2005 [info] Trying to use logger class
org.apache.velocity.runtime.log.AvalonLogSystem
Tue Sep 27 01:53:40 EDT 2005 [info] Using logger class
org.apache.velocity.runtime.log.AvalonLogSystem
Tue Sep 27 01:53:40 EDT 2005 [info] Default ResourceManager
initializing. (class
org.apache.velocity.runtime.resource.ResourceManagerImpl)
Tue Sep 27 01:53:40 EDT 2005 [info] Resource Loader Instantiated:
org.apache.velocity.runtime.resource.loader.FileResourceLoader
Tue Sep 27 01:53:40 EDT 2005 [info] FileResourceLoader :
initialization starting.
Tue Sep 27 01:53:40 EDT 2005 [info] FileResourceLoader : adding path
'/Users/jkk/jython-test'
Tue Sep 27 01:53:40 EDT 2005 [info] FileResourceLoader :
initialization complete.
Tue Sep 27 01:53:40 EDT 2005 [info] ResourceCache : initialized.
(class org.apache.velocity.runtime.resource.ResourceCacheImpl)
Tue Sep 27 01:53:40 EDT 2005 [info] Default ResourceManager
initialization complete.
Tue Sep 27 01:53:40 EDT 2005 [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Literal
Tue Sep 27 01:53:40 EDT 2005 [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Macro
Tue Sep 27 01:53:40 EDT 2005 [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Parse
Tue Sep 27 01:53:40 EDT 2005 [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Include
Tue Sep 27 01:53:40 EDT 2005 [info] Loaded System Directive:
org.apache.velocity.runtime.directive.Foreach
Tue Sep 27 01:53:40 EDT 2005 [info] Created: 20 parsers.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : initialization starting.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : adding VMs from VM
library template : VM_global_library.vm
Tue Sep 27 01:53:40 EDT 2005 [error] ResourceManager : unable to find
resource 'VM_global_library.vm' in any resource loader.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : error using VM
library template VM_global_library.vm :
org.apache.velocity.exception.ResourceNotFoundException: Unable to
find resource 'VM_global_library.vm'
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : VM library
template macro registration complete.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : allowInline = true
: VMs can be defined inline in templates
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro :
allowInlineToOverride = false : VMs defined inline may NOT replace
previous VM definitions
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : allowInlineLocal =
false : VMs defined inline will be global in scope if allowed.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : messages on : VM
system will output logging messages
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : autoload off : VM
system will not automatically reload global library macros
Tue Sep 27 01:53:40 EDT 2005 [info] Velocimacro : initialization complete.
Tue Sep 27 01:53:40 EDT 2005 [info] Velocity successfully started.
Tue Sep 27 01:53:40 EDT 2005 [info] ResourceManager : found test.vm
with loader org.apache.velocity.runtime.resource.loader.FileResourceLoader
Tue Sep 27 01:53:41 EDT 2005 [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = test.vm [line 3,column 8] : $fball.name is not a valid
reference.
Tue Sep 27 01:53:41 EDT 2005 [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = test.vm [line 5,column 1] : $fball.get("shirtColor") is not
a valid reference.
Tue Sep 27 01:53:41 EDT 2005 [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = test.vm [line 7,column 2] : $fball.shirtColor is not a
valid reference.
Tue Sep 27 01:53:41 EDT 2005 [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = test.vm [line 8,column 7] : $obj.key is not a valid
reference.
Tue Sep 27 01:53:41 EDT 2005 [warn]
org.apache.velocity.runtime.exception.ReferenceException: reference :
template = test.vm [line 9,column 1] : $obj.value is not a valid
reference.
On 9/27/05, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
I'm thinking that maybe you have a wrong class name or improperly compiled
Uberspector, and it's never loaded. I haven't tried it but it's possible
Velocity will still initialize (or worse, partially initialize) if the
Uberspector is invalid. If so, there should be an error message when
Velocity starts up.
WILL
----- Original Message -----
From: "James Kebinger" <[EMAIL PROTECTED]>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: Tuesday, September 27, 2005 12:46 PM
Subject: Re: Using Velocity with Jython (and uberspect)
Thanks Will - on the Jython side I think my code is pretty close to
the onjava article. I even went back and took the dataobj from the
example when things weren't working :)
I'm loading the template like this, which is what I believe you are
referring to:
def processTemplate(self,templateName,dictionary,outputFilename):
template = self.getEngine().getTemplate(templateName);
ctx = VelocityContext();
if dictionary != None:
items = dictionary.items();
for key,value in items:
ctx.put(key,value);
writer = FileWriter(outputFilename);
template.merge(ctx,writer);
writer.close();
I'm using the JythonUberspect code right from the wiki, but I don't
think that side is even coming into play yet - no uberspect seems to
be called - because i can set the relevant property's value (the
uberspect classname) to some garbage string and it behaves the same.
I can give a drop from SVN a whirl sometime soon and see if that helps.
I'll dig up the velocity.log file later on when I get home.
-james
On 9/27/05, Will Glass-Husain <[EMAIL PROTECTED]> wrote:
> James,
>
> I'm no expert in Jython but are you following the same approach as in
> the
> onJava article?
>
> One of the alternate approaches: Velocity.evaluate() may not call the
> alternate uberspector. But loading a template with the File resource
> loader
> (as in the article) should work.
>
> Not having personally used it, I'm not sure why the JythonUberspect
> class
> doesn't work. As I noted, you might check the version on the wiki, see
> if
> it's updated. Perhaps the author of the article and Jython Uberspector
> will chime in.
>
> I've updated the latest source with a public UBERSPECT_CLASSNAME
> constant.
> This will be part of the 1.5 release. You might consider trying the
> latest
> source (use svn to check it out) see if this makes a difference.
>
> Best, WILL
>
>
> ----- Original Message -----
> From: "James Kebinger" <[EMAIL PROTECTED]>
> To: <velocity-user@jakarta.apache.org>
> Sent: Tuesday, September 27, 2005 7:50 AM
> Subject: Using Velocity with Jython (and uberspect)
>
>
> Hello all, I've been trying to get access to some Jython objects as
> descibed here:
> http://www.onjava.com/pub/a/onjava/2005/04/27/restweb.html?page=2
> . Curious if anyone else has this working, as I'm running into a
> couple of problems.
> First is that VelocityEngine.UBERSPECT_CLASSNAME is not public in the
> copy of Velocity 1.4 I have so I had to replace the call with
> ve.setProperty(JythonUberspect.getName()) like this
> ve.setProperty("runtime.introspector.uberspect",
> JythonUberspect.getName()) - is that to be expected.
> Next the code runs without error, except my template will not resolve
> my Jython objects - ie $data.field doesn't get expanded as it should.
> Digging further, it appears that Velocity is not accessing the
> JythonUberspect class at all because replacing the property set above
> to garbage makes no difference whatsoever,
> I'm using Velocity 1.4, Jython 2.1 and I had to recompile the
> JythonUberspect class because it wouldn't initially run on Java 1.4
> (invalid class version 49.0...). I'm not running in a web container,
> rather a standalone Jython program.
> Any one had a similar experience, or can give me a pointer in the
> right direction?
>
> thanks
> -James
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]