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:co.forsaken.api.json.JsonWebCall.java

public <T> void execute(Class<T> callbackClass, Callback<T> callback, Object arg) {
    if (_log)/*from  w  w  w  .  j a v  a  2  s.  c  o m*/
        System.out.println("Requested: [" + _url + "]");
    try {
        canConnect();
    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
    HttpClient httpClient = new DefaultHttpClient(_connectionManager);
    InputStream in = null;
    String res = null;

    try {
        Gson gson = new Gson();
        HttpPost request = new HttpPost(_url);
        if (arg != null) {
            StringEntity params = new StringEntity(gson.toJson(arg));
            params.setContentType(new BasicHeader("Content-Type", "application/json"));
            request.setEntity(params);
        }
        HttpResponse response = httpClient.execute(request);
        if (response != null) {
            in = response.getEntity().getContent();

            res = convertStreamToString(in);
            if (_log)
                System.out.println("Returned: [" + _url + "] [" + res + "]");
            callback.run(new Gson().fromJson(res, callbackClass));
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.out.println("JSONWebCall.execute() Error: \n" + ex.getMessage());
        System.out.println("Result: \n" + res);
        StackTraceElement[] arrOfSTE;
        int max = (arrOfSTE = ex.getStackTrace()).length;
        for (int i = 0; i < max; i++) {
            StackTraceElement trace = arrOfSTE[i];
            System.out.println(trace);
        }
    } finally {
        httpClient.getConnectionManager().shutdown();
        if (in != null) {
            try {
                in.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}

From source file:ait.ffma.service.preservation.riskmanagement.TestLODFreebaseRetrieve.java

/**
 * This method initializes extensions list aggregated from all LOD repositories.
 *///w  w  w  . ja va 2  s . c om
private void initFileFormatListFromAllRepositories() {
    PronomFileFormat pronomFileFormat = new PronomFileFormat();
    pronomFileFormat.setFfmaObjectName(PronomFileFormat.class.getSimpleName());
    DBPediaFileFormat dbpediaFileFormat = new DBPediaFileFormat();
    dbpediaFileFormat.setFfmaObjectName(DBPediaFileFormat.class.getSimpleName());
    FreebaseFileFormat freebaseFileFormat = new FreebaseFileFormat();
    freebaseFileFormat.setFfmaObjectName(FreebaseFileFormat.class.getSimpleName());

    try {
        CommonApiServerConfigurationImpl commonApiServerConfiguration = new CommonApiServerConfigurationImpl();
        commonApiServerConfiguration.init();
        MongoDbManager mongoDbManager = new MongoDbManager();
        mongoDbManager.setCommonApiServerConfiguration(commonApiServerConfiguration);
        FfmaAbstractFactoryImpl objectFactory = new FfmaAbstractFactoryImpl();
        mongoDbManager.setObjectFactory(objectFactory);
        mongoDbManager.init();
        DataStoreDaoImpl dataStoreDao = new DataStoreDaoImpl();
        dataStoreDao.setMongoDbManager(mongoDbManager);

        List<String> exclusionsList = new ArrayList<String>();
        exclusionsList.add(RiskConstants.DOMAIN_OBJECT_NAME);
        List<? extends FfmaDomainObject> fileFormats = dataStoreDao
                .retrieveCollection((FfmaDomainObject) pronomFileFormat, exclusionsList);
        List<? extends FfmaDomainObject> dbpediaFileFormats = dataStoreDao
                .retrieveCollection((FfmaDomainObject) dbpediaFileFormat, exclusionsList);
        List<? extends FfmaDomainObject> freebaseFileFormats = dataStoreDao
                .retrieveCollection((FfmaDomainObject) freebaseFileFormat, exclusionsList);

        List<DipFormatId> pronomFileFormatList = LODUtils.getPronomDipFileFormatsList(fileFormats);
        List<DipFormatId> dbpediaFileFormatList = LODUtils.getDBPediaDipFileFormatsList(dbpediaFileFormats);
        List<DipFormatId> freebaseFileFormatList = LODStatisticsFreebaseUtils
                .getFreebaseDipFileFormatsList(freebaseFileFormats);
        aggregateFileFormats(pronomFileFormatList);
        aggregateFileFormats(dbpediaFileFormatList);
        aggregateFileFormats(freebaseFileFormatList);
        log.info("extensionsList size: " + fileFormatList.size());
    } catch (Exception e) {
        fail("Caught ObjectNotRetrievedException error: " + e + e.getStackTrace());
    }
}

From source file:edu.cornell.kfs.fp.batch.service.impl.AdvanceDepositServiceImpl.java

private void logException(Exception e) {
    if (e instanceof ValidationException) {
        List<String> errors = GlobalVariablesUtils.extractGlobalVariableErrors();
        if (ObjectUtils.isNotNull(errors) && !errors.isEmpty()) {
            for (String errorMessage : errors) {
                LOG.error(errorMessage);
            }//from   ww w . j a v a 2  s.c  o m
        }
    } else {
        LOG.error(e.getStackTrace());
    }
}

From source file:com.etouch.cisco.common.CiscoMainPage.java

public boolean verifyTotalECUHR(TestParameters input) throws InterruptedException {
    final int MAX_WAIT = 50;
    try {/*from   www . j  a va 2 s  .  c o m*/
        ValidECU(input);
        jsx.executeScript("document.getElementById('calculate').click()");
        jsx.executeScript("document.getElementById('purchaseTab').click()");
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.CostSolution_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("cos"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.AdditionalInfra_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("ai"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.CAS_XPATH, ObjectValType.XPATH,
                MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("cas"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.OSLicensing_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("osl"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.Depriciation_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("depri"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.Power_XPATH, ObjectValType.XPATH,
                MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("power"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.ITMgmt_XPATH, ObjectValType.XPATH,
                MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("itmgmt"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements.NetworkFee_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("ntwkfee"));
        float CAPEX = Float.parseFloat(
                webDriver.findElement(By.xpath(MainPageElements.CAPEXHR_XPATH)).getAttribute("value"));
        float OPEX = Float.parseFloat(
                webDriver.findElement(By.xpath(MainPageElements.OPEXHR_XPATH)).getAttribute("value"));
        float capexecuhr = CAPEX / totalECU;
        float opexecuhr = OPEX / totalECU;
        float totalecuhr = capexecuhr + opexecuhr;

        System.out.println(Math.floor(totalecuhr * 10000 + .5) / 10000);
        float totalECUHR = Float
                .parseFloat(webDriver.findElement(By.xpath(MainPageElements.TOTALECUHR_XPATH)).getText());
        System.out.println(totalECUHR);
        if (df.format(totalecuhr).equalsIgnoreCase(df.format(totalECUHR))) {
            return true;
        }
    } catch (Exception e) {
        log.error(getErrMessage());
        System.err.println(e.getCause() + "              " + e.getStackTrace());
    }
    return false;
}

From source file:base.BasePlayer.ClusterTable.java

void getAminos(ClusterNode transcript) {

    try {/*from w w w .ja v a2 s  . c  om*/
        aminoarray.clear();
        VarNode varnode = null;

        for (int t = 0; t < transcript.varnodes.size(); t++) {

            if (Main.drawCanvas.hideNode(transcript.varnodes.get(t))) {

                continue;
            }

            varnode = transcript.varnodes.get(t);

            for (int v = 0; v < varnode.vars.size(); v++) { // Map.Entry<String, ArrayList<SampleNode>> entry : varnode.vars) {
                entry = varnode.vars.get(v);
                mutcount = 0;
                if (Main.drawCanvas.hideNodeVar(varnode, entry)) {
                    continue;
                }
                for (int m = 0; m < entry.getValue().size(); m++) {
                    if (entry.getValue().get(m).alleles != null) {
                        break;
                    }
                    if (!Main.drawCanvas.hideVar(entry.getValue().get(m), entry.getKey().length() > 1)) {
                        mutcount++;
                    } else {
                        entry.getValue().remove(m);
                        m--;
                    }
                }

                if (mutcount == 0) {
                    continue;
                }
                if (varnode.getTranscripts() != null) {
                    if (!chrom.equals(varnode.getTranscripts().get(0).getChrom())) {
                        chrom = varnode.getTranscripts().get(0).getChrom();
                    }
                } else {
                    if (!chrom.equals(varnode.getExons().get(0).transcript.getChrom())) {
                        chrom = varnode.getExons().get(0).transcript.getChrom();
                    }
                }
                base = entry.getKey();
                String[] addrow = new String[6];
                addrow[0] = "" + transcript.ID;
                addrow[1] = "" + mutcount;
                addrow[2] = chrom + ":" + MethodLibrary.formatNumber((varnode.getPosition() + 1));
                if (base.length() == 1) {
                    addrow[3] = "" + Main.getBase.get(varnode.getRefBase()) + ">" + base;
                } else {
                    addrow[3] = base;
                }
                if (varnode.isRscode() != null) {
                    addrow[4] = varnode.rscode;
                } else {
                    addrow[4] = "N/A";
                }
                addrow[5] = base;

                AminoEntry aminoentry = new AminoEntry(addrow, varnode);

                aminoarray.add(aminoentry);

                //   aminoarray.add(new Entry(vardraw.getExons().get(0).getTranscript().getGenename() +" " +vardraw.getPosition() +" " +baseTemp.get(base) +" " +Main.chromDraw.getAminoChange(vardraw,base,vardraw.getExons().get(exon), true), vardraw));

            }

        }
        varnode = null;
    } catch (Exception e) {
        ErrorLog.addError(e.getStackTrace());
        e.printStackTrace();
    }

}

From source file:com.konakart.actions.BaseAction.java

/**
 * Returns a string containing the stack trace of the exception and its cause
 * /*from w  w  w. j  av  a 2 s  . c  o  m*/
 * @param e
 * @return Returns a string containing the stack trace
 */
private String getExceptionMessage(Exception e, boolean full) {
    StringBuffer sb = new StringBuffer();

    // Get the stack trace of the exception
    sb.append("<br>Exception Name = ");
    sb.append(e.getClass().getName());
    sb.append("<br>Exception Message = ");
    String msg = e.getMessage();
    if (msg == null || msg.equalsIgnoreCase("null")) {
        msg = "No further details available";
    } else {
        msg = StringEscapeUtils.escapeHtml(msg);
    }
    sb.append(msg);

    if (log.isDebugEnabled() || full) {
        sb.append("<br>Exception Stack Trace = ");
        StackTraceElement[] ste = e.getStackTrace();
        for (int i = 0; i < ste.length; i++) {
            sb.append("<br>   at ");
            sb.append(ste[i].toString());
        }

        // Get the stack trace of the exception cause
        Throwable eCause = e.getCause();
        if (eCause != null) {
            sb.append("<br><br>Exception Cause = ");
            sb.append(eCause.getClass().getName());
            StackTraceElement[] ste1 = eCause.getStackTrace();
            for (int i = 0; i < ste1.length; i++) {
                sb.append("<br>   at ");
                sb.append(ste1[i].toString());
            }
        }
    }

    return sb.toString();
}

From source file:com.ut.healthelink.errorHandling.ExceptionControllerAdvice.java

@ExceptionHandler(Exception.class)
public ModelAndView exception(HttpSession session, Exception e, Authentication authentication)
        throws Exception {

    ModelAndView mav = new ModelAndView();
    mav.setViewName("/exception");

    mailMessage messageDetails = new mailMessage();

    messageDetails.settoEmailAddress("dphuniversaltranslator@gmail.com");
    messageDetails.setfromEmailAddress("dphuniversaltranslator@gmail.com");
    messageDetails.setmessageSubject("Exception Error " + InetAddress.getLocalHost().getHostAddress());

    StringBuilder sb = new StringBuilder();

    /* If a user is logged in then send along the user details */
    if (session.getAttribute("userDetails") != null || authentication != null) {
        User userInfo = (User) session.getAttribute("userDetails");

        if (userInfo == null && authentication != null) {
            // see if it is an admin that is logged in
            userInfo = usermanager.getUserByUserName(authentication.getName());
        }/* w ww  . j  av  a 2s  .  c o  m*/
        if (userInfo != null) {
            sb.append("Logged in User: " + userInfo.getFirstName() + " " + userInfo.getLastName() + " (ID: "
                    + userInfo.getId() + ")");
            sb.append(System.getProperty("line.separator"));
            sb.append("User OrgId: " + userInfo.getOrgId());
            sb.append(System.getProperty("line.separator"));
        }
    }

    sb.append("Error: " + e);
    sb.append("<br /><br />");
    sb.append("Time: " + new Date());
    sb.append("<br /><br />");
    sb.append("Message: " + e.getMessage());
    sb.append("<br /><br />");
    sb.append("Stack Trace: " + Arrays.toString(e.getStackTrace()));

    messageDetails.setmessageBody(sb.toString());
    emailMessageManager.sendEmail(messageDetails);
    /*mav.addObject("messageBody",sb.toString());*/

    return mav;
}

From source file:com.castis.xylophone.adsmadapter.connectors.TambourineConnector.java

public boolean insertOttData(List<ChannelServiceDTO> channelInfoList, ADSMSchedulerLogDTO schedulerLog,
        String resultDirectory, String fileName, InputDataType inputDataType, ADSMJobNameType jobType) {
    boolean result = false;
    try {/*  w  ww  .  jav a 2 s. c o  m*/
        inventoryExportSysCompForAdapter.insertOttData(channelInfoList, schedulerLog, jobType);

        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);
        result = true;
        ResultFileUtil.writeResultFile(fileName,
                "? ?  . [size:" + channelInfoList.size() + "]",
                FileResultCode.RESULT_OK.getValue(), resultDirectory, inputDataType);
    } catch (Exception e) {
        schedulerLog.setMessage(e.getMessage());
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL);
        StackTraceElement[] stackTraces = e.getStackTrace();
        if (stackTraces.length > 0) {
            String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "("
                    + stackTraces[0].getLineNumber() + ")";

            schedulerLog.setFailProcess(failProcess);
        }
        result = false;
        ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(),
                resultDirectory, inputDataType);
    }
    return result;
}

From source file:com.castis.xylophone.adsmadapter.connectors.TambourineConnector.java

public boolean insertChannelData(List<ChannelServiceDTO> channelInfoList, ADSMSchedulerLogDTO schedulerLog,
        String resultDir, String fileName, InputDataType inputDataType, ADSMJobNameType jobType) {
    boolean result = false;
    try {/*w  w  w  .ja v  a  2  s  . c o m*/
        inventoryExportSysCompForAdapter.insertChannelDataList(channelInfoList, schedulerLog, jobType);

        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);
        result = true;
        ResultFileUtil.writeResultFile(fileName,
                "? ?  . [size:" + channelInfoList.size() + "]",
                FileResultCode.RESULT_OK.getValue(), resultDir, inputDataType);
    } catch (Exception e) {
        schedulerLog.setMessage(e.getMessage());
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL);
        StackTraceElement[] stackTraces = e.getStackTrace();
        if (stackTraces.length > 0) {
            String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "("
                    + stackTraces[0].getLineNumber() + ")";

            schedulerLog.setFailProcess(failProcess);
        }
        result = false;
        ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(),
                resultDir, inputDataType);
    }

    return result;
}

From source file:com.castis.xylophone.adsmadapter.connectors.TambourineConnector.java

@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public boolean insertChannelScheduleInfoList(List<ChannelScheduleInfoDTO> channelScheduleInfoDTOList,
        ADSMSchedulerLogDTO schedulerLog, String resultDirectory, String fileName, InputDataType inputDataType,
        ADSMJobNameType jobType) {//w  w w  .  j  av a  2  s . c o  m
    boolean result = false;
    try {
        List<ChannelScheduleInfo> channelScheduleInfoList = new ArrayList<ChannelScheduleInfo>();
        for (ChannelScheduleInfoDTO channelScheduleInfoDTO : channelScheduleInfoDTOList) {
            String channelId = channelScheduleInfoDTO.getChannelId();
            List<Date> dateList = channelScheduleInfoDTO.getScheduleTime();
            for (Date date : dateList) {
                channelScheduleInfoList.add(new ChannelScheduleInfo(channelId, date));
            }
        }
        channelBizComp.replaceChannelScheduleInfoList(channelScheduleInfoList);

        PlacementOpportunityTypeEnum oppType = PlacementOpportunityTypeEnum.PREROLL;
        InventoryType inventoryType = InventoryType.CUETONE;
        Platform platformType = Platform.STB;
        String param = "oppType:" + oppType.toString() + "/inventoryType:" + inventoryType.toString()
                + "/plaformType:" + platformType.toString() + "/fileName:" + fileName;
        FeSyncNoticeboardDTO feSyncNoticeboardDTO = generateFeSyncNoticeboardData(SyncDataType.SCHEDULE,
                new Date(), param, null, FeSyncNoticeboardStatus.NEWDATA, platformType, inventoryType, oppType);
        //         feSyncNoticeboardDTO.setOpportunityType(oppType);
        //         feSyncNoticeboardDTO.setInventoryType(inventoryType);
        //         feSyncNoticeboardDTO.setPlatform(platformType);         
        //feSyncNoticeboardDTO.setStatus(FeSyncNoticeboardStatus.NEWDATA);
        //Timestamp timestamp = new Timestamp(new Date().getTime()); 
        //feSyncNoticeboardDTO.setSyncStartTime(timestamp);
        feSyncNoticeboardDTO = insertSyncNoticeboard(feSyncNoticeboardDTO);

        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);

        result = true;
        ResultFileUtil.writeResultFile(fileName,
                "? ?  . [size:" + channelScheduleInfoList.size() + "]",
                FileResultCode.RESULT_OK.getValue(), resultDirectory, inputDataType);

    } catch (Exception e) {
        schedulerLog.setMessage(e.getMessage());
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.FAIL);
        StackTraceElement[] stackTraces = e.getStackTrace();
        if (stackTraces.length > 0) {
            String failProcess = stackTraces[0].getClassName() + " - " + stackTraces[0].getMethodName() + "("
                    + stackTraces[0].getLineNumber() + ")";

            schedulerLog.setFailProcess(failProcess);
        }
        result = false;
        ResultFileUtil.writeResultFile(fileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(),
                resultDirectory, inputDataType);
    }
    return result;
}