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:org.apache.gora.cassandra.store.CassandraStore.java

/** 
 * Initialize is called when then the call to 
 * {@link org.apache.gora.store.DataStoreFactory#createDataStore(Class<D> dataStoreClass, Class<K> keyClass, Class<T> persistent, org.apache.hadoop.conf.Configuration conf)}
 * is made. In this case, we merely delegate the store initialization to the 
 * {@link org.apache.gora.cassandra.store.CassandraClient#initialize(Class<K> keyClass, Class<T> persistentClass)}. 
 *//* www .  j ava 2  s  .  co m*/
public void initialize(Class<K> keyClass, Class<T> persistent, Properties properties) {
    try {
        super.initialize(keyClass, persistent, properties);
        this.cassandraClient.initialize(keyClass, persistent);
    } catch (Exception e) {
        LOG.error(e.getMessage());
        LOG.error(e.getStackTrace().toString());
    }
}

From source file:com.thoughtworks.go.service.ConfigRepository.java

void cleanAndResetToMaster() throws IOException {
    try {/*from w  w  w.ja  v  a  2s  .  c o  m*/
        git.reset().setMode(ResetCommand.ResetType.HARD).call();
        checkout("master");
        deleteBranch(BRANCH_AT_REVISION);
        deleteBranch(BRANCH_AT_HEAD);
    } catch (Exception e) {
        String currentBranch = git.getRepository().getBranch();
        LOGGER.error(
                "Error while trying to clean up config repository, CurrentBranch: {} \n : \n Message: {} \n StackTrace: {}",
                currentBranch, e.getMessage(), e.getStackTrace(), e);
        throw new RuntimeException(e);
    }
}

From source file:org.openmrs.web.controller.report.ReportSchemaXmlFormController.java

/**
 * @see org.springframework.web.servlet.mvc.SimpleFormController#onSubmit(javax.servlet.http.HttpServletRequest,
 *      javax.servlet.http.HttpServletResponse, java.lang.Object,
 *      org.springframework.validation.BindException)
 *//*from  ww w . j  a  va  2s .c  o m*/
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object commandObject,
        BindException errors) throws Exception {
    ReportSchemaXml reportSchemaXml = (ReportSchemaXml) commandObject;
    ReportService reportService = (ReportService) Context.getService(ReportService.class);

    try {
        // create a new object out of their xml in order to verify xml and copy out the id/name/desc
        ReportSchema schema = reportService.getReportSchema(reportSchemaXml);

        // if the user changed the reportSchemaId to create a new one, create a new object here 
        // so hibernate doesn't complain
        if (reportSchemaXml.getReportSchemaId() != null
                && !schema.getReportSchemaId().equals(reportSchemaXml.getReportSchemaId())) {
            String xml = reportSchemaXml.getXml();
            reportSchemaXml = new ReportSchemaXml();
            reportSchemaXml.setXml(xml);
        }

        reportSchemaXml.populateFromReportSchema(schema);

        // save the xml to the database
        reportService.saveReportSchemaXml(reportSchemaXml);

    } catch (Exception ex) {
        log.warn("Exception building ReportSchema from XML", ex);
        if (ex.getCause() != null) {
            Throwable temp = ex.getCause();
            while (temp.getCause() != null)
                temp = temp.getCause();
            errors.rejectValue("xml", temp.getMessage());
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append("Invalid XML content<br/>");
            sb.append(ex).append("<br/>");
            for (StackTraceElement e : ex.getStackTrace())
                sb.append(e.toString()).append("<br/>");
            errors.rejectValue("xml", sb.toString());
        }
        return showForm(request, response, errors);
    }

    HttpSession httpSession = request.getSession();
    httpSession.setAttribute(WebConstants.OPENMRS_MSG_ATTR, "reportingcompatibility.Report.manageSchema.saved");
    return new ModelAndView(new RedirectView(getSuccessView()));
}

From source file:org.openmrs.web.controller.report.ReportSchemaXmlFormController.java

/**
 * @see org.springframework.validation.Validator#validate(java.lang.Object,
 *      org.springframework.validation.Errors)
 *///www  .  j  av  a  2s . com
public void validate(Object commandObject, Errors errors) {
    ValidationUtils.rejectIfEmpty(errors, "xml", "Paste XML for report before saving");
    ReportSchemaXml rsx = (ReportSchemaXml) commandObject;
    try {
        ReportService reportService = (ReportService) Context.getService(ReportService.class);
        ReportSchema schema = reportService.getReportSchema(rsx);
        if (schema == null)
            throw new NullPointerException();
    } catch (Exception ex) {
        log.warn("Exception building ReportSchema from XML", ex);
        if (ex.getCause() != null) {
            Throwable temp = ex.getCause();
            while (temp.getCause() != null) {
                temp = temp.getCause();
            }
            errors.rejectValue("xml", temp.getMessage());
        } else {
            StringBuilder sb = new StringBuilder();
            sb.append("Invalid XML content<br/>");
            sb.append(ex).append("<br/>");
            for (StackTraceElement e : ex.getStackTrace())
                sb.append(e.toString()).append("<br/>");
            errors.rejectValue("xml", sb.toString());
        }
    }
}

From source file:de.uzk.hki.da.at.AcceptanceTestHelper.java

/**
 * /*from ww w .  j  a  v  a  2s .com*/
 * @param originalName
 * @return null if no object found.
 */
Object getObject(String originalName) {
    Object object = null;
    try {
        object = new ObjectNamedQueryDAO().getUniqueObject(originalName, testContractor.getShort_name());
    } catch (Exception e) {
        System.out.println("Catched exception " + e.getMessage() + ". Try again.");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e1) {
            e1.printStackTrace();
        }
        try {
            object = new ObjectNamedQueryDAO().getUniqueObject(originalName, testContractor.getShort_name());
        } catch (Exception e2) {
            fail("Exception loading Object called " + originalName + " " + e2.getStackTrace());
        }
    }
    return object;
}

From source file:edu.rice.cs.bioinfo.programs.phylonet.algos.network.InferMLNetworkFromSequences.java

public List<Tuple<Network, Double>> inferNetwork(String[] gtTaxa, List<char[][]> sequences,
        Map<String, String> allele2species, RateModel gtrsm, double theta, int maxReticulations, int numSol) {
    if (_optimalNetworks == null) {
        _optimalNetworks = new Network[numSol];
        _optimalScores = new double[numSol];
        Arrays.fill(_optimalScores, Double.NEGATIVE_INFINITY);
    }// ww w . j  a  v a  2s  . c  o m

    List<Tuple<char[], Integer>> distinctSequences = summarizeSquences(sequences);
    String startingNetwork = _startNetwork.toString();

    for (int i = 0; i < _numRuns; i++) {
        System.out.println("Run #" + i);
        DirectedGraphToGraphAdapter<String, PhyloEdge<String>> speciesNetwork = makeNetwork(startingNetwork);
        NetworkNeighbourhoodRandomWalkGenerator<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>> allNeighboursStrategy = new NetworkNeighbourhoodRandomWalkGenerator<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>>(
                _operationWeight, makeNode, makeEdge, _seed);
        AllNeighboursHillClimberFirstBetter<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>, Double> searcher = new AllNeighboursHillClimberFirstBetter<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, String, PhyloEdge<String>, Double>(
                allNeighboursStrategy);
        Func1<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, Double> scorer = getScoreFunction(gtTaxa,
                allele2species, distinctSequences, gtrsm, theta);
        Comparator<Double> comparator = getDoubleScoreComparator();
        HillClimbResult<DirectedGraphToGraphAdapter<String, PhyloEdge<String>>, Double> result = searcher
                .search(speciesNetwork, scorer, comparator, _maxExaminations, maxReticulations, _maxFailure,
                        _diameterLimit); // search starts here
        if (resultFile != null) {
            try {
                BufferedWriter bw = new BufferedWriter(new FileWriter(resultFile, true));
                bw.append("Run #" + i + "\n");
                for (int j = 0; j < _optimalNetworks.length; j++) {
                    bw.append(_optimalScores[j] + ": " + _optimalNetworks[j].toString() + "\n");
                }
                bw.newLine();
                bw.close();
            } catch (Exception e) {
                System.err.println(e.getMessage());
                e.getStackTrace();
            }
        }
    }

    List<Tuple<Network, Double>> resultList = new ArrayList<Tuple<Network, Double>>();
    for (int i = 0; i < numSol; i++) {
        if (_optimalNetworks[i] != null)
            resultList.add(new Tuple<Network, Double>(_optimalNetworks[i], _optimalScores[i]));
    }
    //System.out.println("\n #Networks " + result.ExaminationsCount);
    return resultList;
}

From source file:de.thm.arsnova.socket.ARSnovaSocketIOServer.java

public void stopServer() {
    LOGGER.trace("In stopServer method of class: {}", getClass().getName());
    try {/*from ww w .  j  a  v  a 2  s  .  co m*/
        for (final SocketIOClient client : server.getAllClients()) {
            client.disconnect();
        }
    } catch (final Exception e) {
        /* If exceptions are not caught they could prevent the Socket.IO server from shutting down. */
        LOGGER.error("Exception caught on Socket.IO shutdown: {}", e.getStackTrace());
    }
    server.stop();

}

From source file:nl.b3p.kaartenbalie.reporting.ReportThread.java

public void run() {

    try {//w  w w.j a v a2  s. co  m
        EntityTransaction tx = em.getTransaction();

        long processStart = System.currentTimeMillis();

        Report report = new Report();
        tx = em.getTransaction();
        tx.begin();
        try {
            /*
             * Store all the parameters in the report...
             */
            report.setOrganization(organization);
            report.setStartDate(startDate);
            report.setEndDate(endDate);
            report.setName(name);
            String mime = (String) CastorXmlTransformer.getContentTypes().get(type);
            report.setReportMime(mime);

            em.persist(report);
            em.flush();
            tx.commit();
        } catch (Exception ex) {
            tx.rollback();
            throw ex;
        }

        try {
            Parameters parameters = new Parameters();
            parameters.setDateEnd(new org.exolab.castor.types.Date(endDate));
            parameters.setDateStart(new org.exolab.castor.types.Date(startDate));
            parameters.setId(Integer.toString(report.getId().intValue()));
            parameters.setOrganization(organization.getName());
            parameters.setTimeStamp(new Date());

            MonitorReport mr = createMonitorReport();

            Long procTime = new Long(System.currentTimeMillis() - processStart);
            parameters.setProcessingTime(procTime.longValue());
            mr.setParameters(parameters);
            report.setProcessingTime(procTime);

            if (type.equalsIgnoreCase(CastorXmlTransformer.HTML)) {
                CastorXmlTransformer cxt = new CastorXmlTransformer(xsl, MyEMFDatabase.localPath());
                report.setReportXML(cxt.createHtml(mr));
            } else {
                CastorXmlTransformer cxt = new CastorXmlTransformer();
                report.setReportXML(cxt.createXml(mr));
            }
        } catch (Exception e) {
            StringBuffer rerror = new StringBuffer();
            rerror.append("<error>");
            rerror.append(e.getLocalizedMessage());

            StackTraceElement[] ste = e.getStackTrace();
            if (ste.length > 0) {
                rerror.append(" at ");
                rerror.append(ste[0].toString());
            }
            rerror.append("</error>");
            report.setReportXML(rerror.toString());
        }

        tx = em.getTransaction();
        tx.begin();
        try {
            em.merge(report);
            em.flush();
            tx.commit();
        } catch (Exception ex) {
            tx.rollback();
            throw ex;
        }
    } catch (Exception e) {
        log.error("", e);
    } finally {
        log.debug("Closing local entity manager ......");
        if (em != null && em.isOpen()) {
            em.close();
        }
        em = null;
    }
}

From source file:com.castis.xylophone.adsmadapter.convert.axistree.ConvertBannerAxisTreeDTO.java

public int mergeBannerTreeNode(Date date, ADSMSchedulerLogDTO schedulerLog, ADSMJobNameType srcJopType,
        String treeName, String publisher, Platform platformType) throws Exception {
    if (schedulerLog == null) {
        throw new CiRuntimeException("ADSMSchedulerLog is null");
    }/*  ww  w  . j  a  v  a 2s .co  m*/

    if (treeName == null || treeName.isEmpty()) {
        throw new CiRuntimeException("Cannot find treeName in generating MenuTree");
    }

    log.info("TreeName : " + treeName + ", srcDataType : " + srcJopType + ". Start Update("
            + schedulerLog.getParam() + ")");

    int treeID = 0;

    try {
        //?, , ,  ?
        //tambourineConnector.initializeInventoryCube(date);
        NodeDTO rootNodeDTO = getRootNode(ROOT_NODE_NAME);
        if (rootNodeDTO == null) {
            throw new CiRuntimeException("Fail to Update Banner Tree (Cannot Check root node Info. "
                    + schedulerLog.getParam() + ")");
        }

        treeID = tambourineConnector.getAxisTreeId(TreeType.BANNER_AXIS_TREE, treeName, publisher, platformType,
                false);
        //?
        if (treeID <= 0)
            treeID = tambourineConnector.generateTree(treeName, ROOT_NODE_NAME, TreeType.BANNER_AXIS_TREE,
                    publisher, platformType);

        List<ClientUIData> ClientUIDataList = tambourineConnector.getClientUIDataByType(ClientUIType.BANNER);

        int linkTreeId = -1;
        linkTreeId = makeTreeNode(treeID, date, rootNodeDTO.getExternalNodeId(), ClientUIDataList, publisher,
                platformType);

        tambourineConnector.insertTreeLogNSyncNoticeboard(linkTreeId, TreeType.BANNER_AXIS_TREE,
                Constants.tree.SCENE_TREE_NAME, null, publisher, platformType);
        tambourineConnector.insertTreeLogNSyncNoticeboard(treeID, TreeType.BANNER_AXIS_TREE,
                Constants.tree.BANNER_TREE_NAME, null, publisher, platformType);

        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);
        TheLogger.getWriter().info("Update Banner Tree Success");
    } catch (Exception e) {
        //log.error("",e);
        TheLogger.getWriter().error("Fail to Update Banner Tree");
        log.error("Fail to Update Banner Tree");
        schedulerLog.setMessage(e.getMessage());
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL);
        StackTraceElement[] stackTraces = e.getStackTrace();
        if (stackTraces.length > 0) {
            schedulerLog.setFailProcess(stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName()
                    + "(" + stackTraces[0].getLineNumber() + ")");
        }
        throw e;
    }
    return treeID;
}

From source file:org.apache.lucene.gdata.storage.lucenestorage.StorageImplementation.java

/**
 * @see org.apache.lucene.gdata.storage.Storage#deleteFeed(java.lang.String)
 *///from   w ww  . j av  a 2s.c om
public void deleteFeed(String feedId) throws StorageException {
    if (feedId == null)
        throw new StorageException("can not delete feed id is null ");
    ReferenceCounter<StorageQuery> query = null;
    try {
        query = this.controller.getStorageQuery();
        if (!query.get().isFeedStored(feedId))
            throw new StorageException("Account does not exist");
        StorageModifier modifier = this.controller.getStorageModifier();

        modifier.deleteFeed(feedId);

    } catch (Exception e) {
        LOG.error("Can't delete feed -- " + e.getMessage(), e);
        StorageException ex = new StorageException("Can't create feed -- " + e.getMessage(), e);
        ex.setStackTrace(e.getStackTrace());
        throw ex;

    } finally {
        if (query != null)
            query.decrementRef();
    }
}