
|
If you were logged in you would be able to see more operations.
|
|
|
|
Environment:
|
Tomcat, Java 1.6.0_02 (1.6 is missing from dropdown), struts 2
|
|
| Virtual Machine: |
Sun JVM
- 1.5
|
This is the worst possible kind of bug report, and so I apologize in advance, but it has only appeared once in production and was not reproducible. On top of that, the actual case that generates the error seems to be pretty much impossible. The cast exception you see below, is in this Spring code:
/**
As you can see the method checks if the field is a Class, and casts to it if it is. However, in this case below, for some reason, it tried to cast it to a String even though it was a Class. I don't know if this is some strange classloading issue, a JVM bug, or what, but I figured you would want to at least see it.
Stack trace:
------------------------------
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityModel' defined in class path resource [applicationContext-siteresources.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
at org.springframework.beans.factory.support.AbstractBeanDefinition.getBeanClassName(AbstractBeanDefinition.java:311)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1066)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:349)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:881)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:829)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:229)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
at com.cargurus.site.interceptor.ModelInterceptor.intercept(ModelInterceptor.java:75)
|
|
Description
|
This is the worst possible kind of bug report, and so I apologize in advance, but it has only appeared once in production and was not reproducible. On top of that, the actual case that generates the error seems to be pretty much impossible. The cast exception you see below, is in this Spring code:
/**
As you can see the method checks if the field is a Class, and casts to it if it is. However, in this case below, for some reason, it tried to cast it to a String even though it was a Class. I don't know if this is some strange classloading issue, a JVM bug, or what, but I figured you would want to at least see it.
Stack trace:
------------------------------
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityModel' defined in class path resource [applicationContext-siteresources.xml]: Initialization of bean failed; nested exception is java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.String
at org.springframework.beans.factory.support.AbstractBeanDefinition.getBeanClassName(AbstractBeanDefinition.java:311)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:327)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1066)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:349)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByName(AbstractAutowireCapableBeanFactory.java:881)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:829)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:270)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:229)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
at com.cargurus.site.interceptor.ModelInterceptor.intercept(ModelInterceptor.java:75) |
Show » |
Sort Order:
|
This is almost certainly a class loading issue. It's pretty strange that even the Class class cannot be cast to Class, though!
In any case, I don't see what we could do about this in Spring's code... other than adding an explicit assertion maybe.
Juergen