JFinal项目运行报错
web.xml照搬手册
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>example</display-name> <filter> <filter-name>jfinal</filter-name> <filter-class>com.jfinal.core.JFinalFilter</filter-class> <init-param> <param-name>configClass</param-name> <param-value>demo.DemoConfig</param-value> </init-param> </filter> <filter-mapping> <filter-name>jfinal</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> </web-app>
DemoConfig代码
public void configConstant(Constants me){ me.setMainRenderFactory(new BeetlRenderFactory()); GroupTemplate gt = BeetlRenderFactory.groupTemplate; } public void configRoute(Routes me) { me.add("/", HomeController.class); me.add("/login", UserController.class,"/"); } public void configPlugin(Plugins me) { //TODO } public void configInterceptor(Interceptors me) { //TODO } public void configHandler(Handlers me) { //TODO } public static void main(String[] args) { JFinal.start("WebRoot", 80, "/", 5); }
Starting JFinal 1.9 Starting scanner at interval of 5 seconds. Starting web server on port: 80 2015-01-13 22:29:17.501:WARN:oejuc.AbstractLifeCycle:FAILED jfinal: java.lang.RuntimeException: Can not create instance of class: demo.DemoConfig. Please check the config in web.xml java.lang.RuntimeException: Can not create instance of class: demo.DemoConfig. Please check the config in web.xml at com.jfinal.core.JFinalFilter.createJFinalConfig(JFinalFilter.java:104) at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:47) 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 org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:277) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at com.jfinal.server.JettyServer.doStart(JettyServer.java:120) at com.jfinal.server.JettyServer.start(JettyServer.java:64) at com.jfinal.core.JFinal.start(JFinal.java:159) at demo.DemoConfig.main(DemoConfig.java:33) 2015-01-13 22:29:17.503:WARN:oejw.WebAppContext:Failed startup of context o.e.j.w.WebAppContext{/,file:/D:/extend/workspace/example/WebRoot/} java.lang.RuntimeException: Can not create instance of class: demo.DemoConfig. Please check the config in web.xml at com.jfinal.core.JFinalFilter.createJFinalConfig(JFinalFilter.java:104) at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:47) 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 org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:95) at org.eclipse.jetty.server.Server.doStart(Server.java:277) at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:64) at com.jfinal.server.JettyServer.doStart(JettyServer.java:120) at com.jfinal.server.JettyServer.start(JettyServer.java:64) at com.jfinal.core.JFinal.start(JFinal.java:159) at demo.DemoConfig.main(DemoConfig.java:33) Starting Complete. Welcome To The JFinal World :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
不行的,我的项目本来正常,上传svn。 再导下来,就报这个错误。 java build path 都配置正确。 好奇怪。。。
引用来自“人人皆为初学者”的评论
有继承JFinalConfig,class是在WEB-INF下,我想是项目结构不对或运行姿势不对,同样的代码IDEA下跑没问题
编译的 class 文件输出路径需要设置为 WEB-INF/classes 才可以
有继承JFinalConfig,class是在WEB-INF下,我想是项目结构不对或运行姿势不对,同样的代码IDEA下跑没问题
DemoConfig 有无继承自 JFinalConfig,有无放在 demo 这个包下面?
引用来自“JFinal”的评论
DemoConfig 有无继承自 JFinalConfig,有无放在 demo 这个包下面?
这个在 jfinal 手册第一章有明确的说明
引用来自“JFinal”的评论
编译的 class 文件输出路径需要设置为 WEB-INF/classes 才可以