ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testaction' defined in file [C:\Program Files\Tomcat 6.0\webapps\SearchSystem\WEB-INF\classes\beans.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found
Caused by: 
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessException details (1) are:
PropertyAccessException 1:
org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found
Caused by: 
java.lang.IllegalArgumentException: Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:138)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:815)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
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:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
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:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-5-18 16:46:45 org.apache.catalina.core.StandardContext listenerStart

解决方案 »

  1.   

    Cannot convert value of type [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service': no matching editors or conversion strategy found把你的配置文件贴出来
      

  2.   

    spring配置错了。service的bean配错了吧
      

  3.   

    ref <-> value我猜,上面连个配置弄错了。 
      

  4.   

    我重新配置了一下,现在又报这个错了:
    ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 88 in XML document from file [C:\Program Files\Tomcat 6.0\webapps\SearchSystem\WEB-INF\classes\beans.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-id.1: There is no ID/IDREF binding for IDREF 'testdao'.
    Caused by: 
    org.xml.sax.SAXParseException: cvc-id.1: There is no ID/IDREF binding for IDREF 'testdao'.
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    郁闷啊....
      

  5.   

    spring这样配置有问题吗??帮忙看看了,我改了几遍了,每改一次就报不同的异常....
    <!-- 配置dao -->
         <bean id="tesdao" class="com.org.dao.TestDao">
               <property name="sessionFactory">
                  <ref local="sessionFactory"/>
               </property>
         </bean>
         <!-- 配置service -->
         <bean id="testservice" class="com.org.service.TestService">
             <property name="dao">
                  <ref local="testdao"/>
             </property>
         </bean>
         <!-- 配置action -->
         <bean id="testaction" class="com.org.action.TestAction">
             <property name="service">
                <ref local="testservice"/>
             </property>
         </bean>
      

  6.   

    贴配置文件web.xml bean.xml文件
      

  7.   

    web.xml的配置:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  
     http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
     <!-- 配置过滤器 处理中文编码格式-->
     <filter>
      <filter-name>filter</filter-name>
      <filter-class>com.org.filters.filter</filter-class>
      </filter>
      <filter-mapping>
      <filter-name>filter</filter-name>
      <url-pattern>/*</url-pattern>
      </filter-mapping>
     
      <filter>
       <filter-name>opensession</filter-name>
       <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
       <init-param>
       <param-name>flushMode</param-name>   
       <param-value>AUTO</param-value>   
       </init-param>
      </filter>
      <filter-mapping>
       <filter-name>opensession</filter-name>
       <url-pattern>/*</url-pattern>
      </filter-mapping>
      <!-- 配置监听器管理sping -->
       <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>
      <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>classpath:bean*.xml</param-value>
      </context-param>
      <!-- 配置过滤器 -->
      <!--<filter>
       <filter-name>struts2</filter-name>
       <filter-class>
            org.apache.struts2.dispatcher.FilterDispatcher
       </filter-class>
      </filter>
      <filter-mapping>
       <filter-name>struts2</filter-name>
       <url-pattern>*.action</url-pattern>
      </filter-mapping> -->
      
      
      <welcome-file-list>
        <welcome-file>index.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>
    </web-app>
      

  8.   

    把bean.xml中的
    <ref local="sessionFactory"/>
    改为
    <ref ref="sessionFactory"/>
    其他的也都改了把local改为ref
    try it...
      

  9.   

    不好意思写错了
    把bean.xml中的
    <ref local="sessionFactory"/>
    改为
    <ref bean="sessionFactory"/>
    其他的也都改了把local改为bean
    try it...
      

  10.   

    问题解决了...
    [com.org.service.TestService] to required type [com.org.iservice.Itest] for property 'service'问题出这了,我的TestService忘记实现Itest接口了,额,编程一定要小心谨慎啊....呼呼..