Example usage for java.lang ClassNotFoundException ClassNotFoundException

List of usage examples for java.lang ClassNotFoundException ClassNotFoundException

Introduction

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

Prototype

public ClassNotFoundException() 

Source Link

Document

Constructs a ClassNotFoundException with no detail message.

Usage

From source file:org.demoiselle.internal.implementation.ConfigurationLoader.java

private ConfigurationValueExtractor getValueExtractor(Field field) {
    Collection<ConfigurationValueExtractor> candidates = new HashSet<ConfigurationValueExtractor>();
    ConfigurationBootstrap bootstrap = CDI.current().select(ConfigurationBootstrap.class).get();

    for (Class<? extends ConfigurationValueExtractor> extractorClass : bootstrap.getCache()) {
        ConfigurationValueExtractor extractor = CDI.current().select(extractorClass).get();

        if (extractor.isSupported(field)) {
            candidates.add(extractor);//from w w  w. ja  v  a 2 s.c  o m
        }
    }

    ConfigurationValueExtractor elected = StrategySelector.selectReference(ConfigurationValueExtractor.class,
            candidates);

    if (elected == null) {
        throw new ConfigurationException(getBundle().getString("configuration-extractor-not-found",
                field.toGenericString(), ConfigurationValueExtractor.class.getName()),
                new ClassNotFoundException());
    }

    return elected;
}

From source file:org.apache.hadoop.hbase.regionserver.CompoundConfiguration.java

@Override
public Class<?> getClassByName(String name) throws ClassNotFoundException {
    if (mutableConf != null) {
        Class<?> value = mutableConf.getClassByName(name);
        if (value != null) {
            return value;
        }/*from  w w w. ja  v a 2 s .  com*/
    }

    for (ImmutableConfigMap m : this.configs) {
        try {
            Class<?> value = m.getClassByName(name);
            if (value != null) {
                return value;
            }
        } catch (ClassNotFoundException e) {
            // don't propagate an exception until all configs fail
            continue;
        }
    }
    throw new ClassNotFoundException();
}

From source file:it.polimi.hegira.transformers.CassandraTransformer.java

/**
 * Depending on the value of the type the method:
 * 1) deserialize the value and assign it to the new cassandra column
 * 2) update the cassandra type to a CQL supported type
 * //from  w  w  w .  ja v  a2s .c  o m
 * @param cassandraColumn
 * @param columnValue the value of the columns in the metamodel
 * @param javaType 
 * @throws IOException
 * @throws ClassNotFoundException
 */
private void setValueAndSimpleType(CassandraColumn cassandraColumn, byte[] columnValue, String javaType)
        throws IOException, ClassNotFoundException {
    switch (javaType) {
    case "String":
        cassandraColumn.setColumnValue((String) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("varchar");
        return;
    case "Long":
        cassandraColumn.setColumnValue((Long) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("bigint");
        return;
    case "byte[]":
        cassandraColumn.setColumnValue(ByteBuffer.wrap(columnValue));
        cassandraColumn.setValueType("blob");
        return;
    case "Boolean":
        cassandraColumn.setColumnValue((Boolean) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("boolean");
        return;
    case "BigDecimal":
        cassandraColumn.setColumnValue((BigDecimal) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("decimal");
        return;
    case "Double":
        cassandraColumn.setColumnValue((double) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("double");
        return;
    case "Float":
        cassandraColumn.setColumnValue((float) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("float");
        return;
    case "InetAddress":
        cassandraColumn.setColumnValue((InetAddress) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("inet");
        return;
    case "Integer":
        cassandraColumn.setColumnValue((int) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("int");
        return;
    case "Date":
        cassandraColumn.setColumnValue((Date) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("timestamp");
        return;
    case "UUID":
        cassandraColumn.setColumnValue((UUID) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("uuid");
        return;
    case "BigInteger":
        cassandraColumn.setColumnValue((BigInteger) DefaultSerializer.deserialize(columnValue));
        cassandraColumn.setValueType("varint");
        return;
    default:
        throw new ClassNotFoundException();
    }

}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest06.java

/**
 * testValidateArraysIndex04()//from   w  w w .j  av a 2s.  c o  m
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF
 * <br><br>
 * l?F(?) bean:*<br>
 *         (?) va:methodParams?FtestClass<br>
 *                ?NX<br>
 *         (?) field:not null<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *         (?) session:not null<br>
 *         (?) ActionForm:not null<br>
 *
 * <br>
 * l?F(l) boolean:true<br>
 *         (?) ?O:?Ox?FG?[<br>
 *                    ONX?FClassNotFoundException<br>
 *                    ?Ox?FG?[<br>
 *                    ?bZ?[W?F<br>
 *                    "Can not get class pattern."<br>
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * vamethodParams?NX???A
 * truemF?B<br>
 * ?getParamClasseXg
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateArraysIndex04() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = null;

    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    va.setMethodParams("testClass");

    // ++++ ?tB?[h?
    Field field = new Field();

    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    HttpServletRequest request = new MockHttpServletRequest();

    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    boolean result = FieldChecksEx.validateArraysIndex(bean, va, field, errors, validator, request);
    // eXgmF
    // truep?B
    assertTrue(result);
    // G?[??B
    assertTrue(errors.isEmpty());

    // G?[?O`FbN
    assertTrue(LogUTUtil.checkError("", new ClassNotFoundException()));
    assertTrue(LogUTUtil.checkError("Can not get class pattern."));
}

From source file:thesaurusEditor.gui.graph.MainGraph.java

public void loadLayout(String s) throws IOException {
    try {//from   www. j  a  va2  s. c om
        layout.restore(s);
        if (false)
            throw new ClassNotFoundException();
        vv.repaint();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:it.unimi.di.big.mg4j.document.DispatchingDocumentFactory.java

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override/*from www.  j  a  v a2s. co m*/
protected boolean parseProperty(final String key, final String[] values,
        final Reference2ObjectMap<Enum<?>, Object> metadata) throws ConfigurationException {
    if (sameKey(MetadataKeys.FIELDNAME, key)) {
        fieldName = values;
        numberOfFields = fieldName.length;
        return true;
    } else if (sameKey(MetadataKeys.KEY, key)) {
        final String dispatchingKeyName = ensureJustOne(key, values);
        final int lastDot = dispatchingKeyName.lastIndexOf('.');
        try {
            dispatchingKey = Enum.valueOf((Class<Enum>) Class.forName(dispatchingKeyName.substring(0, lastDot)),
                    dispatchingKeyName.substring(lastDot + 1));
        } catch (ClassNotFoundException e) {
            throw new IllegalArgumentException(
                    "The class specified in the key " + dispatchingKeyName + " cannot be found");
        }
        return true;
    } else if (sameKey(MetadataKeys.RULE, key)) {
        String[] rules = values;
        value2factoryClass = new Object2ObjectLinkedOpenHashMap<String, Class<? extends DocumentFactory>>();
        int i, m = rules.length;
        for (i = 0; i < m; i++) {
            int pos = rules[i].indexOf(':');
            if (pos <= 0 || pos == rules[i].length() - 1)
                throw new ConfigurationException(
                        "Rule " + rules[i] + " does not contain a colon or it is malformed");
            if (rules[i].indexOf(':', pos + 1) >= 0)
                throw new ConfigurationException("Rule " + rules[i] + " contains too many colons");
            String factoryName = rules[i].substring(pos + 1);
            Class<? extends DocumentFactory> factoryClass = null;
            try {
                factoryClass = (Class<? extends DocumentFactory>) Class.forName(factoryName);
                if (!(DocumentFactory.class.isAssignableFrom(factoryClass)))
                    throw new ClassNotFoundException();
            } catch (ClassNotFoundException e) {
                throw new ConfigurationException(
                        "ParsingFactory " + factoryName + " is invalid; maybe the package name is missing");
            }
            value2factoryClass.put(rules[i].substring(0, pos), factoryClass);
        }
        m = value2factoryClass.values().size();
        return true;

    } else if (sameKey(MetadataKeys.MAP, key)) {
        String[] pieces = values;
        int i, m = pieces.length;
        rename = new int[m][];
        for (i = 0; i < m; i++) {
            String[] subpieces = pieces[i].split(":");
            if (i > 0 && subpieces.length != rename[0].length)
                throw new ConfigurationException("Length mismatch in the map " + values);
            rename[i] = new int[subpieces.length];
            for (int k = 0; k < subpieces.length; k++) {
                try {
                    rename[i][k] = Integer.parseInt(subpieces[k]);
                } catch (NumberFormatException e) {
                    throw new ConfigurationException("Number format exception in the map " + values);
                }
            }
        }
    }
    return super.parseProperty(key, values, metadata);
}

From source file:com.chinamobile.bcbsp.bspstaff.BSPStaff.java

/** just for test */
public void loadData(BSPJob job) throws ClassNotFoundException, IOException, InterruptedException {
    int i = 0;/*from  www  . ja  v a2s .co  m*/
    this.partitioner = (Partitioner<Text>) ReflectionUtils.newInstance(
            job.getConf().getClass(Constants.USER_BC_BSP_JOB_PARTITIONER_CLASS, HashPartitioner.class),
            job.getConf());
    if (i == 1) {
        throw new ClassNotFoundException();
    } else if (i == 2) {
        throw new IOException();
    } else if (i == 3) {
        throw new InterruptedException();
    }
}

From source file:com.wavemaker.runtime.ws.salesforce.SalesforceSupport.java

private Class getSforceObjectClass(String objName) throws Exception {
    String apiObjName = getSforceAPIObjectName(objName);
    Class cls;/*from   w ww  . j  ava  2s .  c o  m*/

    String className = "com.sforce.soap.enterprise.salesforceservice." + apiObjName + "Type";

    try {
        cls = Class.forName(className);
    } catch (ClassNotFoundException ex) {
        this.loginSvcBean.logIn("sammysm@wavemaker.com", "Silver77Surfer");
        SessionHeader sessionHeader = LoginService.getSessionHeader();
        SforceService service = LoginService.getSforceService();
        DescribeGlobal parameters = new DescribeGlobal();
        DescribeGlobalResponse dresponse = service.describeGlobal(parameters, sessionHeader, null, null);
        List<DescribeGlobalSObjectResultType> sObjects = dresponse.getResult().getSobjects();

        boolean found = false;
        /*
         * int len = objName.length(); if (len > 3 && (objName.substring(len-3).equalsIgnoreCase("__c") ||
         * objName.substring(len-3).equalsIgnoreCase("__r"))) { objName = objName.substring(0, len-3); }
         */
        objName = getAPISforceObjectShortName(objName);

        for (DescribeGlobalSObjectResultType obj : sObjects) {
            if (objName.equals(obj.getLabelPlural())) {
                found = true;
                // apiObjName = obj.getName();
                apiObjName = getAPISforceObjectShortName(obj.getName());
                /*
                 * if (len > 3 && (apiObjName.substring(len-3).equalsIgnoreCase("__c") ||
                 * apiObjName.substring(len-3).equalsIgnoreCase("__r"))) { apiObjName = apiObjName.substring(0,
                 * len-3); }
                 */
            }
        }

        if (!found) {
            throw new ClassNotFoundException();
        }

        /*
         * len = apiObjName.length(); if (len > 3 && (apiObjName.substring(len-3).equalsIgnoreCase("__c"))) {
         * apiObjName = apiObjName.substring(0, len-3) + "C"; }
         */

        className = "com.sforce.soap.enterprise.salesforceservice." + apiObjName + "Type";

        cls = Class.forName(className);
    }

    return cls;
}

From source file:jp.terasoluna.fw.web.struts.form.FieldChecksExTest08.java

/**
 * testValidateMultiField05()//from ww  w  . j  a v a2  s.  c  o  m
 * <br><br>
 *
 * (?n)
 * <br>
 * _?FF,G
 * <br><br>
 * l?F(?) bean:"abc"<br>
 *         (?) va:not null<br>
 *         (?) field:not null<br>
 *                var:multiFieldValidator="abc"<br>
 *                Msg("message","message")<br>
 *         (?) errors:not null<br>
 *                (vf)<br>
 *         (?) validator:not null<br>
 *         (?) request:not null<br>
 *
 * <br>
 * l?F(?) MultiFieldValidator:?o<br>
 *         (?) O:IllegalArgumentException<br>
 *                    ?bZ?[W?F<br>
 *                    "var value[multiFieldValidator] is invalid."<br>
 *         (?) ?O:?Ox?FG?[<br>
 *                    ?bZ?[W?F<br>
 *                    "var value[multiFieldValidator] is invalid."<br>
 *                    O?F<br>
 *                    ClassLoadException(ClassNotFoundException)
 *         (?) errors:not null<br>
 *                    (vf)<br>
 *
 * <br>
 * fieldmultiFieldValidatorNXpX??NX?A
 * IllegalArgumentException?mF?B
 * <br>
 *
 * @throws Exception ?\bh?O
 */
public void testValidateMultiField05() throws Exception {
    //eXgf?[^?
    // ++++ beanIuWFNg ++++
    String bean = "abc";
    // ++++ ??IuWFNg
    ValidatorAction va = new ValidatorAction();
    // ++++ ?tB?[h?
    Field field = new Field();
    Var var = new Var();
    var.setName("multiFieldValidator");
    var.setValue("abc");
    field.addVar(var);
    // ?bZ?[W?
    Msg msg = new Msg();
    msg.setKey("message");
    msg.setName("message");
    msg.setResource(false);
    field.addMsg(msg);
    // G?[?
    ActionMessages errors = new ActionMessages();
    // [HTTPNGXg
    MockHttpServletRequest request = new MockHttpServletRequest();
    // ValidatorResourcesCX^X
    ValidatorResources validatorResources = new ValidatorResources();
    // ValidatorCX^X
    Validator validator = new Validator(validatorResources);

    // eXg?s
    try {
        FieldChecksEx.validateMultiField(bean, va, field, errors, validator, request);
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(errors.isEmpty());
        assertEquals("var value[multiFieldValidator] is invalid.", e.getMessage());
        assertTrue(LogUTUtil.checkError("var value[multiFieldValidator] is invalid.",
                new ClassLoadException(new ClassNotFoundException())));
    }
}

From source file:wjhk.jupload2.policies.DefaultUploadPolicy.java

/** @see wjhk.jupload2.policies.UploadPolicy#setLang(String) */
public void setLang(String lang) {
    this.lang = lang;
    if (lang == null) {
        displayInfo("lang = null, taking default language");
        locale = Locale.getDefault();
    } else {//from  w  w  w .  j  a  v a2 s.c  o  m
        // If we have a 5 characters lang string, then it should look like
        // ll_CC, where ll is the language code
        // and CC is the Country code.
        if (lang.length() == 5 && (lang.substring(2, 3).equals("_") || lang.substring(2, 3).equals("-"))) {
            String language = lang.substring(0, 2);
            String country = lang.substring(3, 5);
            displayDebug("setLang - language read: " + language, 50);
            displayDebug("setLang - country read: " + country, 50);
            locale = new Locale(language, country.toUpperCase());
        } else {
            locale = new Locale(lang);
            displayDebug("setLang - language read (no country): " + lang, 50);
        }
    }

    /*
     * Patch given by Patrick Use of a specific class loader. The standard
     * ResourceBundle checks first for a class that has the name of the
     * resource bundle. Since there is no such class in the jar file, the
     * AppletClassLoader makes a http request to the server, which will end
     * with a 404 since there is no such class either. To avoid this
     * unnecessary lookup we use a class loader that throws directly a
     * ClassNotFoundException. After looking for a class (which is
     * unsuccessful) ResourceBundle looks finally for a properties file.
     * Therefore we delegate that lookup to the original class loader since
     * this is in the jar file.
     */
    this.resourceBundle = ResourceBundle.getBundle("lang.lang", locale,
            // Special class loader, see description above
            new ClassLoader(this.getClass().getClassLoader()) {
                /** {@inheritDoc} */
                @Override
                public Class<?> loadClass(String name) throws ClassNotFoundException {
                    throw new ClassNotFoundException();
                }

                /** {@inheritDoc} */
                @Override
                public InputStream getResourceAsStream(String name) {
                    return this.getClass().getClassLoader().getResourceAsStream(name);
                }
            });
}