Re: RhinoWrapper Exception
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Friday, January 30, 2009, 7:14:04 AM, Patrick Dobbs wrote:
> Hi,
>
> I'm trying to use Freemarker from a Rhino javascript script. I've the
> couple of related newsgroup posts on this, but not being that familiar
> with Freemarker I suspect I'm going something wrong.
>
> Below is the Rhino shell session.
>
> Thanks
>
> Patrick
>
>
js>> importPackage(Packages.freemarker.template);
>
js>> cfg = new Configuration();
> freemarker.template.Configuration@195dd5b
js>> cfg.setObjectWrapper(new Packages ext.rhino.RhinoWrapper());
js>> cfg.setDirectoryForTemplateLoading(new java.io.File("./templates"));
js>> root = {}
> [object Object]
js>> root.name="Joe";
> Joe
js>> root.age="7";
That rather should be: root.age = 7;
> 7
js>> out = new java.io.OutputStreamWriter(java.lang.System.out);
> java.io.OutputStreamWriter@1dacccc
js>> temp = cfg.getTemplate("test.ftl");
> <tr>
> <th>Name</th><td>${name}</td>
> </tr>
> <tr>
> <th>Age</th><td>${age}</td>
> </tr>
js>> temp.process(root,out);
>
> Exception in thread "main" java.lang.NoSuchFieldError: instance
That's an incompatibility with some Rhino versions where there were no
org.mozilla.javascript.Undefined.instance field. Try using the latest
FreeMarker with the latest Rhino; those should match.
> at
> freemarker.ext.rhino.RhinoWrapper.wrap(RhinoWrapper.java:21)
> at
> freemarker.template.Template.createProcessingEnvironment(Template.java:356)
> at freemarker.template.Template.process(Template.java:237)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
--
Best regards,
Daniel Dekany
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword