NutzCN Logo
问答 FreeMarkerConfigurer初始化失败,关键是发布之后失败,发布前没问题
发布于 2711天前 作者 屠夫与 4851 次浏览 复制 上一个帖子 下一个帖子
标签:

错误日志如下:

严重: Exception starting filter nutz
org.nutz.mvc.LoadingException: org.nutz.ioc.IocException: [freeMarkerConfigurer] # FAIL to create Ioc Bean name=[freeMarkerConfigurer]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
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:990)
at org.nutz.lang.Lang.wrapThrow(Lang.java:196)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:135)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4677)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1742)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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:748)
Caused by: org.nutz.ioc.IocException: [freeMarkerConfigurer] # FAIL to create Ioc Bean name=[freeMarkerConfigurer]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
at org.nutz.plugins.view.freemarker.FreemarkerViewMaker.make(FreemarkerViewMaker.java:18)
at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:86)
at org.nutz.mvc.impl.processor.ViewProcessor.evalView(ViewProcessor.java:89)
at org.nutz.mvc.impl.processor.ViewProcessor.init(ViewProcessor.java:31)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
at org.nutz.plugins.apidoc.ApidocUrlMapping.add(ApidocUrlMapping.java:72)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:204)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
... 19 more
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.plugins.view.freemarker.FreeMarkerConfigurer'
by args: [
@(freemarker.template.Configuration@6e2702fd)
@(org.apache.catalina.core.ApplicationContextFacade@58e6f80b)
@(WEB-INF)
@(.ftl)
@(org.nutz.plugins.view.freemarker.FreemarkerDirectiveFactory@6bcdf6ab)] because:
java.lang.IllegalArgumentException
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:19)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:114)
... 31 more
Caused by: java.lang.IllegalArgumentException
at org.apache.catalina.webresources.AbstractResourceSet.checkPath(AbstractResourceSet.java:39)
at org.apache.catalina.webresources.DirResourceSet.getResource(DirResourceSet.java:91)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:176)
at org.apache.catalina.webresources.CachedResource.validate(CachedResource.java:62)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:78)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:163)
at org.apache.catalina.core.StandardContext.getRealPath(StandardContext.java:4528)
at org.apache.catalina.core.ApplicationContext.getRealPath(ApplicationContext.java:398)
at org.apache.catalina.core.ApplicationContextFacade.getRealPath(ApplicationContextFacade.java:335)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.initp(FreeMarkerConfigurer.java:50)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.(FreeMarkerConfigurer.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
... 33 more

六月 15, 2017 1:45:03 下午 org.apache.catalina.core.ApplicationContext log
信息: Cleaning up Shiro Environment
六月 15, 2017 1:45:04 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
六月 15, 2017 1:45:04 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
六月 15, 2017 1:45:04 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@3787db09')
六月 15, 2017 1:56:43 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Shiro environment
六月 15, 2017 1:56:50 下午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter nutz
org.nutz.mvc.LoadingException: org.nutz.ioc.IocException: [freeMarkerConfigurer] # FAIL to create Ioc Bean name=[freeMarkerConfigurer]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
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:990)
at org.nutz.lang.Lang.wrapThrow(Lang.java:196)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:135)
at org.nutz.mvc.ActionHandler.(ActionHandler.java:19)
at org.nutz.mvc.NutFilter._init(NutFilter.java:87)
at org.nutz.mvc.NutFilter.init(NutFilter.java:65)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4677)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:968)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1742)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
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:748)
Caused by: org.nutz.ioc.IocException: [freeMarkerConfigurer] # FAIL to create Ioc Bean name=[freeMarkerConfigurer]
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:149)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:210)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:239)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:146)
at org.nutz.plugins.view.freemarker.FreemarkerViewMaker.make(FreemarkerViewMaker.java:18)
at org.nutz.mvc.view.ViewZone.makeView(ViewZone.java:86)
at org.nutz.mvc.impl.processor.ViewProcessor.evalView(ViewProcessor.java:89)
at org.nutz.mvc.impl.processor.ViewProcessor.init(ViewProcessor.java:31)
at org.nutz.mvc.impl.NutActionChainMaker.eval(NutActionChainMaker.java:38)
at org.nutz.mvc.impl.UrlMappingImpl.add(UrlMappingImpl.java:54)
at org.nutz.plugins.apidoc.ApidocUrlMapping.add(ApidocUrlMapping.java:72)
at org.nutz.mvc.impl.NutLoading.evalUrlMapping(NutLoading.java:204)
at org.nutz.mvc.impl.NutLoading.load(NutLoading.java:108)
... 19 more
Caused by: org.nutz.lang.born.BorningException: Fail to born 'org.nutz.plugins.view.freemarker.FreeMarkerConfigurer'
by args: [
@(freemarker.template.Configuration@2f2230bb)
@(org.apache.catalina.core.ApplicationContextFacade@3f41ab0e)
@(WEB-INF)
@(.ftl)
@(org.nutz.plugins.view.freemarker.FreemarkerDirectiveFactory@653076e0)] because:
java.lang.IllegalArgumentException
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:19)
at org.nutz.ioc.weaver.DefaultWeaver.born(DefaultWeaver.java:67)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:114)
... 31 more
Caused by: java.lang.IllegalArgumentException
at org.apache.catalina.webresources.AbstractResourceSet.checkPath(AbstractResourceSet.java:39)
at org.apache.catalina.webresources.DirResourceSet.getResource(DirResourceSet.java:91)
at org.apache.catalina.webresources.StandardRoot.getResourceInternal(StandardRoot.java:176)
at org.apache.catalina.webresources.CachedResource.validate(CachedResource.java:62)
at org.apache.catalina.webresources.Cache.getResource(Cache.java:78)
at org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:163)
at org.apache.catalina.core.StandardContext.getRealPath(StandardContext.java:4528)
at org.apache.catalina.core.ApplicationContext.getRealPath(ApplicationContext.java:398)
at org.apache.catalina.core.ApplicationContextFacade.getRealPath(ApplicationContextFacade.java:335)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.initp(FreeMarkerConfigurer.java:50)
at org.nutz.plugins.view.freemarker.FreeMarkerConfigurer.(FreeMarkerConfigurer.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.nutz.lang.born.ConstructorBorning.born(ConstructorBorning.java:17)
... 33 more

六月 15, 2017 1:56:50 下午 org.apache.catalina.core.ApplicationContext log
信息: Cleaning up Shiro Environment
六月 15, 2017 1:56:50 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: contextInitialized()
六月 15, 2017 1:56:50 下午 org.apache.catalina.core.ApplicationContext log
信息: SessionListener: contextInitialized()
六月 15, 2017 1:56:50 下午 org.apache.catalina.core.ApplicationContext log
信息: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@108aedfd')

34 回复

发布之后是什么意思?? 打成war了?

对的,打包之后本机也是没问题的

没解压war?

@wendal 解压了啊,但是控制台报错

来自炫酷的 NutzCN

是不是给freemarker配了一个不存在的路径?

我也怀疑是,但是我不知道具体是那个路径

是不是tomcat版本差异

有freemaker.js不?

@qq_eb516e41 有一个freemarker_tags.js

来自炫酷的 NutzCN

@qq_eb516e41 这个js里面也没有配置路径的啊

来自炫酷的 NutzCN

我的阿里云只有一个C盘,但是本机貌似在D盘创建了一个D:\data\topic文件夹,难道是这个原因???

为啥觉得像nutzcn的代码。。。 存topic数据的目录

就是nutzcn,这都没看出来???老大

我改头换面了一下,但是核心部分依然是nutzcn

custom目录下的properties文件逐个检查一下

我就找到了这个,但是这个也没说是写在D盘啊

图片存在的本地路径

topic.image.dir=/data/topic/image
topic.pageSize=12
topic.lucene.dir=/data/topic/lucene
topic.global.watchers=wendal,zozoh

额, 要不建个盘吧...

阿里云不能建盘,,,,,你又逗我

没用过阿里云的windows主机

加个硬盘试试?按量计费,最便宜的那种

这行代码就不能改了,非要加磁盘???源码改了不行么??

恩, 扯远了.
你有办法debug不? FreeMarkerConfigurer的initp方法, 看看发生了什么

这是两个函数,我能看到反编译后的源码,但是还是不明白,哪里出错了,不是磁盘的问题。。。。帮忙看看啊
protected void initp(Configuration configuration, ServletContext sc, String prefix, String suffix, FreemarkerDirectiveFactory freemarkerDirectiveFactory) {
this.configuration = configuration;
this.prefix = sc.getRealPath(prefix);
this.suffix = suffix;
this.freemarkerDirectiveFactory = freemarkerDirectiveFactory;
if (this.prefix == null)
this.prefix = sc.getRealPath("/") + prefix;
pro.append("tag_syntax=auto_detect").append(NEW_LINE);
pro.append("template_update_delay=-1").append(NEW_LINE);
pro.append("defaultEncoding=UTF-8").append(NEW_LINE);
pro.append("url_escaping_charset=UTF-8").append(NEW_LINE);
pro.append("locale=zh_CN").append(NEW_LINE);
pro.append("boolean_format=true,false").append(NEW_LINE);
pro.append("datetime_format=yyyy-MM-dd HH:mm:ss").append(NEW_LINE);
pro.append("date_format=yyyy-MM-dd").append(NEW_LINE);
pro.append("time_format=HH:mm:ss").append(NEW_LINE);
pro.append("number_format=0.######").append(NEW_LINE);
pro.append("whitespace_stripping=true");
}

public void init() {
    try {
       initFreeMarkerConfigurer();
       Iterator<Entry<String, Object>> iterator = tags.entrySet().iterator();
       while (iterator.hasNext()) {
         Entry<String, Object> entry = iterator.next();
         configuration.setSharedVariable(entry.getKey(), entry.getValue());
       }
       if (freemarkerDirectiveFactory == null)
         return;
       for (FreemarkerDirective freemarkerDirective : freemarkerDirectiveFactory.getList()) {
         configuration.setSharedVariable(freemarkerDirective.getName(), freemarkerDirective.getTemplateDirectiveModel());
       }
    } catch (IOException e) {
       log.error(e);
    } catch (TemplateException e) {
       log.error(e);
    }
}

何须反编译, 源码都在那...

this.prefix = sc.getRealPath(prefix);

看看传入的prefix是什么

你本地测试tomcat版本是多少, 服务器上的版本是多少?

本地tomcat8,服务器也是tomcat8

prefix的值是 WEB-INF
suffix的值是 .ftl

更新一下,会加上反斜杠

解决了,我直接把Tomcat拷过去,解决了

额,看来还是tomcat版本差异导致的?

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