Example usage for java.lang ClassNotFoundException printStackTrace

List of usage examples for java.lang ClassNotFoundException printStackTrace

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.springframework.rest.documentation.boot.SwaggerDocumentationEndpoint.java

private void addModelForType(String type, Map<String, ClassDescriptor> responseClasses,
        Documentation documentation) {/* w w w.j  a  v a 2s .c o  m*/
    String name = getSwaggerDataType(type);
    if (documentation.getModels() == null || !documentation.getModels().containsKey(name)) {
        DocumentationSchema schema = new DocumentationSchema();

        ClassDescriptor classDescriptor = responseClasses.get(type);
        if (classDescriptor != null) {
            schema.setDescription(classDescriptor.getName());
        }

        try {
            Class<?> clazz = Class.forName(type);

            if (clazz.isEnum()) {
                Object[] enumConstants = clazz.getEnumConstants();
                List<String> values = new ArrayList<String>();
                for (Object enumConstant : enumConstants) {
                    values.add(enumConstant.toString());
                }
                schema.setAllowableValues(new DocumentationAllowableListValues(values));
            } else {
                BasicClassIntrospector introspector = new BasicClassIntrospector();

                Map<String, DocumentationSchema> properties = new HashMap<String, DocumentationSchema>();

                BasicBeanDescription descriptor = introspector.forSerialization(
                        this.objectMapper.getSerializationConfig(),
                        TypeFactory.defaultInstance().constructType(clazz),
                        this.objectMapper.getSerializationConfig());

                for (BeanPropertyDefinition property : descriptor.findProperties()) {
                    String propertyName = property.getName();
                    DocumentationSchema propertySchema = new DocumentationSchema();
                    MethodDescriptor methodDescriptor = classDescriptor
                            .getMethodDescriptor((Method) property.getAccessor().getAnnotated());
                    if (methodDescriptor != null) {
                        Class<?> propertyClass = Class.forName(methodDescriptor.getReturnType());

                        propertySchema.setDescription(methodDescriptor.getSummary());

                        if (propertyClass.isEnum()) {
                            Object[] enumConstants = propertyClass.getEnumConstants();
                            List<String> values = new ArrayList<String>();
                            for (Object enumConstant : enumConstants) {
                                values.add(enumConstant.toString());
                            }
                            propertySchema.setType("string");
                            propertySchema.setAllowableValues(new DocumentationAllowableListValues(values));
                        } else {
                            propertySchema.setType(getSwaggerDataType(methodDescriptor.getReturnType()));
                            addModelForType(methodDescriptor.getReturnType(), responseClasses, documentation);
                        }
                    }

                    properties.put(propertyName, propertySchema);
                }

                schema.setProperties(properties);
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        documentation.addModel(name, schema);
    }
}

From source file:com.jroossien.boxx.nms.NMS.java

public <T> Object loadFromNMS(Class<T> dep) {
    if (!dep.isAnnotationPresent(NMSDependant.class))
        return null;
    NMSDependant nmsDependant = dep.getAnnotation(NMSDependant.class);
    Class<?> impl = null;/* ww w. j  a v a2 s  .c o m*/
    try {
        impl = Class.forName(nmsDependant.implementationPath() + "." + dep.getSimpleName() + "_" + version);
        return impl.newInstance();
    } catch (ClassNotFoundException e) {
        Boxx.get().error("The current version is not supported: " + version + ".\n" + e.getMessage());
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }
    return impl;
}

From source file:de.tudarmstadt.ukp.dkpro.lexsemresource.graph.PersistentAdjacencyMatrix.java

@SuppressWarnings("unchecked")
public void loadIndices() {

    logger.info("Loading the indices...");

    FileInputStream finEntIndex = null;
    ObjectInputStream inEntIndex = null;

    FileInputStream finIndexEnt = null;
    ObjectInputStream inIndexEnt = null;

    try {//from ww  w . j a  v  a 2s.c om
        finEntIndex = new FileInputStream("EntityIndexSer" + "_" + resourceName);
        inEntIndex = new ObjectInputStream(finEntIndex);
        entityIndex = (Map<Entity, Integer>) inEntIndex.readObject();
        inEntIndex.close();

        finIndexEnt = new FileInputStream("IndexToEntitySer" + "_" + resourceName);
        inIndexEnt = new ObjectInputStream(finIndexEnt);
        indexToEntity = (Map<Integer, Entity>) inIndexEnt.readObject();
        inIndexEnt.close();
    } catch (IOException ex) {
        ex.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    logger.info("Indices loaded.");

}

From source file:org.seamless_ip.services.dao.IndicatorValueDaoImpl.java

@SuppressWarnings("unchecked")
public Collection<IIndicatorValueTO> findAllByClassName(Long experimentId, String dbClassName) {
    ArrayList<IIndicatorValueTO> result = new ArrayList<IIndicatorValueTO>();

    try {//from  ww w.j ava 2s  .c  om
        Class<?> dbClass = Class.forName(dbClassName);
        Query q = query("from " + dbClass.getSimpleName() + " as i where i.Experiment.id = :id")
                .setParameter("id", experimentId);

        List<IIndicatorValue> dbItems = q.list();
        if (dbItems != null)
            for (IIndicatorValue dbItem : dbItems)
                result.add(createTO(dbItem));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

    return result;
}

From source file:org.seamless_ip.services.dao.IndicatorValueDaoImpl.java

@SuppressWarnings("unchecked")
public Collection<IIndicatorValueTO> findAll(Long experimentId) {
    ArrayList<IIndicatorValueTO> result = new ArrayList<IIndicatorValueTO>();

    Query q = query("from Experiment as e where e.id = :id").setParameter("id", experimentId);
    Experiment experiment = (Experiment) q.uniqueResult();
    if (experiment != null) {
        try {/*from   w w w.ja  va 2  s.co m*/
            Set<IIndicatorValue> dbItems = experiment.getIndicatorValues();
            if (dbItems != null)
                for (IIndicatorValue dbItem : dbItems)
                    result.add(createTO(dbItem));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    return result;
}

From source file:org.geosdi.wps.utility.GeoServerUtils.java

public Connection connectToDatabaseOrDie() {
    Connection conn = null;//from www .j  a  va  2  s.  c om
    try {
        Class.forName("org.postgresql.Driver");
        String url = "jdbc:postgresql://" + this.properties.getProperty("db.host") + "/"
                + this.properties.getProperty("db.name");
        conn = DriverManager.getConnection(url, this.properties.getProperty("db.user"),
                this.properties.getProperty("db.passwd"));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        System.exit(1);
    } catch (SQLException e) {
        e.printStackTrace();
        System.exit(2);
    }
    return conn;
}

From source file:de.julielab.jcore.reader.xmlmapper.typeBuilder.StandardTypeBuilder.java

/**
 * Builds an actual UIMA type from a ConcreteType object which holds all
 * values for the UIMA type./*from w w w . j  a  v a 2  s . c o m*/
 * 
 * @param concreteType
 *            The wrapper object for the type template to create a real UIMA
 *            type from.
 * @param jcas
 *            The JCas to which the created UIMA type should be added.
 * @return The built type. Returns <code>null</code> if
 *         <code>concreteType</code> does not define any features.
 * @throws CollectionException
 */
private Annotation buildSingleInstance(ConcreteType concreteType, JCas jcas) throws CollectionException {
    if (concreteType.getFullClassName() == null) {
        // this will happen at special cases like the documentText
        concreteType.getTypeTemplate().getParser().getTypeBuilder().buildType(concreteType, jcas);
        return null;
    }
    Class<?> typeClass = null;
    Annotation type = null;
    try {
        typeClass = Class.forName(concreteType.getFullClassName());
    } catch (ClassNotFoundException e) {
        // FIXME auto generatet catch block
        e.printStackTrace();
    }
    // Has this type any features at all?
    if (concreteType.getConcreteFeatures() != null) {
        // Create the UIMA type corresponding to the type description in
        // concreteType.
        type = (Annotation) constructor().withParameterTypes(JCas.class).in(typeClass).newInstance(jcas);

        // For each feature this type has, set the corret feature value.
        for (ConcreteFeature concreteFeature : concreteType.getConcreteFeatures()) {
            if ((concreteFeature.getValue() == null || concreteFeature.getValue().equals(""))
                    && !concreteFeature.isType()) {
                continue;
            }
            Class<?> featureClass;
            try {
                // Get the setter for the feature value, e.g.
                // 'setSpecificType'.
                // The setter convention say that the method's name is
                // prefixed by 'set'. Then,
                // the name of the feature is appended with the first
                // character in upper case.
                String methodName = "set" + concreteFeature.getTsName().substring(0, 1).toUpperCase()
                        + concreteFeature.getTsName().substring(1);

                // Now set the actual value for the feature. We have to
                // determine the data type
                // of the feature's value. The primitive types are found in
                // 'standardJavaTypesMap'
                // (see above). The String is a special case. If the value
                // is neither a Java
                // primitive nor a String, we expect it to be an UIMA type
                // itself.
                if (standardJavaTypesMap.get(concreteFeature.getFullClassName()) != null) {
                    featureClass = standardJavaTypesMap.get(concreteFeature.getFullClassName());
                    method(methodName).withParameterTypes(featureClass).in(type)
                            .invoke(parseValueStringToValueType(concreteFeature.getValue(),
                                    concreteFeature.getFullClassName()));
                } else if (concreteFeature.getFullClassName().equals("String")
                        || concreteFeature.getFullClassName().equals("java.lang.String")) {
                    featureClass = Class.forName(concreteFeature.getFullClassName());
                    method(methodName).withParameterTypes(featureClass).in(type)
                            .invoke(concreteFeature.getValue());
                } else {
                    String featureClassName = concreteFeature.getFullClassName();
                    if (StringUtils.isBlank(featureClassName))
                        throw new IllegalStateException("For the feature \"" + concreteFeature.getTsName()
                                + "\" of the type \"" + concreteType.getFullClassName()
                                + "\" the feature value class (e.g. String, Integer, another type...) was not defined in the mapping file.");
                    featureClass = Class.forName(featureClassName);
                    TOP top = concreteFeature.getTypeTemplate().getParser().getTypeBuilder()
                            .buildType(concreteFeature, jcas);
                    method(methodName).withParameterTypes(featureClass).in(type).invoke(top);
                }
            } catch (Throwable e) {
                LOGGER.error("Wrong Feature Type: " + concreteFeature.getFullClassName(), e);
                throw new CollectionException(UIMAException.STANDARD_MESSAGE_CATALOG, null);
            }
        }
        type.setBegin(concreteType.getBegin());
        type.setEnd(concreteType.getEnd());
        type.addToIndexes();
    } else
        LOGGER.warn(
                "Type " + concreteType.getFullClassName() + " does not define any features and is omitted.");
    return type;
}

From source file:org.apache.asterix.replication.storage.ReplicaResourcesManager.java

@SuppressWarnings({ "unchecked" })
public synchronized Map<Long, Long> getReplicaIndexLSNMap(String indexPath) throws IOException {
    try (FileInputStream fis = new FileInputStream(indexPath + File.separator + REPLICA_INDEX_LSN_MAP_NAME);
            ObjectInputStream oisFromFis = new ObjectInputStream(fis)) {
        Map<Long, Long> lsnMap = null;
        try {/*from w  ww  .j a va  2 s .c  o  m*/
            lsnMap = (Map<Long, Long>) oisFromFis.readObject();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return lsnMap;
    }
}

From source file:org.apache.hama.mapreduce.MapRedBSP.java

@SuppressWarnings({ "rawtypes" })
public void setup(BSPPeer<WritableComparable<?>, Writable, WritableComparable<?>, Writable, KVPair> peer) {

    this.conf = peer.getConfiguration();
    this.peer = peer;
    this.path = new Path("/tmp/bsp/mapreduce/spills/" + peer.getTaskId() + "/spill_" + "_" + this
            + peer.getPeerIndex() + ".seq");
    doCleanUp(peer);//  w ww . j a v a2s. c o  m
    String partitionerClassName = conf.get(PARTITIONER_CLASS_NAME);
    try {
        partitioner = ReflectionUtils.newInstance(partitionerClassName);

    } catch (ClassNotFoundException e) {
        LOG.error("Could not initialize partitioner class", e);
        e.printStackTrace();
        throw new RuntimeException(e);
    }

    String mapperClassName = conf.get(MAPPER_CLASS_NAME, Mapper.class.getCanonicalName());

    String reducerClassName = conf.get(REDUCER_CLASS_NAME, Reducer.class.getCanonicalName());

    String mapInKeyClassName = conf.get(MAP_IN_KEY_CLASS_NAME);
    String mapInValClassName = conf.get(MAP_IN_VAL_CLASS_NAME);
    String mapOutKeyClassName = conf.get(MAP_OUT_KEY_CLASS_NAME);
    String mapOutValClassName = conf.get(MAP_OUT_VAL_CLASS_NAME);

    try {
        mapInKey = ReflectionUtils.newInstance(mapInKeyClassName);
        mapInVal = ReflectionUtils.newInstance(mapInValClassName);
        mapOutKey = ReflectionUtils.newInstance(mapOutKeyClassName);
        mapOutVal = ReflectionUtils.newInstance(mapOutValClassName);

    } catch (ClassNotFoundException e1) {
        LOG.error(e1);
        throw new RuntimeException(e1);
    }

    try {
        mapper = ReflectionUtils.newInstance(mapperClassName);
        reducer = ReflectionUtils.newInstance(reducerClassName);

    } catch (ClassNotFoundException e) {
        LOG.error("Could not initialize mapper/reducer Exiting...", e);
    }
    conf.set(QUEUE_TYPE_CLASS, MemoryQueue.class.getCanonicalName());
}

From source file:com.fmguler.ven.support.LiquibaseConverter.java

/**
 * Convert the added domain packages to liquibase changeset xml
 * @return changeset xml/*from w w w  .j a va2s  . c  o m*/
 */
public String convert() {
    StringBuffer liquibaseXml = new StringBuffer();
    Iterator it = domainPackages.iterator();
    while (it.hasNext()) {
        String domainPackage = (String) it.next();
        try {
            Class[] domainClasses = getClasses(domainPackage);
            for (int i = 0; i < domainClasses.length; i++) {
                Class domainClass = domainClasses[i];
                convertClass(liquibaseXml, domainClass);
            }
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    return liquibaseXml.toString();
}