Example usage for java.io InvalidClassException getMessage

List of usage examples for java.io InvalidClassException getMessage

Introduction

In this page you can find the example usage for java.io InvalidClassException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Produce the message and include the classname, if present.

Usage

From source file:com.googlecode.icegem.serialization.spring.AutoSerializableRegistrarBean.java

private void registerClasses(ClassLoader classLoader) throws ClassNotFoundException {

    List<Class<?>> toRegister = new ArrayList<Class<?>>();

    for (String pack : scanPackages) {
        logger.debug("Scan {}.* for @AutoSerializable classes", pack);
        ClassPathScanningCandidateComponentProvider ppp = new ClassPathScanningCandidateComponentProvider(
                false);/*  w  w  w  . j  a  va  2 s.c  om*/
        ppp.addIncludeFilter(new AnnotationTypeFilter(AutoSerializable.class));
        Set<BeanDefinition> candidateComponents = ppp.findCandidateComponents(pack);
        for (BeanDefinition beanDefinition : candidateComponents) {
            String className = beanDefinition.getBeanClassName();
            final Class<?> clazz = Class.forName(className);
            toRegister.add(clazz);
        }
    }

    toRegister.addAll(registeredClasses);
    logger.info("All classes that will be registered in GemFire: " + toRegister);

    try {
        HierarchyRegistry.registerAll(classLoader, toRegister);
    } catch (InvalidClassException e) {
        final String msg = "Some class from list " + toRegister + " is nor serializable. Cause: "
                + e.getMessage();
        throw new IllegalArgumentException(msg, e);
    } catch (CannotCompileException e) {
        final String msg = "Can't compile DataSerializer classes for some classes from list " + toRegister
                + ". Cause: " + e.getMessage();
        throw new IllegalArgumentException(msg, e);
    }
}

From source file:com.googlecode.icegem.cacheutils.common.PeerCacheService.java

/**
 * @param classLoader/*from ww  w .  j a  v a2s  .  c  om*/
 * @throws Exception
 */
private void registerClasses(ClassLoader classLoader) throws Exception {
    List<Class<?>> classesFromPackages = new ArrayList<Class<?>>();

    for (String pack : scanPackages) {
        log.info("Scan package " + pack + " for classes marked by @AutoSerializable");

        ClassPathScanningCandidateComponentProvider ppp = new ClassPathScanningCandidateComponentProvider(
                false);

        ppp.addIncludeFilter(new AnnotationTypeFilter(AutoSerializable.class));

        Set<BeanDefinition> candidateComponents = ppp.findCandidateComponents(pack);

        for (BeanDefinition beanDefinition : candidateComponents) {
            String className = beanDefinition.getBeanClassName();

            final Class<?> clazz = Class.forName(className);

            classesFromPackages.add(clazz);
        }
    }

    try {
        HierarchyRegistry.registerAll(classLoader, classesFromPackages);
    } catch (InvalidClassException e) {
        final String msg = "Some class from list " + classesFromPackages + " is nor serializable. Cause: "
                + e.getMessage();

        log.error(msg);

        throw new RuntimeException(msg, e);
    } catch (CannotCompileException e) {
        final String msg = "Can't compile DataSerializer classes for some classes from list "
                + classesFromPackages + ". Cause: " + e.getMessage();

        log.error(msg);

        throw new RuntimeException(msg, e);
    }
}