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:ar.com.fdvs.dj.core.layout.AbstractLayoutManager.java

/**
 * Creates and registers a variable to be used by the Chart
 * @param chart Chart that needs a variable to be generated
 * @return the generated variables//  ww w.j  a  v  a  2s  .c  o m
 */
protected List registerChartVariable(DJChart chart) {
    //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
    JRDesignGroup group = getJRGroupFromDJGroup(chart.getColumnsGroup());
    List vars = new ArrayList();

    int serieNum = 0;
    for (Iterator iterator = chart.getColumns().iterator(); iterator.hasNext();) {
        AbstractColumn col = (AbstractColumn) iterator.next();

        Class clazz = null;
        try {
            clazz = Class.forName(((PropertyColumn) col).getColumnProperty().getValueClassName());
        } catch (ClassNotFoundException e) {
            throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
        }

        JRDesignExpression expression = new JRDesignExpression();
        //FIXME Only PropertyColumn allowed?
        expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
        expression.setValueClass(clazz);

        JRDesignVariable var = new JRDesignVariable();
        var.setValueClass(clazz);
        var.setExpression(expression);
        var.setCalculation(chart.getOperation());
        var.setResetGroup(group);
        var.setResetType(JRBaseVariable.RESET_TYPE_GROUP);

        //use the index as part of the name just because I may want 2
        //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
        int chartIndex = getReport().getCharts().indexOf(chart);
        var.setName("CHART_[" + chartIndex + "_s" + serieNum + "+]_" + group.getName() + "_" + col.getTitle()
                + "_" + chart.getOperation());

        try {
            getDesign().addVariable(var);
            vars.add(var);
        } catch (JRException e) {
            throw new LayoutException(e.getMessage(), e);
        }
        serieNum++;
    }
    return vars;
}

From source file:ar.com.fdvs.dj.core.layout.AbstractLayoutManager.java

/**
 * Creates and registers a variable to be used by the Chart
 * @param chart Chart that needs a variable to be generated
 * @return the generated variables/*  w  w  w.java 2  s. c o  m*/
 */
protected Map registerChartVariable(ar.com.fdvs.dj.domain.chart.DJChart chart) {
    //FIXME aca hay que iterar por cada columna. Cambiar DJChart para que tome muchas
    JRDesignGroup group = getChartColumnsGroup(chart);
    Map vars = new HashMap();

    int serieNum = 0;
    for (Iterator iterator = chart.getDataset().getColumns().iterator(); iterator.hasNext();) {
        AbstractColumn col = (AbstractColumn) iterator.next();

        Class clazz = null;
        try {
            clazz = Class.forName(col.getValueClassNameForExpression());
        } catch (ClassNotFoundException e) {
            throw new DJException("Exeption creating chart variable: " + e.getMessage(), e);
        }

        JRDesignExpression expression = new JRDesignExpression();
        //FIXME Only PropertyColumn allowed?
        expression.setText("$F{" + ((PropertyColumn) col).getColumnProperty().getProperty() + "}");
        expression.setValueClass(clazz);

        JRDesignVariable var = new JRDesignVariable();
        var.setValueClass(clazz);
        var.setExpression(expression);
        var.setCalculation(chart.getOperation());
        var.setResetGroup(group);
        var.setResetType(JRBaseVariable.RESET_TYPE_GROUP);

        //use the index as part of the name just because I may want 2
        //different types of chart from the very same column (with the same operation also) making the variables name to be duplicated
        int chartIndex = getReport().getNewCharts().indexOf(chart);
        var.setName("CHART_[" + chartIndex + "_s" + serieNum + "+]_" + group.getName() + "_" + col.getTitle()
                + "_" + chart.getOperation());

        try {
            getDesign().addVariable(var);
            vars.put(col, var);
        } catch (JRException e) {
            throw new LayoutException(e.getMessage(), e);
        }
        serieNum++;
    }
    return vars;
}

From source file:com.osbitools.ws.shared.prj.web.AbstractWsPrjInit.java

@Override
public void contextInitialized(ServletContextEvent evt) {
    super.contextInitialized(evt);
    ServletContext ctx = evt.getServletContext();

    // First - Load Custom Error List 
    try {/* w  w w. j ava  2s .  c o  m*/
        Class.forName("com.osbitools.ws.shared.prj.CustErrorList");
    } catch (ClassNotFoundException e) {
        // Ignore Error 
    }

    // Initialize Entity Utils
    IEntityUtils eut = getEntityUtils();
    ctx.setAttribute("entity_utils", eut);

    // Initiate LangSetFileUtils
    ctx.setAttribute("ll_set_utils", new LangSetUtils());

    // Check if git repository exists and create one
    // Using ds subdirectory as git root repository 
    File drepo = new File(
            getConfigDir(ctx) + File.separator + eut.getPrjRootDirName() + File.separator + ".git");
    Git git;
    try {

        if (!drepo.exists()) {
            if (!drepo.mkdirs())
                throw new RuntimeErrorException(
                        new Error("Unable create directory '" + drepo.getAbsolutePath() + "'"));

            try {
                git = createGitRepo(drepo);
            } catch (Exception e) {
                throw new RuntimeErrorException(new Error(
                        "Unable create new repo on path: " + drepo.getAbsolutePath() + ". " + e.getMessage()));
            }

            getLogger(ctx).info("Created new git repository '" + drepo.getAbsolutePath() + "'");
        } else if (!drepo.isDirectory()) {
            throw new RuntimeErrorException(
                    new Error(drepo.getAbsolutePath() + " is regular file and not a directory"));
        } else {
            git = Git.open(drepo);
            getLogger(ctx).debug("Open existing repository " + drepo.getAbsolutePath());
        }
    } catch (IOException e) {
        // Something unexpected and needs to be analyzed
        e.printStackTrace();

        throw new RuntimeErrorException(new Error(e));
    }

    // Save git handler
    ctx.setAttribute("git", git);

    // Check if remote destination set/changed
    StoredConfig config = git.getRepository().getConfig();
    String rname = (String) ctx.getAttribute(PrjMgrConstants.PREMOTE_GIT_NAME);
    String rurl = (String) ctx.getAttribute("git_remote_url");

    if (!Utils.isEmpty(rname) && !Utils.isEmpty(rurl)) {
        String url = config.getString("remote", rname, "url");
        if (!rurl.equals(url)) {
            config.setString("remote", rname, "url", rurl);
            try {
                config.save();
            } catch (IOException e) {
                getLogger(ctx).error("Error saving git remote url. " + e.getMessage());
            }
        }
    }

    // Temp directory for files upload
    String tname = System.getProperty("java.io.tmpdir");
    getLogger(ctx).info("Using temporarily directory '" + tname + "' for file uploads");
    File tdir = new File(tname);

    if (!tdir.exists())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not found"));
    if (!tdir.isDirectory())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not a directory"));

    DiskFileItemFactory dfi = new DiskFileItemFactory();
    dfi.setSizeThreshold(
            ((Integer) ctx.getAttribute(PrjMgrConstants.SMAX_FILE_UPLOAD_SIZE_NAME)) * 1024 * 1024);
    dfi.setRepository(tdir);
    evt.getServletContext().setAttribute("dfi", dfi);

    // Save entity utils in context
    evt.getServletContext().setAttribute("entity_utils", getEntityUtils());
}

From source file:org.adminmap.core.rpc.Response.java

@SuppressWarnings("unchecked")
public <T> T getResult(final Class<T> classProperty) {

    if (result == null)
        throw new RuntimeException("The Response object did not have a 'result' field encoded");

    // Make sure we know how to deserialize the provided type from a JSON object
    if (!JSON.isSupportedType(classProperty))
        throw new RuntimeException("Unsupported type passed to getResult(): " + classProperty.getName());

    // Determine the class property that is encoded in our result object
    final String className = JSONObject.getNames(result)[0]; // The key is the class name
    Class<?> encodedClassProperty = null;
    try {//w ww.j  a  v a  2s.  com
        encodedClassProperty = Class.forName(className);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("Cannot find class encoded in JSON result string: " + className);
    }

    // Make sure it is the same class property that was provided to this function
    if (!JSON.isPrimitiveType(classProperty) && classProperty != encodedClassProperty)
        throw new IllegalArgumentException(
                "The class specified does not match the class encoded in the JSON result string: "
                        + classProperty.getSimpleName() + " vs " + encodedClassProperty.getSimpleName());

    // Determine the super class
    final Class<?> superClassProperty = classProperty.getSuperclass();

    // Create a new instance of the result object according to the class property that we've been provided
    T resultObject = null;

    if (superClassProperty != null && superClassProperty.equals(JSONizer.class)) {

        try {
            resultObject = (T) classProperty.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            System.err.println(e.getMessage());
            throw new RuntimeException("Could not instantiate the result object");
        }

        ((JSONizer) resultObject).fromJSONObject(result.getJSONObject(className));
    } else if (classProperty == boolean.class)
        resultObject = (T) JSON.getBoolean(result);
    else if (classProperty == boolean[].class)
        resultObject = (T) JSON.getBooleanArray(result);
    else if (classProperty == Boolean.class)
        resultObject = (T) JSON.getBoolean(result);
    else if (classProperty == Boolean[].class)
        resultObject = (T) JSON.getBooleanArray(result);
    else if (classProperty == int.class)
        resultObject = (T) JSON.getInteger(result);
    else if (classProperty == int[].class)
        resultObject = (T) JSON.getIntegerArray(result);
    else if (classProperty == Integer.class)
        resultObject = (T) JSON.getInteger(result);
    else if (classProperty == Integer[].class)
        resultObject = (T) JSON.getIntegerArray(result);
    else if (classProperty == long.class)
        resultObject = (T) JSON.getLong(result);
    else if (classProperty == long[].class)
        resultObject = (T) JSON.getLongArray(result);
    else if (classProperty == Long.class)
        resultObject = (T) JSON.getLong(result);
    else if (classProperty == Long[].class)
        resultObject = (T) JSON.getLongArray(result);
    else if (classProperty == double.class)
        resultObject = (T) JSON.getDouble(result);
    else if (classProperty == double[].class)
        resultObject = (T) JSON.getDoubleArray(result);
    else if (classProperty == Double.class)
        resultObject = (T) JSON.getDouble(result);
    else if (classProperty == Double[].class)
        resultObject = (T) JSON.getDoubleArray(result);
    else if (classProperty == String.class)
        resultObject = (T) JSON.getString(result);
    else if (classProperty == String[].class)
        resultObject = (T) JSON.getStringArray(result);
    else
        throw new RuntimeException("Could not cast the result to unsupported type: " + className);

    return resultObject;

}

From source file:com.aliyun.odps.conf.Configuration.java

/**
 * ??<code>name</code>?<code>defaultValue</code> RuntimeException
 *
 * @param name//from   ww  w . ja v  a  2 s .c om
 *     ???
 * @param defaultValue
 *     
 * @return ?<code>name</code>?<code>defaultValue</code>
 */
public Class<?> getClass(String name, Class<?> defaultValue) {
    String valueString = get(name);
    if (valueString == null) {
        return defaultValue;
    }
    try {
        return getClassByName(valueString);
    } catch (ClassNotFoundException e) {
        throw new RuntimeException("ODPS-0730001: ClassNotFoundException - " + e.getMessage());
    }
}

From source file:com.draagon.meta.loader.xml.XMLFileMetaDataLoader.java

/**
 * Loads the specified group types/*from  www.  ja  v  a 2  s .c  o m*/
 */
protected synchronized void loadAllTypes(Element el) throws MetaException, SAXException {

    // Get all elements that have <type> elements
    for (Element e : getElementsWithType(el)) {

        String name = e.getNodeName();

        // Get the MetaDataTypes with the specified element name
        MetaDataTypes mdts = typesMap.get(name);

        // If it doesn't exist, then create it and check for the "class" attribute
        if (mdts == null) {

            // Get the base class for the given element
            String clazz = e.getAttribute("class");
            if (clazz == null || clazz.isEmpty()) {
                throw new MetaException("Element section [" + name + "] has no 'class' attribute specified");
            }

            try {
                Class<? extends MetaData> baseClass = (Class<? extends MetaData>) Class.forName(clazz);

                // Create a new MetaDataTypes and add to the mapping
                mdts = new MetaDataTypes(baseClass);
                typesMap.put(name, mdts);
            } catch (ClassNotFoundException ex) {
                throw new MetaException(
                        "Element section [" + name + "] has an invalid 'class' attribute: " + ex.getMessage(),
                        ex);
            }
        }

        // Load all the types for the specific element type
        loadTypes(e, mdts);
    }
}

From source file:com.draagon.meta.loader.xml.XMLFileMetaDataLoader.java

/**
 * Loads the specified group types//from w w  w  .  j av a2 s .c o  m
 */
protected void loadTypes(Element el, MetaDataTypes typesMap) throws MetaException, SAXException {

    String section = el.getNodeName();

    //Collection<Element> c = getElementsOfName(root, section);

    // Iterate through each section grouping (should just be 1)
    //for (Element el : c) {
    Collection<Element> typeCol = getElementsOfName(el, "type");

    // Iterate through each type
    for (Element typeEl : typeCol) {

        String name = typeEl.getAttribute(ATTR_NAME);
        String tclass = typeEl.getAttribute("class");

        if (name.length() == 0) {
            throw new MetaException("Type of section [" + section + "] has no 'name' attribute specified");
        }

        try {
            Class<MetaData> tcl = (Class<MetaData>) Class.forName(tclass);

            // Add the type class with the specified name
            typesMap.put(name, tcl);
        } catch (ClassNotFoundException e) {
            throw new MetaException("Type of section [" + section + "] with name [" + name
                    + "] has invalid class: " + e.getMessage());
            //log.warn( "Type of section [" + section + "] with name [" + name + "] has unknown class: " + e.getMessage() );
        }
    }
    //}
}

From source file:org.apache.lens.ml.LensMLImpl.java

/**
 * Inits the./*  www  .j  ava  2s .  com*/
 *
 * @param hiveConf the hive conf
 */
public synchronized void init(HiveConf hiveConf) {
    this.conf = hiveConf;

    // Get all the drivers
    String[] driverClasses = hiveConf.getStrings("lens.ml.drivers");

    if (driverClasses == null || driverClasses.length == 0) {
        throw new RuntimeException("No ML Drivers specified in conf");
    }

    LOG.info("Loading drivers " + Arrays.toString(driverClasses));
    drivers = new ArrayList<MLDriver>(driverClasses.length);

    for (String driverClass : driverClasses) {
        Class<?> cls;
        try {
            cls = Class.forName(driverClass);
        } catch (ClassNotFoundException e) {
            LOG.error("Driver class not found " + driverClass);
            continue;
        }

        if (!MLDriver.class.isAssignableFrom(cls)) {
            LOG.warn("Not a driver class " + driverClass);
            continue;
        }

        try {
            Class<? extends MLDriver> mlDriverClass = (Class<? extends MLDriver>) cls;
            MLDriver driver = mlDriverClass.newInstance();
            driver.init(toLensConf(conf));
            drivers.add(driver);
            LOG.info("Added driver " + driverClass);
        } catch (Exception e) {
            LOG.error("Failed to create driver " + driverClass + " reason: " + e.getMessage(), e);
        }
    }
    if (drivers.isEmpty()) {
        throw new RuntimeException("No ML drivers loaded");
    }

    LOG.info("Inited ML service");
}

From source file:org.apache.cayenne.map.ObjEntity.java

/**
 * Returns Java class of persistent objects described by this entity. For
 * generic entities with no class specified explicitly, default DataMap
 * superclass is used, and if it is not set - CayenneDataObject is used.
 * Casts any thrown exceptions into CayenneRuntimeException.
 * /* w w w .  j av a  2s .co m*/
 * @since 1.2
 * @deprecated since 4.0 this method based on statically defined class
 *             loading algorithm is not going to work in environments like
 *             OSGi. {@link AdhocObjectFactory} should be used as it can
 *             provide the environment-specific class loading policy. 
 */
@Deprecated
public Class<?> getJavaClass() {
    String name = getJavaClassName();

    try {
        return Util.getJavaClass(name);
    } catch (ClassNotFoundException e) {
        throw new CayenneRuntimeException("Failed to doLoad class " + name + ": " + e.getMessage(), e);
    }
}