Example usage for java.lang Exception getStackTrace

List of usage examples for java.lang Exception getStackTrace

Introduction

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

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:com.bah.applefox.main.plugins.fulltextindex.FTAccumuloSampler.java

/**
 * Overridden method to create the sample
 *///w ww. jav  a2s  . c o  m
public void createSample() {
    try {
        // HashMap to write the sample table to
        HashMap<String, Integer> output = new HashMap<String, Integer>();

        // Scan the data table
        Scanner scan = AccumuloUtils.connectRead(dataTable);

        Map<String, String> properties = new HashMap<String, String>();
        IteratorSetting cfg2 = new IteratorSetting(11, SamplerCreator.class, properties);
        scan.addScanIterator(cfg2);

        for (Entry<Key, Value> entry : scan) {
            try {
                // Write the data from the table to the sample table
                String row = entry.getKey().getRow().toString();
                // get rid of the timestamp at the end
                row = row.substring(0, row.lastIndexOf(" "));
                int value = output.containsKey(row) ? output.get(row) : 0;
                value += (Integer) IngestUtils.deserialize(entry.getValue().get());
                output.put(row, value);
            } catch (Exception e) {
                if (e.getMessage() != null) {
                    log.error(e.getMessage());
                } else {
                    log.error(e.getStackTrace());
                }
            }
        }

        // get the total number of docs from the urls table
        Scanner scann = AccumuloUtils.connectRead(urlTable);

        IteratorSetting cfg3 = new IteratorSetting(11, TotalDocFinder.class, properties);
        scann.addScanIterator(cfg3);

        for (Entry<Key, Value> entry : scann) {
            try {
                output.put(entry.getKey().getRow().toString(),
                        (Integer) IngestUtils.deserialize(entry.getValue().get()));
            } catch (Exception e) {
                if (e.getMessage() != null) {
                    log.error(e.getMessage());
                } else {
                    log.error(e.getStackTrace());
                }
            }
        }

        // Create the sample table file
        File f = new File(sampleFile);
        f.createNewFile();

        // use buffering
        OutputStream file = new FileOutputStream(f);
        OutputStream buffer = new BufferedOutputStream(file);
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(output);
        out.flush();
        out.close();
    } catch (AccumuloException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (AccumuloSecurityException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (TableNotFoundException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (IOException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    }
}

From source file:com.bah.applefox.main.plugins.imageindex.ImageAccumuloSampler.java

/**
 * Overridden method to create the sample
 *//*from   w  w w.  ja  v a  2 s .  c o m*/
public void createSample() {
    try {
        // HashMap to write the sample table to
        HashMap<String, Integer> output = new HashMap<String, Integer>();

        // Scan the data table
        Scanner scan = AccumuloUtils.connectRead(dataTable);

        Map<String, String> properties = new HashMap<String, String>();
        IteratorSetting cfg2 = new IteratorSetting(11, SamplerCreator.class, properties);
        scan.addScanIterator(cfg2);

        for (Entry<Key, Value> entry : scan) {
            try {
                // Write the data from the table to the sample table
                String row = entry.getKey().getRow().toString();
                int value = output.containsKey(row) ? output.get(row) : 0;
                value += 1;
                output.put(row, value);
            } catch (Exception e) {
                if (e.getMessage() != null) {
                    log.error(e.getMessage());
                } else {
                    log.error(e.getStackTrace());
                }
            }
        }

        // get the total number of docs from the urls table
        Scanner scann = AccumuloUtils.connectRead(urlTable);

        IteratorSetting cfg3 = new IteratorSetting(11, TotalDocFinder.class, properties);
        scann.addScanIterator(cfg3);

        for (Entry<Key, Value> entry : scann) {
            try {
                output.put(entry.getKey().getRow().toString(),
                        (Integer) IngestUtils.deserialize(entry.getValue().get()));
            } catch (Exception e) {
                if (e.getMessage() != null) {
                    log.error(e.getMessage());
                } else {
                    log.error(e.getStackTrace());
                }
            }
        }

        // Create the sample table file
        System.out.println(output.size());
        System.out.println("sample file: " + sampleFile);
        File f = new File(sampleFile);
        f.createNewFile();

        // use buffering
        OutputStream file = new FileOutputStream(f);
        OutputStream buffer = new BufferedOutputStream(file);
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(output);
        out.flush();
        out.close();
    } catch (AccumuloException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (AccumuloSecurityException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (TableNotFoundException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    } catch (IOException e) {
        if (e.getMessage() != null) {
            log.error(e.getMessage());
        } else {
            log.error(e.getStackTrace());
        }
    }
}

From source file:org.kew.rmf.matchconf.ConfigurationEngine.java

/**
 * Runs the deduplicator's CoreApp providing the path to the written config. In case of chained
 * configs it calls one after the other. Doing this it tries to collect as many Exception types
 * as possible and pipes them back to the UI-user.
 *
 * @param writeBefore/*from  w  w  w.j  av  a  2 s. c om*/
 * @return
 */
public Map<String, List<String>> runConfiguration(boolean writeBefore) {
    @SuppressWarnings("serial")
    Map<String, List<String>> infoMap = new HashMap<String, List<String>>() {
        {
            put("messages", new ArrayList<String>());
            put("exception", new ArrayList<String>());
            put("stackTrace", new ArrayList<String>());
        }
    };
    try {
        if (writeBefore)
            this.write_to_filesystem();
        infoMap.get("messages").add(String.format("%s: Written config file to %s..", this.config.getName(),
                this.config.getWorkDirPath()));
        File workDir = new File(this.config.getWorkDirPath());
        assert workDir.exists();
        // assert the luceneDirectory does NOT exist (we want to overwrite the index for now!)
        File luceneDir = new File(this.luceneDirectory);
        if (luceneDir.exists())
            FileUtils.deleteDirectory(luceneDir);
        CoreApp.main(
                new String[] { "-d " + workDir.toString(), "-c config_" + this.config.getName() + ".xml" });
        infoMap.get("messages").add(String.format("%s: Ran without complains.", this.config.getName()));
        // Our super-sophisticated ETL functionality:
        String next = this.config.getNextConfig();
        if (!StringUtils.isBlank(this.config.getNextConfig())) {
            ConfigurationEngine nextEngine = new ConfigurationEngine(
                    Configuration.findConfigurationsByNameEquals(next).getSingleResult());
            Map<String, List<String>> nextInfoMap = nextEngine.runConfiguration();
            infoMap.get("exception").addAll(nextInfoMap.get("exception"));
            infoMap.get("stackTrace").addAll(nextInfoMap.get("stackTrace"));
            infoMap.get("messages").addAll(nextInfoMap.get("messages"));
        }
    } catch (Exception e) {
        infoMap.get("exception").add(e.toString());
        for (StackTraceElement ste : e.getStackTrace())
            infoMap.get("stackTrace").add(ste.toString());
    }
    File luceneDir = new File(this.luceneDirectory);
    try {
        if (luceneDir.exists())
            FileUtils.deleteDirectory(luceneDir);
    } catch (IOException e) {
        System.err.println("Error deleting lucine directory " + luceneDir);
    }
    return infoMap;
}

From source file:fsart.diffTools.gui.DiffToolsMainPanel.java

private String getFileGui() {

    int returnVal = fc.showOpenDialog(panel1);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        try {/*from  w  w  w  . jav a 2  s .c  o  m*/
            return fc.getSelectedFile().getCanonicalPath();
        } catch (Exception e) {
            log.error("Can't get file with FileChooser \n" + e.toString() + "\n" + e.getStackTrace());
            return "";
        }
    }
    return "";
}

From source file:nz.co.fortytwo.signalk.handler.GitHandler.java

protected String upgrade(String path) throws Exception {
    //staticDir.mkdirs();
    Repository repository = null;/*from  w  w w  .j  av a2s .  c  o  m*/
    try {
        String logFile = "output.log";
        File installLogDir = new File(staticDir, "logs");
        installLogDir.mkdirs();
        //
        File destDir = new File(staticDir, SLASH + path);
        destDir.mkdirs();
        File output = new File(installLogDir, logFile);
        String gitPath = github + path + ".git";
        logger.debug("Cloning from " + gitPath + " to " + destDir.getAbsolutePath());
        FileUtils.writeStringToFile(output,
                "Updating from " + gitPath + " to " + destDir.getAbsolutePath() + "\n", false);
        try {
            FileRepositoryBuilder builder = new FileRepositoryBuilder();
            repository = builder.setGitDir(destDir).readEnvironment() // scan environment GIT_* variables
                    .findGitDir() // scan up the file system tree
                    .build();

            FetchResult result = new Git(repository).fetch().setRemote(gitPath).setCheckFetchedObjects(true)
                    .call();
            FileUtils.writeStringToFile(output, result.getMessages(), true);
            logger.debug("Updated " + gitPath + " repository: " + result.getMessages());

            //now run npm install
            runNpmInstall(output, destDir);
        } catch (Exception e) {
            FileUtils.writeStringToFile(output, e.getMessage(), true);
            FileUtils.writeStringToFile(output, e.getStackTrace().toString(), true);
            logger.debug("Error updating " + gitPath + " repository: " + e.getMessage(), e);
        }
        return logFile;

    } finally {
        if (repository != null)
            repository.close();
    }

}

From source file:nz.co.fortytwo.signalk.handler.GitHandler.java

protected String install(String path) throws Exception {
    //staticDir.mkdirs();
    Git result = null;/*  ww  w.  jav a2 s  . c  om*/
    try {
        File installLogDir = new File(staticDir, "logs");
        installLogDir.mkdirs();
        //make log name
        String logFile = "output.log";
        File output = new File(installLogDir, logFile);
        File destDir = new File(staticDir, SLASH + path);
        destDir.mkdirs();
        String gitPath = github + path + ".git";
        logger.debug("Cloning from " + gitPath + " to " + destDir.getAbsolutePath());
        FileUtils.writeStringToFile(output,
                "Updating from " + gitPath + " to " + destDir.getAbsolutePath() + "\n", false);
        try {
            result = Git.cloneRepository().setURI(gitPath).setDirectory(destDir).call();
            result.fetch().setRemote(gitPath);
            logger.debug("Cloned " + gitPath + " repository: " + result.getRepository().getDirectory());
            FileUtils.writeStringToFile(output,
                    "Cloned " + gitPath + " repository: " + result.getRepository().getDirectory(), true);
        } catch (Exception e) {
            FileUtils.writeStringToFile(output, e.getMessage(), true);
            FileUtils.writeStringToFile(output, e.getStackTrace().toString(), true);
            logger.debug("Error updating " + gitPath + " repository: " + e.getMessage(), e);
        }
        try {
            //now run npm install
            runNpmInstall(output, destDir);
        } catch (Exception e) {
            FileUtils.writeStringToFile(output, e.getMessage(), true);
            FileUtils.writeStringToFile(output, e.getStackTrace().toString(), true);
            logger.debug("Error updating " + gitPath + " repository: " + e.getMessage(), e);
        }
        return logFile;

    } finally {
        if (result != null)
            result.close();
    }

}

From source file:com.osi.manager.services.ManagerStartupProcessor.java

@Override
public String saveErrorDetailes(String errorResultXml) {
    LOGGER.info(" ManagerStartupProcessor :: saveErrorDetailes : start");
    String result = "";
    try {/*from  w ww  .ja v  a  2 s.  c  om*/
        if (errorResultXml.equals("") || errorResultXml.equals(null)) {
            result = "Bad request";
        } else {
            result = jobService.saveErrorResultXml(errorResultXml);
        }
        LOGGER.info(" ManagerStartupProcessor :: saveErrorDetailes : end ");

    } catch (Exception e) {
        e.getStackTrace();
        result = "Bad request";
    }
    return result;
}

From source file:edu.cornell.mannlib.vitro.webapp.controller.edit.ObjectPropertyStatementRetryController.java

public void doPost(HttpServletRequest request, HttpServletResponse response) {
    if (!isAuthorizedToDisplayPage(request, response, SimplePermission.DO_BACK_END_EDITING.ACTION)) {
        return;//w w w . ja  v  a 2  s . c  o  m
    }

    VitroRequest vreq = new VitroRequest(request);

    //create an EditProcessObject for this and put it in the session
    EditProcessObject epo = super.createEpo(request);
    epo.setBeanClass(PropertyInstanceIface.class);
    Class[] classarray = { PropertyInstanceIface.class };
    try {
        epo.setInsertMethod(PropertyInstanceDao.class.getMethod("insertProp", classarray));
        epo.setUpdateMethod(epo.getInsertMethod());
    } catch (NoSuchMethodException nsme) {
        log.error("Unable to find " + PropertyInstanceDao.class.getName() + ".insertProp("
                + PropertyInstanceIface.class.getName() + ")");
    }

    try {
        epo.setDeleteMethod(PropertyInstanceDao.class.getMethod("deletePropertyInstance", classarray));
    } catch (NoSuchMethodException nsme) {
        log.error("Unable to find " + PropertyInstanceDao.class.getName() + ".deletePropertyInstance("
                + PropertyInstanceIface.class.getName() + ")");
    }

    String action = "insert";

    PropertyInstanceDao piDao = vreq.getUnfilteredWebappDaoFactory().getPropertyInstanceDao();
    epo.setDataAccessObject(piDao);
    ObjectPropertyDao pDao = vreq.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
    IndividualDao eDao = vreq.getUnfilteredWebappDaoFactory().getIndividualDao();
    VClassDao vcDao = vreq.getUnfilteredWebappDaoFactory().getVClassDao();

    PropertyInstance objectForEditing = null;
    if (!epo.getUseRecycledBean()) {
        objectForEditing = new PropertyInstance();
        populateBeanFromParams(objectForEditing, vreq);
        if (vreq.getParameter(MULTIPLEXED_PARAMETER_NAME) != null) {
            action = "update";
        }
        epo.setOriginalBean(objectForEditing);
    } else {
        objectForEditing = (PropertyInstance) epo.getNewBean();
    }

    //set up any listeners
    //        List changeListenerList = new LinkedList();
    //        changeListenerList.add(new SearchReindexer());
    //        epo.setChangeListenerList(changeListenerList);

    FormObject foo = new FormObject();
    ObjectProperty p = pDao.getObjectPropertyByURI(objectForEditing.getPropertyURI());
    if (p != null) {
        foo.getValues().put("Prop", p.getDomainPublic());
    } else {
        foo.getValues().put("Prop", "The property must be specified.");
    }
    HashMap optionMap = new HashMap();
    String domainEntityName = "";
    String rangeEntityName = "";
    Individual domainEntity = eDao.getIndividualByURI(objectForEditing.getSubjectEntURI());
    List domainOptionList = new LinkedList();
    Individual subjectInd = eDao.getIndividualByURI(objectForEditing.getSubjectEntURI());
    if (subjectInd != null) {
        Option subjOpt = new Option(subjectInd.getURI(), subjectInd.getName());
    }
    domainOptionList.add(new Option(domainEntity.getURI(), domainEntity.getName(), true));
    optionMap.put("SubjectEntURI", domainOptionList);

    // TODO : handle list of VClasses
    List<VClass> possibleClasses = vcDao.getVClassesForProperty(domainEntity.getVClassURI(),
            objectForEditing.getPropertyURI());
    Iterator<VClass> possIt = possibleClasses.iterator();
    HashSet<Individual> possIndSet = new HashSet<Individual>();
    while (possIt.hasNext()) {
        VClass possClass = possIt.next();
        List<Individual> possibleIndividuals = eDao.getIndividualsByVClass(possClass);
        possIndSet.addAll(possibleIndividuals);
    }
    List<Individual> indList = new LinkedList();
    indList.addAll(possIndSet);
    sortForPickList(indList, vreq);
    List objectEntOptionList = new LinkedList();
    Iterator<Individual> indIt = indList.iterator();
    while (indIt.hasNext()) {
        Individual objInd = indIt.next();
        Option objIndOpt = new Option(objInd.getURI(), objInd.getName());
        if (objectForEditing.getObjectEntURI() != null
                && objectForEditing.getObjectEntURI().equals(objInd.getURI())) {
            objIndOpt.setSelected(true);
        }
        objectEntOptionList.add(objIndOpt);
    }
    if (objectEntOptionList.size() == 0) {
        objectEntOptionList
                .add(new Option("", "There are no individuals yet defined that could fill this role."));
    }
    optionMap.put("ObjectEntURI", objectEntOptionList);

    foo.setOptionLists(optionMap);
    epo.setFormObject(foo);

    FormUtils.populateFormFromBean(objectForEditing, action, foo);

    RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
    request.setAttribute("bodyJsp", "/templates/edit/formBasic.jsp");
    request.setAttribute("formJsp", "/templates/edit/specific/ents2ents_retry_domainSide.jsp");
    request.setAttribute("scripts", "/templates/edit/formBasic.js");
    request.setAttribute("title", "Object Property Instance Editing Form");
    request.setAttribute("_action", action);
    request.setAttribute("unqualifiedClassName", "ObjectPropertyStatement");
    setRequestAttributes(request, epo);

    try {
        rd.forward(request, response);
    } catch (Exception e) {
        log.error("ObjectPropertyStatementRetryController could not forward to view.");
        log.error(e.getMessage());
        log.error(e.getStackTrace());
    }

}

From source file:com.yuntongxun.ecdemo.storage.IMessageSqlManager.java

/**
 * Im????//from  w  w  w .  j  a  v a2 s .  c o  m
 *
 * @param msgId     ?ID
 * @param sendStatu ???
 * @return
 */
public static int setIMessageSendStatus(String msgId, int sendStatu, int duration) {
    int row = 0;
    ContentValues values = new ContentValues();
    try {
        String where = IMessageColumn.MESSAGE_ID + " = '" + msgId + "' and " + IMessageColumn.SEND_STATUS + "!="
                + sendStatu;
        values.put(IMessageColumn.SEND_STATUS, sendStatu);
        if (duration > 0) {
            values.put(IMessageColumn.DURATION, duration);
        }
        row = getInstance().sqliteDB().update(DatabaseHelper.TABLES_NAME_IM_MESSAGE, values, where, null);
        // notifyChanged(msgId);
    } catch (Exception e) {
        LogUtil.e(TAG + " " + e.toString());
        e.getStackTrace();
    } finally {
        if (values != null) {
            values.clear();
            values = null;
        }
    }
    return row;
}

From source file:com.intel.hadoop.hbase.dot.doc.serializer.AvroData.java

@Override
public void setValue(byte[] field, byte[] value) throws IOException {
    try {//from ww w .ja v  a  2  s .  c o m
        this.record.put(new String(field), ByteBuffer.wrap(value));
    } catch (AvroRuntimeException are) {
        throw new DocSchemaMissMatchException(DocSchemaMissMatchException.INVALID_DOC_OR_FIELD);
    } catch (NullPointerException npe) {
        throw new DocSchemaMissMatchException(DocSchemaMissMatchException.INVALID_DOC_OR_FIELD);
    } catch (Exception e) {
        LOG.info("Unexpected exception: " + e);
        LOG.info(e.getStackTrace());
        throw new IOException(e);
    }
}