Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.trackplus.ddl.DataReader.java

public static Connection getConnection(DatabaseInfo databaseInfo) throws DDLException {
    try {//from   w  ww  .  j a  v a2s.c o  m
        Class.forName(databaseInfo.getDriver());
    } catch (ClassNotFoundException e) {
        throw new DDLException(e.getMessage(), e);
    }
    Connection connection = null;
    try {
        connection = DriverManager.getConnection(databaseInfo.getUrl(), databaseInfo.getUser(),
                databaseInfo.getPassword());
    } catch (SQLException e) {
        throw new DDLException(e.getMessage(), e);
    }
    return connection;
}

From source file:com.trackplus.ddl.DataWriter.java

private static Connection getConnection(DatabaseInfo databaseInfo) throws DDLException {
    try {/*from   w ww  . j a  v  a2 s. c  o m*/
        Class.forName(databaseInfo.getDriver());
    } catch (ClassNotFoundException e) {
        throw new DDLException(e.getMessage(), e);
    }

    Connection connection;
    try {
        connection = DriverManager.getConnection(databaseInfo.getUrl(), databaseInfo.getUser(),
                databaseInfo.getPassword());
    } catch (SQLException e) {
        throw new DDLException(e.getMessage(), e);
    }
    return connection;
}

From source file:hu.ppke.itk.nlpg.purepos.cli.PurePos.java

public static ITagger createTagger(String modelPath, String analyzer, boolean noStemming, int maxGuessed,
        double beamLogTheta, boolean useBeamSearch, Configuration conf) throws Exception {
    IMorphologicalAnalyzer ma;//from   w  ww.  j a  v  a  2 s . co  m
    if (analyzer.equals(INTEGRATED_MA)) {
        // TODO: set lex files through environment vars
        try {
            // System.err
            // .println("Trying to use Humor morphological analyzer.");
            ma = loadHumor();
        } catch (ClassNotFoundException e) {
            System.err.println("Humor java files are not found. Not using any morphological analyzer.");
            ma = new NullAnalyzer();
        } catch (Exception e) {
            System.err.println(e.getMessage());
            System.err.println("Not using any morphological analyzer.");
            ma = new NullAnalyzer();
        }
    } else if (analyzer.equals(NONE_MA)) {
        ma = new NullAnalyzer();

        // } else if (analyzer.equals(PRE_MA)) {
        // ma = taggedSeqReader.getMorphologicalAnalyzer();
    } else {
        System.err.println("Using morphological table at: " + analyzer + ".");
        ma = new MorphologicalTable(new File(analyzer));
    }

    System.err.println("Reading model... ");
    RawModel rawmodel = SSerializer.readModel(new File(modelPath));
    System.err.println("Compiling model... ");
    CompiledModel<String, Integer> model = rawmodel.compile(conf);
    ITagger t;

    // double beamLogTheta = Math.log(1000);
    // double beamLogTheta = Math.log(10000000);
    // double beamLogTheta = Double.POSITIVE_INFINITY;
    double suffixLogTheta = Math.log(10);
    if (noStemming) {
        t = new POSTagger(model, ma, beamLogTheta, suffixLogTheta, maxGuessed, useBeamSearch);
    } else {
        t = new MorphTagger(model, ma, beamLogTheta, suffixLogTheta, maxGuessed, useBeamSearch);
    }
    return t;
}

From source file:org.apache.hadoop.hive.ql.metadata.HiveUtils.java

public static HiveIndexHandler getIndexHandler(HiveConf conf, String indexHandlerClass) throws HiveException {

    if (indexHandlerClass == null) {
        return null;
    }/*from ww  w. j  a va 2  s.c o  m*/
    try {
        Class<? extends HiveIndexHandler> handlerClass = (Class<? extends HiveIndexHandler>) Class
                .forName(indexHandlerClass, true, Utilities.getSessionSpecifiedClassLoader());
        HiveIndexHandler indexHandler = ReflectionUtils.newInstance(handlerClass, conf);
        return indexHandler;
    } catch (ClassNotFoundException e) {
        throw new HiveException("Error in loading index handler." + e.getMessage(), e);
    }
}

From source file:org.cosmo.common.template.Parser.java

public static Page parsePageString(String pageString, File src, boolean reParse) throws Exception {
    ArrayList<byte[]> segmentContainer = new ArrayList();
    ArrayList<CharSequence> bindingContainer = new ArrayList();
    StringBuilder segment = new StringBuilder(256);
    StringBuilder binding = null;

    char[] pageChars = pageString.toCharArray();

    // extract args string
    int end = pageString.indexOf(PageEndToken, PageBeginTokenSize);
    String argString = pageString.substring(PageBeginTokenSize + 1, end);
    StringTokens args = StringTokens.on(argString);
    Options options = new Options(args);

    // extract get pageName and bindingSrc className , by default pageName IS The bindingSrc class name, unless options bindingSrc:xxx is specified
    String pageName = options._pageName;
    Class clazz = null;/*  w w  w  . j a  v  a2s  .  com*/
    if (pageName.startsWith("!")) {
        // virtual page
        pageName = pageName.substring(1, pageName.length()); // strip ! so that it can be referenced without "!"
        clazz = options._bindingSrc == null ? BindingSrc.class : Class.forName(options._bindingSrc);
    } else {
        try {
            clazz = options._bindingSrc == null ? Class.forName(pageName) : Class.forName(options._bindingSrc);
        } catch (ClassNotFoundException e) {
            ClassNotFoundException cnfe = new ClassNotFoundException(e.getMessage() + " from page" + src, e);
            cnfe.fillInStackTrace();
            throw cnfe;

        }
    }

    // parse segments and bindings
    for (int i = end + PageEndTokenSize; i < pageChars.length; i++) {

        // handles bindings
        if (pageChars[i] == BindingChar) {
            if (binding == null) {
                binding = new StringBuilder();
                continue;
            } else {
                segmentContainer.add(options._jsonEncode ? Util.jsonQuoteBytes(segment) : Util.bytes(segment));
                segment = new StringBuilder(256);
                //indents.add(currentIndent);

                segmentContainer
                        .add(options._jsonEncode ? Page.BindingMarkerBytesQuoted : Page.BindingMarkerBytes);
                bindingContainer.add(binding.toString());
                binding = null;
                continue;
            }
        }
        if (binding != null) {
            binding.append(pageChars[i]);
        }

        // handles trim and escapeQuote
        if (binding == null) {

            if (pageChars[i] == '\n' || pageChars[i] == '\r') {
                if (!options._trim) {
                    segment.append(pageChars[i]);
                }
            } else {
                if (pageChars[i] == '\t') {
                    if (!options._trim) {
                        segment.append(pageChars[i]);
                    }
                } else {
                    if (options._escapeQuote && pageChars[i] == '\"') {
                        segment.append("\\");
                    }
                    segment.append(pageChars[i]);
                }
            }
        }
    }

    // convert segments to raw bytes
    Page page = new Page(pageName, clazz, src, options, reParse);
    segmentContainer.add(options._jsonEncode ? Util.jsonQuoteBytes(segment) : Util.bytes(segment));
    page._segmentArray = (byte[][]) segmentContainer.toArray(new byte[][] {});

    // convert binding string to parsed bindings
    BindingContainer bindingsContainer = Parser.parseBindings(page, bindingContainer, 0,
            page._segmentArray.length, 0);
    page._bindingArray = (Binding[]) bindingsContainer.toArray(new Binding[] {});

    for (Binding aBinding : page._bindingArray) {
        if (aBinding instanceof Binding.ValueBinding) {
            page._bindingMap.put(aBinding.name(), aBinding);
        }
    }
    return page;
}

From source file:org.apache.hadoop.hive.ql.metadata.HiveUtils.java

public static HiveStorageHandler getStorageHandler(Configuration conf, String className) throws HiveException {

    if (className == null) {
        return null;
    }/* w w w .  j  a  va 2s . co  m*/
    try {
        Class<? extends HiveStorageHandler> handlerClass = (Class<? extends HiveStorageHandler>) Class
                .forName(className, true, Utilities.getSessionSpecifiedClassLoader());
        HiveStorageHandler storageHandler = ReflectionUtils.newInstance(handlerClass, conf);
        return storageHandler;
    } catch (ClassNotFoundException e) {
        throw new HiveException("Error in loading storage handler." + e.getMessage(), e);
    }
}

From source file:org.apache.openaz.xacml.util.FactoryFinder.java

public static <T> T newInstance(String className, Class<T> classExtends, ClassLoader cl, boolean doFallback,
        Properties xacmlProperties) throws FactoryException {
    try {/*from   w ww  .  j a  v  a  2 s.  c o m*/
        Class<?> providerClass = getProviderClass(className, cl, doFallback);
        if (classExtends.isAssignableFrom(providerClass)) {
            Object instance = null;
            if (xacmlProperties == null) {
                instance = providerClass.newInstance();
            } else {
                //
                // Search for a constructor that takes Properties
                //
                for (Constructor<?> constructor : providerClass.getDeclaredConstructors()) {
                    Class<?>[] params = constructor.getParameterTypes();
                    if (params.length == 1 && params[0].isAssignableFrom(Properties.class)) {
                        instance = constructor.newInstance(xacmlProperties);
                    }
                }
                if (instance == null) {
                    logger.warn("No constructor that takes a Properties object.");
                    instance = providerClass.newInstance();
                }
            }
            if (logger.isTraceEnabled()) {
                logger.trace("Created new instance of " + providerClass + " using ClassLoader: " + cl);
            }
            return classExtends.cast(instance);
        } else {
            throw new ClassNotFoundException(
                    "Provider " + className + " does not extend " + classExtends.getCanonicalName());
        }
    } catch (ClassNotFoundException ex) {
        throw new FactoryException("Provider " + className + " not found", ex);
    } catch (Exception ex) {
        throw new FactoryException("Provider " + className + " could not be instantiated: " + ex.getMessage(),
                ex);
    }
}

From source file:org.apache.fop.render.afp.AFPFontConfig.java

private static Typeface getTypeFace(String base14Name) throws ClassNotFoundException {
    try {/*from www  . j av a 2s .c om*/
        Class<? extends Typeface> clazz = Class.forName("org.apache.fop.fonts.base14." + base14Name)
                .asSubclass(Typeface.class);
        return clazz.newInstance();
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (ClassNotFoundException cnfe) {
        LOG.error(cnfe.getMessage());
    } catch (InstantiationException ie) {
        LOG.error(ie.getMessage());
    }
    throw new ClassNotFoundException("Couldn't load file for AFP font with base14 name: " + base14Name);
}

From source file:com.ocs.dynamo.utils.ClassUtils.java

/**
 * forClass which doesn't throw an exception and can handle empty class names
 * /*  w  w  w . ja  v a  2  s . co m*/
 * @param clazz
 *            The fully qualified class name
 * @return the specified class and null when class is not found
 */
public static Class<?> forClass(final String clazz) {
    Class<?> result = null;
    try {
        if (StringUtils.isNotEmpty(clazz)) {
            result = Class.forName(clazz);
        }
    } catch (final ClassNotFoundException e) {
        LOG.error(e.getMessage(), e);
    }
    return result;
}

From source file:com.eucalyptus.upgrade.TestHarness.java

@SuppressWarnings("unchecked")
private static Multimap<Class, Method> getTestMethods() throws Exception {
    final Multimap<Class, Method> testMethods = ArrayListMultimap.create();
    List<Class> classList = Lists.newArrayList();
    for (File f : new File(System.getProperty("euca.home") + "/usr/share/eucalyptus").listFiles()) {
        if (f.getName().startsWith("eucalyptus") && f.getName().endsWith(".jar")
                && !f.getName().matches(".*-ext-.*")) {
            try {
                JarFile jar = new JarFile(f);
                Enumeration<JarEntry> jarList = jar.entries();
                for (JarEntry j : Collections.list(jar.entries())) {
                    if (j.getName().matches(".*\\.class.{0,1}")) {
                        String classGuess = j.getName().replaceAll("/", ".").replaceAll("\\.class.{0,1}", "");
                        try {
                            Class candidate = ClassLoader.getSystemClassLoader().loadClass(classGuess);
                            for (final Method m : candidate.getDeclaredMethods()) {
                                if (Iterables.any(testAnnotations,
                                        new Predicate<Class<? extends Annotation>>() {
                                            public boolean apply(Class<? extends Annotation> arg0) {
                                                return m.getAnnotation(arg0) != null;
                                            }
                                        })) {
                                    System.out.println("Added test class: " + candidate.getCanonicalName());
                                    testMethods.put(candidate, m);
                                }//from  w w w.j  av a 2 s . c o m
                            }
                        } catch (ClassNotFoundException e) {
                        }
                    }
                }
                jar.close();
            } catch (Exception e) {
                System.out.println(e.getMessage());
                continue;
            }
        }
    }
    return testMethods;
}