执行Rythm.init(Map <string,object> map)</string,object>时发生空指针异常

时间:2015-02-18 10:48:58

标签: java rythm

我是Rythm模板引擎的新手,尝试访问外部文件并呈现数据但无法成功。有'空指针异常&#39; 当试图做Rythm.init(地图)。 我按照教程中提供的相同步骤进行操作。请找到以下链接。

http://rythmengine.org/doc/tutorial.md

我正在使用: rythm-engine-1.0.1-SNAPSHOT

Error :
init:

compile:
  [javac] Compiling 1 source file to C:\rythm-tutorial\HelloWorld\classes

n:
   [java] java.lang.NullPointerException
   [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
ava:194)
   [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
   [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)

   [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)

   [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
   [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
:291)
   [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Sourc

   [java]     at java.lang.reflect.Method.invoke(Unknown Source)
   [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
ls.java:106)
   [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
   [java]     at org.apache.tools.ant.Target.execute(Target.java:392)
   [java]     at org.apache.tools.ant.Target.performTasks(Target.java:413)
   [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
1399)
   [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)

   [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
ultExecutor.java:41)
   [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251

   [java]     at org.apache.tools.ant.Main.runBuild(Main.java:811)
   [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
   [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
   [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
   [java] Caused by: java.lang.NullPointerException
   [java]     at org.rythmengine.resource.TemplateResourceManager.<init>(Templ
eResourceManager.java:168)
   [java]     at org.rythmengine.RythmEngine.init(RythmEngine.java:636)
   [java]     at org.rythmengine.RythmEngine.<init>(RythmEngine.java:561)
   [java]     at org.rythmengine.Rythm.init(Rythm.java:97)
   [java]     at HelloWorld.main(Unknown Source)
   [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Sourc

   [java]     at java.lang.reflect.Method.invoke(Unknown Source)
   [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav
217)

Java代码:

import org.rythmengine.Rythm;
import java.util.*;
import java.io.*;

public class HelloWorld {
    public static void main(String[] args) {
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("home.template","resources");
        Rythm.init(map);
        System.out.println(Rythm.render("helloworld.html","world"));    
    }
}

请求帮助以解决问题。

0 个答案:

没有答案