Example usage for java.lang NoSuchFieldException printStackTrace

List of usage examples for java.lang NoSuchFieldException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.google.api.ads.adwords.awreporting.model.persistence.sql.SqlReportEntitiesPersister.java

/**
 * Create a new composed Index with the the "keys" columns
 *///from w  w w. jav  a2s . c  o m
@Override
@Transactional
public <T> void createIndex(Class<T> t, List<String> keys) {
    try {
        Table table = t.getAnnotation(Table.class);
        String tableName = table.name();

        String columnNames = "";
        String columnIndexName = "";
        int position = 0;
        for (String key : keys) {
            Field property = getField(t, key);
            Column column = property.getAnnotation(Column.class);

            if (position++ == 0) {
                columnNames += column.name();
                columnIndexName += column.name();
            } else {
                columnNames += "," + column.name();
                columnIndexName += "_" + column.name();
            }
        }

        String checkIndex = "SELECT COUNT(1) IndexIsThere FROM INFORMATION_SCHEMA.STATISTICS WHERE "
                + "Table_name='" + tableName + "' AND index_name='AW_INDEX_" + columnIndexName + "'";

        String newIndex = "ALTER TABLE  " + tableName + " ADD INDEX " + "AW_INDEX_" + columnIndexName + " ( "
                + columnNames + " )";

        Session session = this.sessionFactory.getCurrentSession();

        List<?> list = session.createSQLQuery(checkIndex).list();
        if (String.valueOf(list.get(0)).equals("0")) {
            System.out.println("Creating Index AW_INDEX_" + columnIndexName + " ON " + tableName);
            SQLQuery sqlQuery = session.createSQLQuery(newIndex);
            sqlQuery.executeUpdate();
        }

    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    }
}

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.BlueprintsPersistenceBackendFactory.java

@Override
public BlueprintsPersistenceBackend createPersistentBackend(File file, Map<?, ?> options)
        throws InvalidDataStoreException {
    BlueprintsPersistenceBackend graphDB = null;
    PropertiesConfiguration neoConfig = null;
    PropertiesConfiguration configuration = null;
    try {/*from   ww  w .  j  av a2  s  . co  m*/
        // Try to load previous configurations
        Path path = Paths.get(file.getAbsolutePath()).resolve(CONFIG_FILE);
        try {
            configuration = new PropertiesConfiguration(path.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        // Initialize value if the config file has just been created
        if (!configuration.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            configuration.setProperty(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE,
                    BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE_DEFAULT);
        } else if (options.containsKey(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)) {
            // The file already existed, check that the issued options
            // are not conflictive
            String savedGraphType = configuration
                    .getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
            String issuedGraphType = options.get(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE)
                    .toString();
            if (!savedGraphType.equals(issuedGraphType)) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, "Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
                throw new InvalidDataStoreException("Unable to create graph as type " + issuedGraphType
                        + ", expected graph type was " + savedGraphType + ")");
            }
        }

        // Copy the options to the configuration
        for (Entry<?, ?> e : options.entrySet()) {
            configuration.setProperty(e.getKey().toString(), e.getValue().toString());
        }

        // Check we have a valid graph type, it is needed to get the
        // graph name
        String graphType = configuration.getString(BlueprintsResourceOptions.OPTIONS_BLUEPRINTS_GRAPH_TYPE);
        if (graphType == null) {
            throw new InvalidDataStoreException("Graph type is undefined for " + file.getAbsolutePath());
        }

        String[] segments = graphType.split("\\.");
        if (segments.length >= 2) {
            String graphName = segments[segments.length - 2];
            String upperCaseGraphName = Character.toUpperCase(graphName.charAt(0)) + graphName.substring(1);
            String configClassQualifiedName = MessageFormat.format(
                    "fr.inria.atlanmod.neoemf.graph.blueprints.{0}.config.Blueprints{1}Config", graphName,
                    upperCaseGraphName);
            try {
                ClassLoader classLoader = BlueprintsPersistenceBackendFactory.class.getClassLoader();
                Class<?> configClass = classLoader.loadClass(configClassQualifiedName);
                Field configClassInstanceField = configClass.getField("eINSTANCE");
                AbstractBlueprintsConfig configClassInstance = (AbstractBlueprintsConfig) configClassInstanceField
                        .get(configClass);
                Method configMethod = configClass.getMethod("putDefaultConfiguration", Configuration.class,
                        File.class);
                configMethod.invoke(configClassInstance, configuration, file);
                Method setGlobalSettingsMethod = configClass.getMethod("setGlobalSettings");
                setGlobalSettingsMethod.invoke(configClassInstance);
            } catch (ClassNotFoundException e1) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        "Unable to find the configuration class " + configClassQualifiedName);
                e1.printStackTrace();
            } catch (NoSuchFieldException e2) {
                NeoLogger.log(NeoLogger.SEVERITY_WARNING,
                        MessageFormat.format(
                                "Unable to find the static field eINSTANCE in class Blueprints{0}Config",
                                upperCaseGraphName));
                e2.printStackTrace();
            } catch (NoSuchMethodException e3) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                        MessageFormat.format(
                                "Unable to find configuration methods in class Blueprints{0}Config",
                                upperCaseGraphName));
                e3.printStackTrace();
            } catch (InvocationTargetException e4) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e4.printStackTrace();
            } catch (IllegalAccessException e5) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, MessageFormat.format(
                        "An error occured during the exection of a configuration method", upperCaseGraphName));
                e5.printStackTrace();
            }
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_WARNING, "Unable to compute graph type name from " + graphType);
        }

        Graph baseGraph = null;
        try {
            baseGraph = GraphFactory.open(configuration);
        } catch (RuntimeException e) {
            throw new InvalidDataStoreException(e);
        }
        if (baseGraph instanceof KeyIndexableGraph) {
            graphDB = new BlueprintsPersistenceBackend((KeyIndexableGraph) baseGraph);
        } else {
            NeoLogger.log(NeoLogger.SEVERITY_ERROR,
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
            throw new InvalidDataStoreException(
                    "Graph type " + file.getAbsolutePath() + " does not support Key Indices");
        }
        // Save the neoconfig file
        Path neoConfigPath = Paths.get(file.getAbsolutePath()).resolve(NEO_CONFIG_FILE);
        try {
            neoConfig = new PropertiesConfiguration(neoConfigPath.toFile());
        } catch (ConfigurationException e) {
            throw new InvalidDataStoreException(e);
        }
        if (!neoConfig.containsKey(BACKEND_PROPERTY)) {
            neoConfig.setProperty(BACKEND_PROPERTY, BLUEPRINTS_BACKEND);
        }
    } finally {
        if (configuration != null) {
            try {
                configuration.save();
            } catch (ConfigurationException e) {
                // Unable to save configuration, supposedly it's a minor error,
                // so we log it without rising an exception
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
        if (neoConfig != null) {
            try {
                neoConfig.save();
            } catch (ConfigurationException e) {
                NeoLogger.log(NeoLogger.SEVERITY_ERROR, e);
            }
        }
    }
    return graphDB;
}

From source file:com.ycdyng.onemulti.OneActivity.java

public void clearAvailIndices() {
    Class<?> classType = mFragmentManager.getClass();
    Field field = null;//from  w  w w .ja  v  a2 s  .c  om
    try {
        field = classType.getDeclaredField("mAvailIndices");
        field.setAccessible(true);
        field.set(mFragmentManager, null);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}

From source file:org.apache.ranger.service.RangerPolicyService.java

public List<XXTrxLog> getTransactionLog(RangerPolicy vObj, XXPolicy mObj, int action) {
    if (vObj == null || action == 0 || (action == OPERATION_UPDATE_CONTEXT && mObj == null)) {
        return null;
    }// w w w .j a v  a  2 s .  c o m
    List<XXTrxLog> trxLogList = new ArrayList<XXTrxLog>();
    Field[] fields = vObj.getClass().getDeclaredFields();

    try {

        Field nameField = vObj.getClass().getDeclaredField("name");
        nameField.setAccessible(true);
        String objectName = "" + nameField.get(vObj);
        for (Field field : fields) {
            if (!trxLogAttrs.containsKey(field.getName())) {
                continue;
            }
            XXTrxLog xTrxLog = processFieldToCreateTrxLog(field, objectName, nameField, vObj, mObj, action);
            if (xTrxLog != null) {
                trxLogList.add(xTrxLog);
            }
        }

        Field[] superClassFields = vObj.getClass().getSuperclass().getDeclaredFields();
        for (Field field : superClassFields) {
            if (field.getName().equalsIgnoreCase("isEnabled")) {
                XXTrxLog xTrx = processFieldToCreateTrxLog(field, objectName, nameField, vObj, mObj, action);
                if (xTrx != null) {
                    trxLogList.add(xTrx);
                }
                break;
            }
        }
    } catch (IllegalAccessException illegalAcc) {
        illegalAcc.printStackTrace();
    } catch (NoSuchFieldException noSuchField) {
        noSuchField.printStackTrace();
    }

    return trxLogList;
}

From source file:com.ycdyng.onemulti.OneActivity.java

private int getFragmentIndex(Fragment fragment) {
    int fragmentIndex = 0;
    Class cls = fragment.getClass();
    do {/*from  w w w.ja  v a 2  s.  co m*/
        cls = cls.getSuperclass();
    } while (!cls.getSimpleName().equals("Fragment"));
    try {
        Field field = cls.getDeclaredField("mIndex");
        field.setAccessible(true);
        fragmentIndex = field.getInt(fragment);
        field.setAccessible(false);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return fragmentIndex;
}

From source file:tudarmstadt.lt.ABSentiment.training.util.ProblemBuilder.java

protected static INDArray classifyTestSet(String inputFile, Model model, Vector<FeatureExtractor> features,
        String predictionFile, String type, boolean printResult) {
    InputReader fr;//w ww  .j ava  2 s  . co m
    if (inputFile.endsWith("xml")) {
        fr = new XMLReader(inputFile);
    } else {
        fr = new TsvReader(inputFile);
    }

    Writer out = null;
    Writer featureOut = null;

    try {
        OutputStream predStream = new FileOutputStream(predictionFile);
        out = new OutputStreamWriter(predStream, "UTF-8");
        if (featureOutputFile != null) {
            OutputStream vectorStream = new FileOutputStream(featureOutputFile);
            featureOut = new OutputStreamWriter(vectorStream, "UTF-8");
        }
    } catch (FileNotFoundException | UnsupportedEncodingException e1) {
        e1.printStackTrace();
        System.exit(1);
    }

    Feature[] instance;
    Vector<Feature[]> instanceFeatures;

    confusionMatrix = new ConfusionMatrix();
    String item;
    for (int j = 0; j < model.getNrClass(); j++) {
        item = labelLookup.get(Integer.parseInt(model.getLabels()[j] + ""));
        confusionMatrix.addLabel(item);
        allLabels.add(item);
    }

    ArrayList<double[]> probability = new ArrayList<>();
    confusionMatrix.createMatrix();

    for (Document doc : fr) {
        for (Sentence sentence : doc.getSentences()) {
            int i = 0;
            preprocessor.processText(sentence.getText());
            instanceFeatures = applyFeatures(preprocessor.getCas(), features);
            Double prediction;
            instance = combineInstanceFeatures(instanceFeatures);
            double[] prob_estimates = new double[model.getNrClass()];
            prediction = Linear.predictProbability(model, instance, prob_estimates);
            probability.add(prob_estimates);
            try {
                out.write(sentence.getId() + "\t" + sentence.getText() + "\t");
                String goldLabel = null;
                String predictedLabel = labelLookup.get(prediction.intValue());
                if (type.compareTo("relevance") == 0) {
                    goldLabel = sentence.getRelevance()[0];
                    confusionMatrix.updateMatrix(predictedLabel, goldLabel);
                } else if (type.compareTo("sentiment") == 0) {
                    try {
                        while (i < sentence.getSentiment().length) {
                            goldLabel = sentence.getSentiment()[i++];
                            confusionMatrix.updateMatrix(predictedLabel, goldLabel);
                        }
                    } catch (NoSuchFieldException e) {
                    }
                } else if (useCoarseLabels) {
                    out.append(StringUtils.join(sentence.getAspectCategoriesCoarse(), " "));
                    goldLabel = StringUtils.join(sentence.getAspectCategoriesCoarse(), " ");
                    confusionMatrix.updateMatrix(predictedLabel, goldLabel);
                } else {
                    out.append(StringUtils.join(sentence.getAspectCategories(), " "));
                    goldLabel = StringUtils.join(sentence.getAspectCategories(), " ");
                    confusionMatrix.updateMatrix(predictedLabel, goldLabel);
                }
                out.append("\t").append(labelLookup.get(prediction.intValue())).append("\n");
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (featureOutputFile != null) {
                String[] labels = sentence.getAspectCategories();
                if (useCoarseLabels) {
                    labels = sentence.getAspectCategoriesCoarse();
                }
                for (String label : labels) {
                    try {
                        assert featureOut != null;
                        for (Feature f : instance) {
                            featureOut.write(" " + f.getIndex() + ":" + f.getValue());
                        }
                        featureOut.write("\n");
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }

    INDArray classificationProbability = Nd4j.zeros(probability.size(), model.getNrClass());
    int j = -1;
    for (double prob_estimates[] : probability) {
        classificationProbability.putRow(++j, Nd4j.create(prob_estimates));
    }

    try {
        out.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    HashMap<String, Float> recall;
    HashMap<String, Float> precision;
    HashMap<String, Float> fMeasure;

    recall = getRecallForAll();
    precision = getPrecisionForAll();
    fMeasure = getFMeasureForAll();

    if (printResult) {
        System.out.println("Label" + "\t" + "Recall" + "\t" + "Precision" + "\t" + "F Score");
        for (String itemLabel : allLabels) {
            System.out.println(itemLabel + "\t" + recall.get(itemLabel) + "\t" + precision.get(itemLabel) + "\t"
                    + fMeasure.get(itemLabel));
        }
        printFeatureStatistics(features);
        printConfusionMatrix();
        System.out.println("\n");
        System.out.println("True positive     : " + getTruePositive());
        System.out.println("Accuracy          : " + getOverallAccuracy());
        System.out.println("Overall Precision : " + getOverallPrecision());
        System.out.println("Overall Recall    : " + getOverallRecall());
        System.out.println("Overall FMeasure  : " + getOverallFMeasure());
    }

    return classificationProbability;
}

From source file:net.cloudpath.xpressconnect.screens.GetCredentials.java

public WifiConfigurationProxy getExistingConfig(int paramInt) {
    List localList = ((WifiManager) getSystemService("wifi")).getConfiguredNetworks();
    for (int i = 0; i < localList.size(); i++)
        if (((WifiConfiguration) localList.get(i)).networkId == paramInt)
            try {
                WifiConfigurationProxy localWifiConfigurationProxy = new WifiConfigurationProxy(
                        (WifiConfiguration) localList.get(i), this.mLogger);
                return localWifiConfigurationProxy;
            } catch (IllegalArgumentException localIllegalArgumentException) {
                Util.log(this.mLogger, "IllegalArgumentException in getExistingConfig()!");
                localIllegalArgumentException.printStackTrace();
                return null;
            } catch (NoSuchFieldException localNoSuchFieldException) {
                Util.log(this.mLogger, "NoSuchFieldException in getExistingConfig()!");
                localNoSuchFieldException.printStackTrace();
                return null;
            } catch (ClassNotFoundException localClassNotFoundException) {
                Util.log(this.mLogger, "ClassNotFoundException in getExistingConfig()!");
                localClassNotFoundException.printStackTrace();
                return null;
            } catch (IllegalAccessException localIllegalAccessException) {
                Util.log(this.mLogger, "IllegalAccessException in getExistingConfig()!");
                localIllegalAccessException.printStackTrace();
                return null;
            }/*w  w  w  . j  a  v a2s  . com*/
    return null;
}

From source file:net.cloudpath.xpressconnect.screens.GetCredentials.java

public int isConnectionFound() {
    List localList = ((WifiManager) getSystemService("wifi")).getConfiguredNetworks();
    if (localList == null) {
        Util.log(this.mLogger, "No networks in the network list.  (So the network isn't found.)");
        return -1;
    }/*from   ww  w.  j av  a 2 s  .c o  m*/
    if (this.mParser == null) {
        Util.log(this.mLogger, "Parser isn't bound in isConnectionFound()!");
        return -2;
    }
    if (this.mParser.selectedProfile == null) {
        Util.log(this.mLogger, "No profile is selected in isConnectionFound()!");
        return -2;
    }
    if (this.mFailure == null) {
        Util.log(this.mLogger, "Failure class is null in isConnectionFound()!");
        return -2;
    }
    Util.log(this.mLogger,
            "Your device currently has " + localList.size() + " wireless network(s) configured.");
    int i = 0;
    if (i < localList.size()) {
        WifiConfigurationProxy localWifiConfigurationProxy;
        SettingElement localSettingElement;
        try {
            localWifiConfigurationProxy = new WifiConfigurationProxy((WifiConfiguration) localList.get(i),
                    this.mLogger);
            localSettingElement = this.mParser.selectedProfile.getSetting(1, 40001);
            if (localSettingElement == null) {
                Util.log(this.mLogger, "Unable to locate the SSID element!");
                this.mFailure.setFailReason(FailureReason.useErrorIcon, getResources()
                        .getString(this.mParcelHelper.getIdentifier("xpc_no_ssid_defined", "string")), 6);
                return -2;
            }
        } catch (IllegalArgumentException localIllegalArgumentException) {
            Util.log(this.mLogger, "IllegalArgumentException in isConnectionFound()!");
            localIllegalArgumentException.printStackTrace();
            return -2;
        } catch (NoSuchFieldException localNoSuchFieldException) {
            Util.log(this.mLogger, "NoSuchFieldException in isConnectionFound()!");
            localNoSuchFieldException.printStackTrace();
            return -2;
        } catch (ClassNotFoundException localClassNotFoundException) {
            Util.log(this.mLogger, "ClassNotFoundException in isConnectionFound()!");
            localClassNotFoundException.printStackTrace();
            return -2;
        } catch (IllegalAccessException localIllegalAccessException) {
            Util.log(this.mLogger, "IllegalAccessException in isConnectionFound()!");
            localIllegalAccessException.printStackTrace();
            return -2;
        }
        String[] arrayOfString;
        if (localSettingElement.additionalValue != null) {
            arrayOfString = localSettingElement.additionalValue.split(":");
            if (arrayOfString.length != 3) {
                Util.log(this.mLogger, "The SSID element provided in the configuration file is invalid!");
                this.mFailure.setFailReason(FailureReason.useErrorIcon, getResources()
                        .getString(this.mParcelHelper.getIdentifier("xpc_ssid_element_invalid", "string")), 6);
                return -2;
            }
            if (this.mParser.savedConfigInfo != null)
                this.mParser.savedConfigInfo.ssid = arrayOfString[2];
            if (localWifiConfigurationProxy.getSsid() != null)
                break label429;
            Util.log(this.mLogger, "SSID was null parsing network string.");
        }
        label429: while (!localWifiConfigurationProxy.getSsid().equals("\"" + arrayOfString[2] + "\"")) {
            i++;
            break;
        }
        Util.log(this.mLogger, "Our SSID already exists.  It will be replaced.");
        return localWifiConfigurationProxy.getNetworkId();
    }
    return -1;
}

From source file:com.lcw.one.common.persistence.BaseDao.java

/**
 * /*from w w  w  .  j  av  a 2 s  .c  o  m*/
 * @param detachedCriteria
 * @return
 */
@SuppressWarnings("rawtypes")
public long count(DetachedCriteria detachedCriteria) {
    Criteria criteria = detachedCriteria.getExecutableCriteria(getSession());
    long totalCount = 0;
    try {
        // Get orders
        Field field = CriteriaImpl.class.getDeclaredField("orderEntries");
        field.setAccessible(true);
        List orderEntrys = (List) field.get(criteria);
        // Remove orders
        field.set(criteria, new ArrayList());
        // Get count
        criteria.setProjection(Projections.rowCount());
        totalCount = Long.valueOf(criteria.uniqueResult().toString());
        // Clean count
        criteria.setProjection(null);
        // Restore orders
        field.set(criteria, orderEntrys);
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return totalCount;
}

From source file:com.gome.haoyuangong.views.SwipeRefreshLayout.java

private void removeListTapCallback(ListView list) {
    try {//from ww w . ja v a  2s  .  c o m
        Field field = AbsListView.class.getField("mPendingCheckForTap");
        field.setAccessible(true);
        Runnable c = (Runnable) (field.get(list));
        if (c != null) {

            list.removeCallbacks(c);
        }
    } catch (NoSuchFieldException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}