SSH框架搞起来,启动报错!!!
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:78)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:663)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:638)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:407)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4681)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5184)
at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5179)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
at org.springframework.web.context.support.ServletContextResource.getInputStream(ServletContextResource.java:117)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:161)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:69)
... 14 moreweb.xml配置如下:::<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
 
   <listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <welcome-file-list>
     <welcome-file>reg.jsp</welcome-file>
   </welcome-file-list>
  <filter>
   <filter-name>struts2</filter-name>
   <filter-class>
   org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
   </filter-class>
  </filter>
  
   <filter-mapping>
   <filter-name>struts2</filter-name>
   <url-pattern>*.action</url-pattern>
   </filter-mapping>
   <filter>
    <filter-name>encoding</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
     <param-name>encoding</param-name>
      <param-value>UTF-8</param-value>
    </init-param>
   </filter>
  
   <filter-mapping>
    <filter-name>encoding</filter-name>
    <url-pattern>/*</url-pattern>
   </filter-mapping>
</web-app>applicationContex.xml配置如下:<bean name="userDaoImpl" class="dao.impl.UserDaoImpl"
  scope="prototype">
  <property name="sessionFactory" ref="sf"></property>
 </bean>
 <bean name="reg" class="action.UserAction" scope="prototype">
  <property name="userDaoImpl" ref="userDaoImpl"></property>
 </bean>
 <bean id="propertyConfigurer"
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="locations">
   <list>
    <value>jdbc.properties</value>
   </list>
  </property>
 </bean>
 
  <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName"
   value="${jdbc.driverClassName}"/>
  <property name="url" value="${jdbc.url}"/>
  <property name="username" value="${jdbc.username}"/>
  <property name="password" value="${jdbc.password}"/>
 </bean> <!--配置SessionFactory -->
 <bean id="sf"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="configLocation"
   value="classpath:hibernate.cfg.xml" />
 </bean> <aop:config>
  <aop:advisor pointcut="execution(* *..PetStoreFacade.*(..))"
   advice-ref="txAdvice" />
 </aop:config>
 <tx:advice id="txAdvice" transaction-manager="txManager">
  <tx:attributes>
   <tx:method name="insert*" />
   <tx:method name="update*" />
   <tx:method name="delete*" />
   <tx:method name="modify*" />
   <tx:method name="*" read-only="true" />
  </tx:attributes>
 </tx:advice> <bean id="txManager"
  class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource" />
  </bean>
 </beans>
肿么就找不到呢!!!!愁愁愁愁!!!!!!!!!

解决方案 »

  1.   

     <bean id="propertyConfigurer"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="locations">
      <list>
      <value>classpath:jdbc.properties</value>
      </list>
      </property>
     </bean>
    可能是没有加载类,加上classpath试试
      

  2.   

    路径不对 写成这样过去了 <property name="locations">
    <list>
    <value>/WEB-INF/jdbc.properties</value>
    </list>
    </property>
    不过感谢回答哦!!!!!!!!!!!!
      

  3.   


    我一直以为默认的路径就是/WEB-INF/....  呢!!!!