ITeye博客

Spring异常备忘录

ace · 2010-09-09 09:32 · Spring · 企业架构 · Markdown

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/web-inf/springmvc-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/web-inf/springmvc-servlet.xml]
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/web-inf/springmvc-servlet.xml]

在WEB-INF 下确实是没有找到springmvc-servlet.xml , 同时根本没有编辑这个xml文件,更加没有引用他

原因是:在web.xml里配置了如下的servlet


<servlet>
  <servlet-name>adminServlet</servlet-name>
  <servletclass>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!--
    <init-param>
     <param-name>namespace</param-name>
     <param-value>admin-servlet</param-value>
    </init-param>
    <init-param>
      <param-name>namespace</param-name>
      <param-value>spring/mvc-config</param-value>
    </init-param>
    -->
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>adminServlet</servlet-name>
<url-pattern>/remote/*</url-pattern>
</servlet-mapping>

注意在运行时,Spring会在WEB-INF下去找adminServlet-servlet.xml这个是默认规定的,当然你可以像斜体内容去指定加载的*.xml文件名

not allowed in read-only mode (FlushMode.NEVER)

即check打头的操作时,是不可操作数据库的,包括更新与增加数据。

<bean id="transactionInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor">
  <property name="transactionManager" ref="transactionManager" />
  <property name="transactionAttributes">
    <props>
      <prop key="query*">PROPAGATION_REQUIRED,readOnly</prop>
      <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
      <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
      <prop key="check*">PROPAGATION_REQUIRED,readOnly</prop>
      <prop key="insert*">
        PROPAGATION_REQUIRED,-GenericException  
       </prop>

即check打头的操作时,是不可操作数据库的,包括更新与增加数据。 修改为

<prop key="check*">PROPAGATION_REQUIRED</prop>  

评论(3)

  1. #3 楼 · JAVACHEN010 · 2011-08-01 11:13

    我也出现第一个问题·你说的我了解我在前面加了 contextConfigLocation classpath:beans.xml 但是还是不能解决·请问下你是如何解决的?!

  2. #2 楼 · javaEEdevelop · 2011-04-02 11:02

    我遇到了你上面所说的第一个问题

    
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    	<!---->   <context-param>                         
    			<param-name>contextConfigLocation</param-name>
    			<param-value>/WEB-INF/config/application-config.xml</param-value>
    	</context-param>  
    	 
    	 <listener>    
    			<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    	</listener> 
    	 
    	<!-- sping security  -->
    	<filter> 
    			<filter-name>springSecurityFilterChain</filter-name>
    			<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    	</filter>
    	
    	<!-- srping delegating flex -->     
    	<servlet>                                         
    			<display-name>spring MVC</display-name>
    			<servlet-name>spring MVC</servlet-name>
    			<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    			<!----> <init-param>  
    				<param-name>contextConfigLocation</param-name>
    				<param-value>/WEB-INF/config/application-config.xml</param-value>
    			</init-param>
    			<load-on-startup>-1</load-on-startup> 
    	</servlet>   
    	
    	 
    	<servlet-mapping>
    		<servlet-name>spring MVC</servlet-name>
    		<url-pattern>/spring/*</url-pattern>
    	</servlet-mapping>
    	<filter-mapping>
    			<filter-name>springSecurityFilterChain</filter-name>
    			<url-pattern>/*</url-pattern>
    	</filter-mapping>
    
    
        <welcome-file-list>
            <welcome-file>index.html</welcome-file>
            <welcome-file>index.htm</welcome-file>
        </welcome-file-list>
    
    
    
    </web-app>
    
    
    

    因为这是根sping security整合,所以配了二个application-config文件,如果spring MVC不配application-config文件,等下访问就说没有找到这个文件

  3. #1 楼 · wuyakenihao · 2011-03-24 14:53

    老大在不,我遇到了你上面所说的第一个问题,不是很清楚你说的什么意思,能否在描述的清楚点。“在WEB-INF 下确实是没有找到springmvc-servlet.xml , 同时根本没有编辑这个xml文件,更加没有引用他 ” 这个句话什么意思?

评论功能维护中,当前仅展示历史评论。