lundi 17 novembre 2014

Object is not an 'instanceof' it's own class


Vote count:

0




I'm trying to hunt down some issues with spring not expending a factoryBean. I've plugged into a debugger and proven that the failure is in this line of AbstraceBeanFactory:



if(!beanInstance instanceof FactoryBean) || BeanFactoryUtils.isFactoryDereference(name)) {
return beanInstance;
}


specifically the "beanInstance instanceof FactoryBean" part is returning false when it should be true, resulting in my returning a factorybean back rather then the bean that the factory is suppose to construct.


My debugger clearly tells me that the the beanInstance is a org.springframework.beans.factory.config.PropertiesFactoryBean. When I tell eclipse to expand the class of bean I see it clearly implements FactoryBean


For further testing I went to expressions. Supposedly the expression:



beanInstance instanceof org.springframework.beans.factory.config.PropertiesFactoryBean


returns false. However beanInstance.getClass() returns



(org.springframework.beans.factory.config.PropertiesFactoryBean) (id=112)


It seems my VM is very confused about this class. I'm trying to figure out what would cause this confusion, and how I can fix it?


The most likely case seems to be confusion across multiple class loaders, but I haven't found any obvious examples. There should only be one implementation of PropertiesFactoryBean in my classpath.


What would cause instanceof to fail in this manner? How can I hunt down my root cause?


Incidentally, this is ultimately a tomcat instance I'm debugging, if it's relevant. Also, beanInstance is an instanceof Object, so intanceof does work properly sometimes.


ps. I had to type this by hand rather then copy/paste. Please assume any obvious naming mistakes are typos on my part.



asked 43 secs ago







Object is not an 'instanceof' it's own class

Aucun commentaire:

Enregistrer un commentaire