2007年12月25日

在使用Spring相关产品时,你可能会碰到下面这种异常:
Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
这是异常的第一行,按以往的经验,第一行应该就是问题所在,但是实际上,从这行来看你根本不知道错在哪里。

后面接下来的是:
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'

上面的内容是我将重复信息去掉,并分块后的结果。

从报错机制可以看出来,spring出现异常不同于普通的java异常,我们查异常的习惯一般是关注第一行,但是sping恰恰相反,要在sping中查错,你必须分解他,因为spring的嵌套层次比较多,它报错是从最高层报起,然后逐层往下,每个层次都会要报错,直到最终出错的地方,因此查sping的错必须逐层分解到最底层,那里才是真正出错的地方。

OK,现在看出来了,真正错误的原因是:
Failed to convert property value of type [net.sf.ehcache.Cache]
to required type [net.sf.ehcache.Ehcache] for property 'cache'

我出现这个错误的原因是使用了Acegi 1.0.5,它本身自带了ehcache 1.2.4.jar
但是我同时还使用了hibernate3.1,从Eclipse导入hibernate3.1时,将会导入ehcache 1.1.jar,因为hibernate本身也要使用EHCache,但是版本不同。

posted @ 2007-12-25 10:02 Exiler 阅读(3074) | 评论 (0)编辑 收藏


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

Copyright © Exiler