Java Code Examples for org.springframework.beans.factory.CannotLoadBeanClassException

Following code examples demonstrate how to use org.springframework.beans.factory.CannotLoadBeanClassExceptionfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.beans.factory.CannotLoadBeanClassExceptionand various code implementation of this class.

        }
        catch( CannotLoadBeanClassException e )
        {
            AppLogService.debug( "ActionFactory ERROR : could not load bean '" + e.getBeanName( ) + "' - CAUSE : " + e.getMessage( ) );
        } 


	protected Class<?> resolveBeanClass(RootBeanDefinition mbd, String beanName) throws CannotLoadBeanClassException {
		if (!"dynamic".equals(mbd.getScope())) {
			return super.resolveBeanClass(mbd, beanName);
		}
		else {
			try {
				return mbd.resolveBeanClass(getBeanClassLoader());
			}
			catch (ClassNotFoundException ex) {
				throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(),
						ex);
			}
			catch (LinkageError err) {
				throw new CannotLoadBeanClassException(mbd.getResourceDescription(), beanName, mbd.getBeanClassName(),
						err);
			}
		}
	} 

	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		for (String beanDefName : beanFactory.getBeanDefinitionNames()) {
			BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanDefName);

			if (beanDefinition.isAbstract()) {
				continue;
			}
			String className = beanDefinition.getBeanClassName();

			if (className == null) {
				continue;
			}
			
			Class<?> beanClass;
			
			try {
				beanClass = ClassUtils.forName(className, beanFactory.getBeanClassLoader());
			} catch (ClassNotFoundException e) {
				throw new CannotLoadBeanClassException(beanDefinition.getResourceDescription(), beanDefName, beanDefinition.getBeanClassName(), e);
			} catch (LinkageError e) {
				throw new CannotLoadBeanClassException(beanDefinition.getResourceDescription(), beanDefName, beanDefinition.getBeanClassName(), e);
			}

			Class<?>[] interfaces = beanClass.getInterfaces();
			
			if (interfaces.length == 1 && interfaces[0] == GroovyObject.class) {
				beanDefinition.setAttribute(AutoProxyUtils.PRESERVE_TARGET_CLASS_ATTRIBUTE, true);
			}
		}
	} 

    public static Class<?> findClassByName(String className, String beanName, ParserContext parserContext) {
        String description = parserContext.getReaderContext().getResource().getDescription();
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException ex) {
            throw new CannotLoadBeanClassException(description, beanName, className, ex);
        }
    } 

    private static Class<?> retrieveClassByName(String className) {
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException ex) {
            throw new CannotLoadBeanClassException(null, null, className, ex);
        }
    } 

  private void loadCommand(BeanDefinition beanDefinition) {
    try {
      addCommand(loadClass(beanDefinition));
    } catch (ClassNotFoundException ex) {
      throw new CannotLoadBeanClassException(beanDefinition.getResourceDescription(),  null,
                                             beanDefinition.getBeanClassName(), ex);
    }
  } 

        }
        catch( CannotLoadBeanClassException e )
        {
            _bAvailable = false;
        } 

    }

    private Class<?> getClassOrFigureOutClass(final String beanName,
            final RootBeanDefinition mbd) {
        String className = mbd.getBeanClassName();
        try {
            return Class.forName(className);
        } catch (ClassNotFoundException e) {
            try {
                return Class.forName(packageNameForModelClasses + "."
                        + className);
            } catch (ClassNotFoundException e1) {
                throw new CannotLoadBeanClassException(
                        mbd.getResourceDescription(), beanName,
                        mbd.getBeanClassName(), e1);
            }
        }
    }