NutzCN Logo
问答 nutz 集成 freemarker报错
发布于 3242天前 作者 qq_a6bc4bb6 5930 次浏览 复制 上一个帖子 下一个帖子
标签: freemarker nutz

根据官方文档
配置 了
@Views({ VelocityViewMaker.class,FreemarkerViewMaker.class})

配置 了

org.freemarker
freemarker
2.3.21


org.nutz
nutz-plugins-views
1.b.53

启动项目直接报错:
SEVERE: Exception starting filter nutz
org.nutz.mvc.LoadingException: java.lang.NullPointerException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
at org.nutz.lang.born.BornContext.doBorn(BornContext.java:60)
at org.nutz.lang.Mirror.born(Mirror.java:967)
at org.nutz.lang.Lang.wrapThrow(Lang.java:164)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:133)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NullPointerException
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.initFreeMarkerConfigurer(FreeMarkerConfigurer.java:104)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.init(FreeMarkerConfigurer.java:76)
at org.nutz.plugins.view.freemarker.FreemarkerViewMaker.make(FreemarkerViewMaker.java:24)
at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:83)
at org.nutz.mvc.impl.processor.ViewProcessor.evalView(ViewProcessor.java:77)
at org.nutz.mvc.impl.processor.ViewProcessor.init(ViewProcessor.java:30)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:47)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:201)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:106)
... 14 more

不会是因为和  volicity一起用才会报的错吧。。
求大神
14 回复

应该不是,参考一下nutz.cn的代码吧

查日志 的时候发现是
类 FreeMarkerConfigurer 中 方法 initFreeMarkerConfigurer
protected void initFreeMarkerConfigurer() throws IOException, TemplateException {
Properties p = new Properties();
String path = freemarkerDirectiveFactory.getFreemarker();
File file = Files.findFile(path);
if (Lang.isEmpty(file)) {
p.load(Streams.wrap(pro.toString().getBytes()));
} else {
p.load(Streams.fileIn(file));
}
configuration.setSettings(p);
File f = Files.findFile(prefix);
configuration.setDirectoryForTemplateLoading(f);
}
里报出 的错。。
java.lang.NullPointerException
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.initFreeMarkerConfigurer(FreeMarkerConfigurer.java:104)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.init(FreeMarkerConfigurer.java:76)
at org.nutz.plugins.view.freemarker.FreemarkerViewMaker.make(FreemarkerViewMaker.java:24)
at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:83)
at org.nutz.mvc.impl.processor.ViewProcessor.evalView(ViewProcessor.java:77)
at org.nutz.mvc.impl.processor.ViewProcessor.init(ViewProcessor.java:30)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:47)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:201)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:106)
at untitled1_png untitled2_png

还请大神指点啊。。

freemarker.properties 资源文件没找到
你是不是没有加载freemarker.js文件

nutzbook 的ioc 目录下 加载了freemarker.js文件

文档 上不是不需要配置 freemarker.js 文件吗?

@qq_a6bc4bb6
新版插件做了这些文件的处理 你可以下载最新的代码 编译一个版本
https://github.com/nutzam/nutzmore/tree/master/nutz-plugins-views

@Rekoe
现在已经是加的最新的包了。。但是出现了个新的问题
FreeMarker template error:
freemarker.core._MiscTemplateException: Failed to set setting "tag_syntax" to value "auto_detecttemplate_update_delay=-1defaultEncoding=UTF-8url_escaping_charset=UTF-8locale=zh_CNboolean_format=true,falsedatetime_format=yyyy-MM-dd HH:mm:ssdate_format=yyyy-MM-ddtime_format=HH:mm:ssnumber_format=0.######whitespace_stripping=true"; see cause exception.
at freemarker.template.Configuration.setSetting(Configuration.java:1055)
at freemarker.core.Configurable.setSettings(Configurable.java:1149)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.initFreeMarkerConfigurer(FreeMarkerConfigurer.java:111)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.init(FreeMarkerConfigurer.java:76)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.nutz.ioc.trigger.MethodEventTrigger.trigger(MethodEventTrigger.java:18)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:74)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:135)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:196)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:221)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:140)
at org.nutz.plugins.view.freemarker.FreemarkerViewMaker.make(FreemarkerViewMaker.java:18)
at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:83)
at org.nutz.mvc.impl.processor.ViewProcessor.evalView(ViewProcessor.java:77)
at org.nutz.mvc.impl.processor.ViewProcessor.init(ViewProcessor.java:30)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:47)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:201)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:106)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter.init(NutFilter.java:77)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:98)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4584)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: freemarker.core._MiscTemplateException: Invalid value for setting "tag_syntax": "auto_detecttemplate_update_delay=-1defaultEncoding=UTF-8url_escaping_charset=UTF-8locale=zh_CNboolean_format=true,falsedatetime_format=yyyy-MM-dd HH:mm:ssdate_format=yyyy-MM-ddtime_format=HH:mm:ssnumber_format=0.######whitespace_stripping=true"
at freemarker.core.Configurable.invalidSettingValueException(Configurable.java:1127)
at freemarker.template.Configuration.setSetting(Configuration.java:1045)
... 34 more

 ![untitled1_png](/yvr/upload/0v/m2guhf52j55q7f0ucqjl5s80)

@qq_a6bc4bb6
你打的包有问题
你用

mvn clean package install 

来构建下包

是这样的结构
untitled1_png

已经重新打包ok了,谢谢!

@qq_a6bc4bb6 哥们,你还可以看到吗?关于集成freemark,我有些问题想向你请教,方便的话 请加下我qq 1421210148

添加回复
请先登陆
回到顶部