NutzCN Logo
问答 nutzboot beetl模板路径问题,打成jar包启动后,访问出错,以下是application.properties配置和报错日志
发布于 2439天前 作者 小苍蝇 3424 次浏览 复制 上一个帖子 下一个帖子
标签:
TEMPLATE_LOAD_ERROR
        at org.beetl.core.resource.ClasspathResource.openReader(ClasspathResource.java:74)
        at org.beetl.core.GroupTemplate.loadTemplate(GroupTemplate.java:633)
        at org.beetl.core.GroupTemplate.getTemplateByLoader(GroupTemplate.java:583)
        at org.beetl.core.GroupTemplate.getTemplate(GroupTemplate.java:547)
        at org.beetl.ext.web.WebRender.render(WebRender.java:86)
        at org.beetl.ext.nutz.BeetlView.render(BeetlView.java:28)
        at org.nutz.mvc.impl.processor.ViewProcessor.process(ViewProcessor.java:66)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.MethodInvokeProcessor.process(MethodInvokeProcessor.java:33)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:30)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.integration.shiro.NutShiroProcessor.process(NutShiroProcessor.java:126)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
        at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
        at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcesso
)
        at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
        at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
        at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
        at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
        at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
        at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
        at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
        at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
        at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
        at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:159)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
        at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
        at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
        at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:745)
[DEBUG] 15:29:31.307 org.beetl.ext.nutz.LogErrorHandler.processExcption(LogErrorHandler.java:32) - null
>>03:29:31:错找不到指定模板或者加载错(TEMPLATE_LOAD_ERROR): 位于0行 资源:/index.html

#端口号 server.port=8080 #ip server.host=127.0.0.1 #数据库连接地址 jdbc.url=jdbc:mysql://192.168.31.100:3306/urule jdbc.username=root jdbc.password=Mysql-502 #是否打印dao的SQL耗时日志 nutz.dao.interceptor.time.enable=true #是否使用daocache nutz.dao.interceptor.cache.enable=true #开启urule数据源配置 urule.repository.datasourcename=nutz.dataSource urule.repository.databasetype=mysql beetl.RESOURCE.rootLocal=src/main/webapp/WEB-INF/views/ #beetl.RESOURCE.root=src/main/webapp/WEB-INF/views/ #开启urule本地目录配置 #urule.repository.dir=d:/repo-demo
45 回复

我还特别强调不要这写的

beetl.RESOURCE.rootLocal=src/main/webapp/WEB-INF/views/

root是必须写, rootLocal是可选, 必须在src/main/resources

beetl.RESOURCE.rootLocal=C:/XXX/XXX/XXX/XXX/XX/src/main/resources/webapp/WEB-INF/views/
beetl.RESOURCE.root=webapp/WEB-INF/views/

嗯! 我看你的写的源码是这样解释的,rootLocal是目录绝对路径,root是目录路径默认是resources/template 目录下,如果绝对路径(rootLocal)没找到,就去找路径(root),这样的话,我把webapp这个文件夹,移动到resources下就ok了

我现在配置了这个 beetl.RESOURCE.root=webapp/WEB-INF/views/ 还是和上面报错一样啊! 感觉beetl.RESOURCE.root这个属性没有被加载,我反复试了好几次没作用,唯一有作用的就是 beetl.RESOURCE.rootLocal这个属性! 我的目录结构 src/main/resources/webapp/WEB-INF/views/index.html

你当前的配置贴一下


#端口号 server.port=8080 #ip server.host=127.0.0.1 #数据库连接地址 #jdbc.url=jdbc:mysql://192.168.31.100:3306/ads #jdbc.username=root #jdbc.password=Mysql-502 #是否打印dao的SQL耗时日志 nutz.dao.interceptor.time.enable=true #是否使用daocache nutz.dao.interceptor.cache.enable=true #开启urule数据源配置 #urule.repository.datasourcename=nutz.dataSource #urule.repository.databasetype=mysql #开启urule本地目录配置 urule.repository.dir=d:/repo-demo #beetl对应的目录,对应的目录是 src/main/resources/webapp/WEB-INF/views/ 注意不是 src/main/webapp/ #beetl.RESOURCE.rootLocal=src/main/resources/ beetl.RESOURCE.root=webapp/WEB-INF/views/

debug一下BeetlGroupTemplateStarter的

        if (!prop.contains("RESOURCE.root")) {
            prop.put("RESOURCE.root", prop.getProperty("root", "template/"));
        }

下面三个if方法都进来了,调式的是第三个if把第一个if put进去的值覆盖了

 if (!prop.contains(Configuration.RESOURCE_LOADER)) {
            prop.put(Configuration.RESOURCE_LOADER, ClasspathResourceLoader.class.getName());
        }
        if (!prop.contains("RESOURCE.autoCheck")) {
            prop.put("RESOURCE.autoCheck", "true");
        }
        if (!prop.contains("RESOURCE.root")) {
            prop.put("RESOURCE.root", prop.getProperty("root", "template/"));
        }

不会吧, 我试试

真的,我把debug值给你

第一个if的值 {RESOURCE.root=webapp/WEB-INF/views/, RESOURCE_LOADER=org.beetl.core.resource.ClasspathResourceLoader}
第二个if的值 {RESOURCE.root=webapp/WEB-INF/views/, RESOURCE_LOADER=org.beetl.core.resource.ClasspathResourceLoader, RESOURCE.autoCheck=true}
第三个if的值 {RESOURCE.root=template/, RESOURCE_LOADER=org.beetl.core.resource.ClasspathResourceLoader, RESOURCE.autoCheck=true}

啊啊啊, 我的锅

块更新下( ⊙ o ⊙ )啊!

contains --> containsKey

对的,判断key值存不存在!

好了跟我说一下,我更新

启动上下文 名称怎么配置

没懂, context path吗?

我想在 http:localhost:8080/{项目名} 像这样访问

jetty.contextPath=/XXX

启动的时候有打印配置手册吧?

没有打印配置,, tomcat下也可以这样用吗

tomcat.contextPath 就是了, 但我建议你用jetty

好的,那我换成jetty

那个urule版本问题,明天能不能搞好啊,我明天就要用了

你的main方法不是这样的?? setPrintProcDoc设置为true就会打印手册

    public static void main(String[] args) throws Exception {
        new NbApp().setPrintProcDoc(true).run();
    }

urule版本问题??? 指哪一个? 我不是提交了吗?? @ExpontAction ??

我把它设置为false了,尴尬

就是一个内置动作 一个动作

更新后, 加上@AsSpringBean还是报错吗???

我正在启动,我走一下流程

好了,看能不能合成一个注解那就完美了,O(∩_∩)O哈哈~

合成一个注解???

现在只能这样,才不报错

@IocBean
@AsSpringBean
public class CustomerTest {

	@ExposeAction("方法1")
	public boolean evalTest(String username){
		if(username==null){
			return false;
		}else if(username.equals("张三")){
			return true;
		}
		return false;
	}
}

你指的是, 最好能只标注 @ExposeAction , 不需要@AsSpringBean, 对吧?

不是这个,@IocBean和@AsSpringBean 两个bean 同时存在 urule才能生效,能不能只要其中一个

起码现在不能 -_-

哦,凡是有依赖关系的,我们可以合并一下成为一个bean,就更加nice了,嘿嘿

扫描整个项目的包咋搞

"扫描整个项目的包" ??? 你要做什么??

我有com.bstek.urule包里面一个MainLauncher.java类,里面有controller方法;com.bstek.urule.controller包里面也有一个RuleController.java类,里面有controller方法,启动的时候为啥不能访问com.bstek.urule.controller包下的RuleController类下的controller方法

@IocBean(create="init", depose="depose")
public class MainLauncher {
    
    @Inject
    protected PropertiesProxy conf;
    
	@At({"/", "/index"})
    @Ok("beetl:/index.html")
    public NutMap index() {
		NutMap obj = new NutMap();
		obj.setv("name", "NB").setv("age", 18);
		return obj;
    }

    public static void main(String[] args) throws Exception {
        new NbApp().setArgs(args).setPrintProcDoc(true).run();
    }

}
@At("/rule")
@IocBean(create="init", depose="depose")
public class RuleController {

	@Inject
	protected HighspeedrailAction highspeedrailAction;

	@At("/getHig/?")
	@Ok("json:full")
	public List<Map<String,Object>> getHig(String name) throws IOException {
		//创建一个KnowledgeSession对象
		KnowledgeSession session = RuleTool.getSessionFactory( "test01/hig");
		Map<String, Object> param = new HashMap<>();
		param.put("mechanismType", name);
		session.startProcess("demo",param);
		return  HighspeedrailAction.list;
	}
}
添加回复
请先登陆
回到顶部