Object bean = runtimeModule.getBean(beanName);
try {
// Check if required type matches the type of the actual bean instance.
if (!requiredType.isAssignableFrom(bean.getClass())) {
throw new InvalidBeanTypeException(beanName, requiredType, bean.getClass());
}
}
catch (BeansException e) {
e.printStackTrace();