JFinal默认加载spring配置文件applicationContext.xml的路径是项目下的/WEB-INF/下,在windows操作系统下运行正常,部署在Linux系统下报错,如下提示信息(找不到spring的配置文件):
[INFO ][localhost-startStop-1] 2015-10-27 18:35:05.219 - AbstractApplicationContext.prepareRefresh(495) | Refreshing org.springframework.context.support.FileSystemXmlApplicationContext@5d69a0c5: startup date [Tue Oct 27 18:35:05 CST 2015]; root of context hierarchy
[INFO ][localhost-startStop-1] 2015-10-27 18:35:05.272 - XmlBeanDefinitionReader.loadBeanDefinitions(315) | Loading XML bean definitions from file [/home/tomcat_zlp/bin/home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml]
[ERROR][localhost-startStop-1] 2015-10-27 18:35:05.273 - Config.startPlugins(95) | Plugin start error: com.jfinal.plugin.spring.SpringPlugin.
IOException parsing XML document from file [/home/tomcat_zlp/bin/home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml]; nested exception is java.io.FileNotFoundException: home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml (No such file or directory)
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from file [/home/tomcat_zlp/bin/home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml];
nested exception is java.io.FileNotFoundException: home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml (No such file or directory)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:522)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:436)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:94)
at com.jfinal.plugin.spring.SpringPlugin.start(SpringPlugin.java:50)
at com.jfinal.core.Config.startPlugins(Config.java:87)
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:4830)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5510)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
... 29 more
观察发现,打印出来的查找路径home/tomcat_zlp/webapps/zlp_view/WEB-INF/applicationContext.xml前面少了/
需要重新指定路径,方法如下:
重启tomcat,正常