在使用Spring相關(guān)產(chǎn)品時,你可能會碰到下面這種異常:
          Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
          這是異常的第一行,按以往的經(jīng)驗,第一行應(yīng)該就是問題所在,但是實際上,從這行來看你根本不知道錯在哪里。

          后面接下來的是:
          Error creating bean with name 'basicProcessingFilter'
          Cannot resolve reference to bean 'authenticationManager'
          while setting bean property 'authenticationManager';

          nested exception is Error creating bean with name 'authenticationManager'
          Cannot resolve reference to bean 'casAuthenticationProvider'
          while setting bean property 'providers' with key [0];

          nested exception is : Error creating bean with name 'casAuthenticationProvider'
          Cannot resolve reference to bean 'statelessTicketCache'
          while setting bean property 'statelessTicketCache';

          nested exception is: Error creating bean with name 'statelessTicketCache'
          Error setting property values;

          nested exception is
          nested PropertyAccessExceptions (1) are:
          PropertyAccessException 1:
          TypeMismatchException:

          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          Error creating bean with name 'authenticationManager'
          Cannot resolve reference to bean 'casAuthenticationProvider'
          while setting bean property 'providers' with key [0];

          nested exception is
          Error creating bean with name 'casAuthenticationProvider'
          Cannot resolve reference to bean 'statelessTicketCache' while setting bean property 'statelessTicketCache';

          nested exception is
          Error creating bean with name 'statelessTicketCache'
          Error setting property values;

          nested exception is
          nested PropertyAccessExceptions (1) are:
          PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          Error creating bean with name 'casAuthenticationProvider'
          Cannot resolve reference to bean 'statelessTicketCache'
          while setting bean property 'statelessTicketCache';

          nested exception is
          Error creating bean with name 'statelessTicketCache'
          Error setting property values;

          nested exception is PropertyAccessExceptionsException;
          nested PropertyAccessExceptions (1) are:
          PropertyAccessException 1:TypeMismatchException:
          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          Error creating bean with name 'statelessTicketCache'
          Error setting property values;

          nested exception is PropertyAccessExceptionsException;
          nested PropertyAccessExceptions (1) are:
          PropertyAccessException 1: org.springframework.beans.TypeMismatchException:
          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          PropertyAccessExceptionsException;
          nested PropertyAccessException details (1) are:
          PropertyAccessException 1:
          ypeMismatchException:
          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          上面的內(nèi)容是我將重復(fù)信息去掉,并分塊后的結(jié)果。

          從報錯機制可以看出來,spring出現(xiàn)異常不同于普通的java異常,我們查異常的習(xí)慣一般是關(guān)注第一行,但是sping恰恰相反,要在sping中查錯,你必須分解他,因為spring的嵌套層次比較多,它報錯是從最高層報起,然后逐層往下,每個層次都會要報錯,直到最終出錯的地方,因此查sping的錯必須逐層分解到最底層,那里才是真正出錯的地方。

          OK,現(xiàn)在看出來了,真正錯誤的原因是:
          Failed to convert property value of type [net.sf.ehcache.Cache]
          to required type [net.sf.ehcache.Ehcache] for property 'cache'

          我出現(xiàn)這個錯誤的原因是使用了Acegi 1.0.5,它本身自帶了ehcache 1.2.4.jar
          但是我同時還使用了hibernate3.1,從Eclipse導(dǎo)入hibernate3.1時,將會導(dǎo)入ehcache 1.1.jar,因為hibernate本身也要使用EHCache,但是版本不同。


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          posts - 3, comments - 32, trackbacks - 0, articles - 3

          Copyright © Exiler

          主站蜘蛛池模板: 台州市| 兴化市| 禄劝| 革吉县| 金寨县| 新安县| 郓城县| 石狮市| 榆社县| 锡林郭勒盟| 苍南县| 赤峰市| 涿鹿县| 静宁县| 忻城县| 若尔盖县| 成武县| 辽阳市| 资阳市| 温州市| 阿克苏市| 平度市| 孟村| 玉林市| 海晏县| 翁牛特旗| 公安县| 临泽县| 新巴尔虎右旗| 峨眉山市| 台南市| 塘沽区| 科尔| 平利县| 津南区| 榆林市| 宜川县| 谢通门县| 日土县| 威海市| 随州市|