spring、struts、mybatis集成WARN [com.opensymphony.xwork2.util.FileManager] (MSC service thread 1-1) Cou

本人在进行spring、struts、mybatis集成过程中出现了很多问题,现记录如下,希望对本人以后及其它遇到类似错误的人提供一些借鉴。

1、Eclipse使用问题
当选择server(如JBoss)的发布按钮没有反应或者没有变化时,此时应在server上点击右键,然后选择“clean”,此时项目会进行清理和发布。

2、版本问题
Struts、 Spring、Mybatis版本要匹配,否则会出现莫名奇妙的警告,例如本人开始使用的版本是:struts-2.2.3、spring3.1、 mybatis-3.1.1,出现下面的警告,当将struts的版本换成struts-2.3.7时,警告消失。
WARN [com.opensymphony.xwork2.util.FileManager] (MSC service thread 1-1) Could not create JarEntryRevision for [vfs:/D:/JBoss/jbossAS711Final/standalone/deployments/SS2MTest.war/WEB-INF/lib/struts2-spring-plugin-2.2.3]!: java.io.FileNotFoundException: vfs:/D:/JBoss/jbossAS711Final/standalone/deployments/SS2MTest.war/WEB-INF/lib/struts2-spring-plugin-2.2.3 (文件名、目录名或卷标语法不正确。)
at java.util.zip.ZipFile.open(Native Method) [rt.jar:1.6.0_07]
at java.util.zip.ZipFile.<init>(ZipFile.java:114) [rt.jar:1.6.0_07]
at java.util.jar.JarFile.<init>(JarFile.java:133) [rt.jar:1.6.0_07]
at java.util.jar.JarFile.<init>(JarFile.java:97) [rt.jar:1.6.0_07]
at com.opensymphony.xwork2.util.FileManager$JarEntryRevision.build(FileManager.java:307) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:145) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.util.FileManager.loadFile(FileManager.java:105) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadConfigurationFiles(XmlConfigurationProvider.java:898) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.loadDocuments(XmlConfigurationProvider.java:154) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.init(XmlConfigurationProvider.java:121) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:179) [xwork-core-2.2.3.jar:2.2.3]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:66) [xwork-core-2.2.3.jar:2.2.3]
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:380) [struts2-core-2.2.3.jar:2.2.3]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:424) [struts2-core-2.2.3.jar:2.2.3]
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69) [struts2-core-2.2.3.jar:2.2.3]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.2.3.jar:2.2.3]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]

3、Struts错误
ERROR [org.apache.struts2.dispatcher.Dispatcher] (MSC service thread 1-1) Dispatcher initialization failed: Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:71) [xwork-core-2.3.7.jar:2.3.7]
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:447) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3269) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3865) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:391) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:362) [struts2-core-2.3.7.jar:2.3.7]
at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:288) [struts2-core-2.3.7.jar:2.3.7]
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) [xwork-core-2.3.7.jar:2.3.7]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:68) [xwork-core-2.3.7.jar:2.3.7]
... 13 more

解决方法:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>configFiles/struts.xml</param-value>
</init-param>
</filter>

改成

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>platform-web.xml,struts-default.xml,struts-plugin.xml,configFiles/struts.xml</param-value>
</init-param>
</filter>

4、Spring错误
ERROR [org.springframework.web.context.ContextLoader] (MSC service thread 1-3) Context initialization failed:
org.springframework.beans.factory.BeanDefinitionStoreException: Could not resolve bean definition resource pattern [configFiles/applicationContext*.xml]; nested exception is java.io.FileNotFoundException: ServletContext resource [/configFiles/] cannot be resolved to URL because it does not exist
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:190) [spring-beans-2.5.6.jar:2.5.6]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) [spring-beans-2.5.6.jar:2.5.6]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) [spring-web-2.5.6.jar:2.5.6]
at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:92) [spring-web-2.5.6.jar:2.5.6]
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:123) [spring-context-2.5.6.jar:2.5.6]
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422) [spring-context-2.5.6.jar:2.5.6]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352) [spring-context-2.5.6.jar:2.5.6]
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255) [spring-web-2.5.6.jar:2.5.6]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199) [spring-web-2.5.6.jar:2.5.6]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45) [spring-web-2.5.6.jar:2.5.6]
at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885) [rt.jar:1.6.0_07]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907) [rt.jar:1.6.0_07]
at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_07]
Caused by: java.io.FileNotFoundException: ServletContext resource [/configFiles/] cannot be resolved to URL because it does not exist
at org.springframework.web.context.support.ServletContextResource.getURL(ServletContextResource.java:130) [spring-web-2.5.6.jar:2.5.6]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.isJarResource(PathMatchingResourcePatternResolver.java:406) [spring-core-

2.5.6.jar:2.5.6]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources(PathMatchingResourcePatternResolver.java:338) [spring-core-2.5.6.jar:2.5.6]
at org.springframework.core.io.support.PathMatchingResourcePatternResolver.getResources(PathMatchingResourcePatternResolver.java:276) [spring-core-2.5.6.jar:2.5.6]
at org.springframework.context.support.AbstractApplicationContext.getResources(AbstractApplicationContext.java:1018) [spring-context-2.5.6.jar:2.5.6]
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:177) [spring-beans-2.5.6.jar:2.5.6]
... 17 more

解决方法:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>configFiles/applicationContext*.xml</param-value>
</context-param>

改成
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:configFiles/applicationContext*.xml</param-value>
</context-param>
注意:与spring相关的配置文件路径,都要使用classpath*:或其它关键字来限定位置,这与struts不一样。

你可能感兴趣的:(mybatis)