I'm getting a ClassCastException when running the following code:
14:33:18,508 XmlBeanFactory DEBUG - Returning cached instance of singleton bean 'flightAvailability'
Resource res = new FileSystemResource("flightAvailabilityTest.xml");
BeanFactory factory = new XmlBeanFactory(res);
//Get the requests container
FlightAvailabilityRequestsHolder requestsHolder = null;
requestsHolder = (FlightAvailabilityRequestsHolder) factory.getBean("flightAvailability");
LOG.error("ClassCastException casting to FlightAvailabilityRequestsHolder.\n" +
"Class found was: " + factory.getBean("flightAvailability").getClass().getName() + "\n" +
"Class expected was: " + FlightAvailabilityRequestsHolder.class.getName());
14:33:18,509 FlightAvailabilityTestCase ERROR - ClassCastException casting to FlightAvailabilityRequestsHolder.
Class found was: com.mycorp.test.FlightAvailabilityRequestsHolder
Class expected was: com.mycorp.test.FlightAvailabilityRequestsHolder
Notice that these are the same!
If I run this as a stand alone application, all works just fine, but when I put it inside another Spring based app (a framework that I'm trying to incorporate into) I get this problem.
Is there some issue with having multiple BeanFactory classes maybe?
Note that I don't have easy access to th current BeanFactory and it is set up to load a specific application context file and I need to add my own file apart from it, and that is why I went this route.
Any help is greatly appreciated!