小白请教~~最近学习Rythm,跟着教程在做例子时报错。教程地址:http://rythmengine.org/doc/tutorial.md#env
代码如下:
import org.rythmengine.Rythm; import java.util.*; 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")); } }
请问home.template是在配置文件中存在么,教程中没有提到这个配置在哪里。
报错信息空指针异常,具体如下:
run: [java] java.lang.NullPointerException [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava .java:194) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:764) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja va:288) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces sorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet hodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:597) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU tils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.Target.execute(Target.java:357) [java] at org.apache.tools.ant.Target.performTasks(Target.java:385) [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.jav a:1337) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De faultExecutor.java:41) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1189 ) [java] at org.apache.tools.ant.Main.runBuild(Main.java:758) [java] at org.apache.tools.ant.Main.startAnt(Main.java:217) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) [java] Caused by: java.lang.NullPointerException [java] at org.rythmengine.resource.TemplateResourceManager.<init>(Templ ateResourceManager.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 HelloWord.main(Unknown Source) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces sorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet hodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:597) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav a:217) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava .java:152) [java] ... 21 more [java] --- Nested Exception --- [java] java.lang.NullPointerException [java] at org.rythmengine.resource.TemplateResourceManager.<init>(Templ ateResourceManager.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 HelloWord.main(Unknown Source) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces sorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet hodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:597) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav a:217) [java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava .java:152) [java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:764) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218) [java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132) [java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105) [java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja va:288) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces sorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet hodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:597) [java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU tils.java:106) [java] at org.apache.tools.ant.Task.perform(Task.java:348) [java] at org.apache.tools.ant.Target.execute(Target.java:357) [java] at org.apache.tools.ant.Target.performTasks(Target.java:385) [java] at org.apache.tools.ant.Project.executeSortedTargets(Project.jav a:1337) [java] at org.apache.tools.ant.Project.executeTarget(Project.java:1306) [java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De faultExecutor.java:41) [java] at org.apache.tools.ant.Project.executeTargets(Project.java:1189 ) [java] at org.apache.tools.ant.Main.runBuild(Main.java:758) [java] at org.apache.tools.ant.Main.startAnt(Main.java:217) [java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) [java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104) [java] Java Result: -1
我不能重现你这个问题呢?你的Rythm版本是多少?能把你的项目打个包放到网盘上让我看看吗?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。