Exception starting filter jfinal

严重: Exception starting filter jfinal

java.lang.IllegalStateException: Load propties file by invoking loadPropertyFile(String fileName) method first.

at com.jfinal.config.JFinalConfig.getProp(JFinalConfig.java:124)

at com.jfinal.config.JFinalConfig.getProperty(JFinalConfig.java:129)

at www.gulixiong.config.Config.configPlugin(Config.java:49)

at com.jfinal.core.Config.configJFinal(Config.java:48)

at com.jfinal.core.JFinal.init(JFinal.java:65)

at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:49)

at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)

at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)

at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)

at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4598)

at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5223)

at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:155)

at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:724)

at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:700)

at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:718)

at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1097)

at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1798)

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:745)


评论区

gulixiong

2017-02-11 10:17

哪位大神知道这个问题怎么解决

lyh061619

2017-02-11 10:34

你贴下你加载配置文件部分相关的代码出来看看。

lyh061619

2017-02-11 10:36

不行的话,你就修改成这样子,
public void loadProp(String pro, String dev) {
try {
PropKit.use(pro);
}
catch (Exception e) {
PropKit.use(dev);
}
}

@Override
public void configConstant(Constants me) {
loadProp("a_little_config_pro.txt", "a_little_config.txt");
me.setDevMode(PropKit.getBoolean("devMode", false));
me.setEncoding(PropKit.get("encoding", "utf-8"));
}
试下:

JFinal

2017-02-11 11:00

在调用 getProperty 方法之前,需要先调用一次 loadProperty 方法预先加载配置文件。这两个方法已不被建议使用,建议使用 PropKit.use(configFile.txt) 以及 PropKit.get(...) 系列的方法

具体可以下载首页的 jfinal demo ,里面有现成的代码

gulixiong

2017-02-11 18:28

@lyh061619 大神,我用的开发工具是MyEclipse,a_little_config.txt和log4j.properties放在src目录下,然后就报了我发帖中的错误,PropKit.use("a_little_config.txt");这个我在Config类中用到了

lyh061619

2017-02-11 23:03

@gulixiong 这个跟存放目录及开发工具没有多大关系的,重点是你按我上面贴的代码改造下成功记得回来分享下,因为你用loadProperty就如波总提到的两这个方法已经不建议使用了。

gulixiong

2017-02-12 10:06

@lyh061619 我的代码中没有用到loadProperty,用的是PropKit.use("a_little_config.txt");

cyf123

2018-03-14 09:30

我在webConfig 中 run---启动可以。在tomcat 下启动就报这个错了。是怎么回事啊,哪个大神知道啊。

三月 14, 2018 9:28:17 上午 org.apache.catalina.core.StandardContext filterStart
严重: Exception starting filter jfinal
java.lang.RuntimeException: Can not create instance of class: ibasic.web.com.config.WebConfig
at com.jfinal.core.JFinalFilter.createJFinalConfig(JFinalFilter.java:102)
at com.jfinal.core.JFinalFilter.init(JFinalFilter.java:47)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:397)
at org.apache.catalina.core.ApplicationFilterConfig.(ApplicationFilterConfig.java:108)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3693)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4340)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
Caused by: java.lang.ClassNotFoundException: ibasic.web.com.config.WebConfig
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1358)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1204)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.jfinal.core.JFinalFilter.createJFinalConfig(JFinalFilter.java:100)
... 28 more

三月 14, 2018 9:28:17 上午 org.apache.catalina.core.StandardContext start
严重: Error filterStart
三月 14, 2018 9:28:17 上午 org.apache.catalina.core.StandardContext start
严重: Context [/sub_person_inner_for_maven] startup failed due to previous errors
三月 14, 2018 9:28:17 上午 org.apache.coyote.http11.Http11Protocol start
信息: Starting Coyote HTTP/1.1 on http-8080
三月 14, 2018 9:28:18 上午 org.apache.jk.common.ChannelSocket init
信息: JK: ajp13 listening on /0.0.0.0:8009
三月 14, 2018 9:28:18 上午 org.apache.jk.server.JkMain start
信息: Jk running ID=0 time=0/62 config=null
三月 14, 2018 9:28:18 上午 org.apache.catalina.startup.Catalina start
信息: Server startup in 3275 ms

热门反馈

扫码入社