1
回答
CommonConfig问题
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

@JFinal 你好,想跟你请教个问题:我根据官网的DEMO,配置CommonConfig,配置到到路由这项时候,我选择自动绑定的路由配置方式,代码如下:

public class CommonConfig extends JFinalConfig{

@Override
public void configConstant(Constants me) {
    loadPropertyFile("config.properties");
    me.setDevMode(getPropertyToBoolean("devMode", true));
    me.setViewType(ViewType.JSP);
}


@Override
public void configRoute(Routes routes) {
    RouteBind routeBind = new RouteBind();
    routes.add(routeBind);

}


@Override
public void configPlugin(Plugins plugins) {

}


@Override
public void configInterceptor(Interceptors me) {

}


@Override
public void configHandler(Handlers me) {

}
public static void main(String[] args) {
    JFinal.start("WebRoot", 4891, "/", 5);
}
}

然后run as 出现错误代码:

2016-03-09 10:07:13.304:WARN:oejuc.AbstractLifeCycle:FAILED jfinal: java.lang.NoClassDefFoundError: com/jfinal/log/Logger
java.lang.NoClassDefFoundError: com/jfinal/log/Logger
at cn.dreampie.routebind.RouteBind.<init>(RouteBind.java:28)
at com.demo.common.CommonConfig.configRoute(CommonConfig.java:29)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
at com.jfinal.server.Scanner.compare(Scanner.java:88)
at com.jfinal.server.Scanner.working(Scanner.java:57)
at com.jfinal.server.Scanner.access$0(Scanner.java:55)
at com.jfinal.server.Scanner$1.run(Scanner.java:94)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: 
java.lang.ClassNotFoundException: com.jfinal.log.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
at com.jfinal.server.JFinalClassLoader.loadClass(JFinalClassLoader.java:53)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at cn.dreampie.routebind.RouteBind.<init>(RouteBind.java:28)
at com.demo.common.CommonConfig.configRoute(CommonConfig.java:29)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
at com.jfinal.server.Scanner.compare(Scanner.java:88)
at com.jfinal.server.Scanner.working(Scanner.java:57)
at com.jfinal.server.Scanner.access$0(Scanner.java:55)
at com.jfinal.server.Scanner$1.run(Scanner.java:94)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
2016-03-09 10:07:13.306:WARN:oejuc.AbstractLifeCycle:FAILED o.e.j.w.WebAppContext{/,file:/home/ym/Workspaces/MyEclipse%2010/JFinal_demo/WebRoot/}: java.lang.NoClassDefFoundError: com/jfinal/log/Logger
java.lang.NoClassDefFoundError: com/jfinal/log/Logger
at cn.dreampie.routebind.RouteBind.<init>(RouteBind.java:28)
at com.demo.common.CommonConfig.configRoute(CommonConfig.java:29)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
at com.jfinal.server.Scanner.compare(Scanner.java:88)
at com.jfinal.server.Scanner.working(Scanner.java:57)
at com.jfinal.server.Scanner.access$0(Scanner.java:55)
at com.jfinal.server.Scanner$1.run(Scanner.java:94)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: 
java.lang.ClassNotFoundException: com.jfinal.log.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
at com.jfinal.server.JFinalClassLoader.loadClass(JFinalClassLoader.java:53)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at cn.dreampie.routebind.RouteBind.<init>(RouteBind.java:28)
at com.demo.common.CommonConfig.configRoute(CommonConfig.java:29)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
at com.jfinal.server.Scanner.compare(Scanner.java:88)
at com.jfinal.server.Scanner.working(Scanner.java:57)
at com.jfinal.server.Scanner.access$0(Scanner.java:55)
at com.jfinal.server.Scanner$1.run(Scanner.java:94)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Exception in thread "JFinal-Scanner" java.lang.NoClassDefFoundError: com/jfinal/log/Logger
at cn.dreampie.routebind.RouteBind.<init>(RouteBind.java:28)
at com.demo.common.CommonConfig.configRoute(CommonConfig.java:29)
at com.jfinal.core.Config.configJFinal(Config.java:48)
at com.jfinal.core.JFinal.init(JFinal.java:62)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)
at org.eclipse.jetty.servlet.FilterHolder.doStart(FilterHolder.java:119)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at org.eclipse.jetty.servlet.ServletHandler.initialize(ServletHandler.java:724)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:265)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1250)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:706)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:492)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64)
at com.jfinal.server.JettyServer$1.onChange(JettyServer.java:108)
at com.jfinal.server.Scanner.compare(Scanner.java:88)
at com.jfinal.server.Scanner.working(Scanner.java:57)
at com.jfinal.server.Scanner.access$0(Scanner.java:55)
at com.jfinal.server.Scanner$1.run(Scanner.java:94)
at java.util.TimerThread.mainLoop(Timer.java:512)
at java.util.TimerThread.run(Timer.java:462)
Caused by: java.lang.ClassNotFoundException: com.jfinal.log.Logger
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:430)
at com.jfinal.server.JFinalClassLoader.loadClass(JFinalClassLoader.java:53)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 20 more
意思是少log4j的jar包?但我已经导入了的,而且官网提供的jar包 也没有Logger这中的jar,我的jar包信息:

c3p0-0.9.5.1.jar
cos-26Dec2008.jar
google-collections-1.0.jar
javax.servlet.jsp.jstl-1.2.0.v201105211821.jar
jetty-server-8.1.8.jar
jfinal-2.2-bin-with-src.jar
jfinal-routebind-0.1.jar
jfinal-tablebind-0.1.jar
log4j-1.2.16.jar
mysql-connector-java-5.1.20-bin.jar
org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar

PS:把配置路由里边的自动绑定两行代码注释掉是能正常运行的

<无标签>
举报
共有1个答案 最后回答: 2年前
  jfinal 2.2 的 Logger 改成了 Log,而楼主使用的绑定 routes 的扩展应该是没有升级到 jfinal 2.2 的,所以出现错误,改下相关源码即可。或者弃用路由绑定相关的第三方,jfinal 默认的方式就很好了。
--- 共有 2 条评论 ---
JFinal回复 @戏子非 : jfinal 官方的路由方式才是性能最好,最安全可靠的 2年前 回复
我要打十个噢,原来如此,我看我们这边以前的项目是用这种自动的路由方式,好简洁,觉得方便,所以想自己搭建看看,不知道实际性好不好 2年前 回复
顶部