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.castis.xylophone.adsmadapter.connectors.TambourineConnector.java

public boolean insertRegionData(List<RegionDataDTO> regionDataList, ADSMSchedulerLogDTO schedulerLog,
        String resultDir, String dataFileName) {
    boolean result = false;

    try {/*from   w ww.j  a v a 2  s .c o m*/
        inventoryExportSysCompForAdapter.insertRegionDataList(regionDataList, schedulerLog);
        schedulerLog.setSchedulerStatus(ADSMSchedulerStatus.SUCCESS);
        result = true;
        ResultFileUtil.writeResultFile(dataFileName,
                "? ?  . [size:" + regionDataList.size() + "]",
                FileResultCode.RESULT_OK.getValue(), resultDir, InputDataType.INVENTORY_DAT);
    } catch (Exception e) {
        //log.error("",e);
        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() + ")");
        }
        result = false;
        ResultFileUtil.writeResultFile(dataFileName, e.getMessage(), FileResultCode.RESULT_FAIL.getValue(),
                resultDir, InputDataType.INVENTORY_DAT);
    }

    return result;
}

From source file:com.esri.geoevent.solutions.adapter.cot.CoTAdapterInbound.java

@Override
public void afterPropertiesSet() {
    try {//from www.  j  a  va  2 s.  co m
        if (hasProperty(CoTAdapterServiceInbound.MAXIMUM_BUFFER_SIZE_LABEL)) {
            Property bufSizeProperty = getProperty(CoTAdapterServiceInbound.MAXIMUM_BUFFER_SIZE_LABEL);
            if (bufSizeProperty != null) {
                int maxBufferSize = (Integer) bufSizeProperty.getValue();
                if (maxBufferSize <= 0) {
                    log.error("Cannot set the maximum buffer size to " + maxBufferSize);
                } else
                    this.setMaxBufferSize(maxBufferSize);
            }
        }
        if (hasProperty(CoTAdapterServiceInbound.COT_TYPES_PATH_LABEL)) {
            Property cotTypesPathProperty = getProperty(CoTAdapterServiceInbound.COT_TYPES_PATH_LABEL);
            if (cotTypesPathProperty != null) {
                String userDefinedPath = cotTypesPathProperty.getValueAsString();
                if (userDefinedPath != null && (!userDefinedPath.equals(""))) {
                    try {
                        this.coTTypeMap = CoTUtilities.getCoTTypeMap(
                                new FileInputStream(((Property) cotTypesPathProperty).getValueAsString()));
                        log.info("CotTypes.xml path will be set to: " + userDefinedPath);
                    } catch (Exception e) {
                        this.coTTypeMap = null;
                        log.error("Problem loading the user-specified CoTTypes.xml file.", e);
                    }
                }
            }
        }
        if (this.coTTypeMap == null) {
            try {
                String defaultPath = "CoTTypes/CoTtypes.xml";
                this.coTTypeMap = CoTUtilities
                        .getCoTTypeMap(this.getClass().getClassLoader().getResourceAsStream(defaultPath));
                log.info("Default CoTtypes.xml definitions were loaded successfully.");
            } catch (Exception e1) {
                log.error("Problem loading the default CoTTypes.xml file.", e1);
            }
        }
    } catch (Exception e) {
        log.error(e);
        log.error(e.getStackTrace());
    }
}

From source file:com.iiordanov.runsoft.bVNC.RemoteCanvas.java

/**
 * Starts a VNC connection using the TightVNC backend.
 * @throws Exception/*from ww w.  jav  a2s.c om*/
 */
private void startVncConnection() throws Exception {
    Log.i(TAG, "Connecting to: " + connection.getAddress() + ", port: " + connection.getPort());
    String address = getAddress();
    int vncPort = getPort(connection.getPort());
    boolean sslTunneled = connection.getConnectionType() == Constants.CONN_TYPE_STUNNEL;

    try {
        rfb = new RfbProto(decoder, this, address, vncPort, connection.getPrefEncoding(),
                connection.getViewOnly(), connection.getUseLocalCursor(), sslTunneled,
                connection.getIdHashAlgorithm(), connection.getIdHash(), connection.getSshHostKey());
        Log.v(TAG, "Connected to server: " + address + " at port: " + vncPort);
        rfb.initializeAndAuthenticate(connection.getUserName(), connection.getPassword(),
                connection.getUseRepeater(), connection.getRepeaterId(), connection.getConnectionType(),
                connection.getSshHostKey());
    } catch (Exception e) {
        throw new Exception(getContext().getString(R.string.error_vnc_unable_to_connect)
                + e.getStackTrace().toString() + e.getLocalizedMessage());
    }

    rfbconn = rfb;
    pointer = new RemoteVncPointer(rfbconn, RemoteCanvas.this, handler);
    keyboard = new RemoteVncKeyboard(rfbconn, RemoteCanvas.this, handler);

    rfb.writeClientInit();
    rfb.readServerInit();
    initializeBitmap(displayWidth, displayHeight);
    decoder.setPixelFormat(rfb);

    handler.post(new Runnable() {
        public void run() {
            pd.setMessage(getContext().getString(R.string.info_progress_dialog_downloading));
        }
    });

    sendUnixAuth();
    if (connection.getUseLocalCursor())
        initializeSoftCursor();

    handler.post(drawableSetter);
    handler.post(setModes);
    handler.post(desktopInfo);

    // Hide progress dialog
    if (pd.isShowing())
        pd.dismiss();

    sendBroadcastConnected();
    rfb.processProtocol();

}

From source file:org.apache.jsp.sources_jsp.java

private void saveShareAsTemplate(HttpServletRequest request, HttpServletResponse response) {
       try {/*from  ww  w  .  j a  v  a 2s  .c  o  m*/
           String urlShareTitle = URLEncoder.encode(shareTitle + " - Template", "UTF-8");
           String urlShareDescription = URLEncoder.encode(shareDescription, "UTF-8");
           String apiAddress = "social/share/add/json/source_template/" + urlShareTitle + "/"
                   + urlShareDescription;

           JSONObject JSONresponse = new JSONObject(postToRestfulApi(apiAddress, sourceJson, request, response))
                   .getJSONObject("response");
           if (JSONresponse.getString("success").equalsIgnoreCase("true")) {
               messageToDisplay = "Success: " + JSONresponse.getString("message");
           } else {
               messageToDisplay = "Error: " + JSONresponse.getString("message");
           }
       } catch (Exception e) {
           messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString();
       }
   }

From source file:org.apache.jsp.sources_jsp.java

private void deleteShare(String shareId, HttpServletRequest request, HttpServletResponse response) {
       if (shareId != null && shareId != "") {
           JSONObject source = getSourceJSONObjectFromShare(shareId, request, response);
           String apiAddress = "social/share/remove/" + shareId + "/";
           try {// ww w. java  2s  . co m
               JSONObject JSONresponse = new JSONObject(callRestfulApi(apiAddress, request, response))
                       .getJSONObject("response");
               if (JSONresponse.getString("success").equalsIgnoreCase("true")) {
                   messageToDisplay = "Success: " + JSONresponse.getString("message");
               } else {
                   messageToDisplay = "Error: " + JSONresponse.getString("message");
               }
           } catch (Exception e) {
               messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString();
           }
       }
   }

From source file:org.apache.jsp.sources_jsp.java

private void deleteSourceObject(String sourceId, boolean bDocsOnly, HttpServletRequest request,
           HttpServletResponse response) {
       if (sourceId != null && sourceId != "") {
           try {//ww  w.  j a va 2s  . c  om
               JSONObject sourceResponse = new JSONObject(getSource(sourceId, request, response));
               JSONObject source = new JSONObject(sourceResponse.getString("data"));
               JSONArray com = source.getJSONArray("communityIds");
               String tempCommunityId = com.getString(0);

               JSONObject JSONresponse = new JSONObject(
                       deleteSource(sourceId, bDocsOnly, tempCommunityId, request, response))
                               .getJSONObject("response");

               if (JSONresponse.getString("success").equalsIgnoreCase("true")) {
                   messageToDisplay = "Success: " + JSONresponse.getString("message");
               } else {
                   messageToDisplay = "Error: " + JSONresponse.getString("message");
               }
           } catch (Exception e) {
               messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString();
           }
       }
   }

From source file:org.apache.jsp.sources_jsp.java

private void publishSource(HttpServletRequest request, HttpServletResponse response) {
       try {//from www . j a v a  2  s  .c o  m
           // CommunityID Array - Delete and replace with id from community id dropdown list
           if (communityId.length() > 0) {
               JSONObject source = new JSONObject(sourceJson);
               source.remove("communityIds");
               JSONArray communityIds = new JSONArray();
               communityIds.put(communityId);
               source.put("communityIds", communityIds);
               sourceJson = source.toString(4);
           } //TESTED

           String sourceApiString = "config/source/save/" + communityId;

           // Post the update to our rest API and check the results of the post
           JSONObject result = new JSONObject(postToRestfulApi(sourceApiString, sourceJson, request, response));
           JSONObject JSONresponse = result.getJSONObject("response");

           if (JSONresponse.getString("success").equalsIgnoreCase("true")) {
               messageToDisplay = "Success: " + JSONresponse.getString("message");
               // Delete the share object - shareId
               String apiAddress = "social/share/remove/" + shareid;

               // Post the update to our rest API and check the results of the post
               JSONObject shareResponse = new JSONObject(callRestfulApi(apiAddress, request, response))
                       .getJSONObject("response");
               if (shareResponse.getString("success").equalsIgnoreCase("true")) {
                   messageToDisplay += " (" + shareResponse.getString("message") + ")";
               } else {
                   messageToDisplay += " (" + shareResponse.getString("message") + ")";
               }
           } else {
               messageToDisplay = "Error: " + JSONresponse.getString("message");
           }
       } catch (Exception e) {
           messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString();
       }
   }

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

public boolean verifyTotalECUHR(TestParameters input) throws InterruptedException {
    final int MAX_WAIT = 50;
    try {/*  w  w  w. ja v  a  2  s  . co  m*/
        // ValidECU(input);
        // jsx.executeScript("document.getElementById('calculate').click()");
        // jsx.executeScript("document.getElementById('purchaseTab').click()");
        driver.findElement(By.xpath("/window[1]/UIAKey[1]/scrollview[1]/webview[1]/link[2]")).click();
        driver.findElement(By.xpath(" //window[1]/UIAKey[1]/scrollview[1]/webview[1]/button[1]")).click(); // purchase

        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.CostSolution_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("cos"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.AdditionalInfra_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE)).enterText(input.getParamMap().get("ai"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.CAS_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("cas"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.OSLicensing_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("osl"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.Depriciation_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("depri"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.Power_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("power"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.ITMgmt_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("itmgmt"));
        ((TextBox) webPage.findObject(ObjectType.TextBox, MainPageElements_iphone.NetworkFee_XPATH,
                ObjectValType.XPATH, MAX_WAIT, WaitCondition.VISIBLE))
                        .enterText(input.getParamMap().get("ntwkfee"));
        float CAPEX = Float.parseFloat(
                webDriver.findElement(By.xpath(MainPageElements_iphone.CAPEXHR_XPATH)).getAttribute("value"));
        float OPEX = Float.parseFloat(
                webDriver.findElement(By.xpath(MainPageElements_iphone.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_iphone.TOTALECUHR_XPATH)).getText());
        System.out.println(totalECUHR);
        if (df.format(totalecuhr).equalsIgnoreCase(df.format(totalECUHR))) {
            return true;
        }
    } catch (Exception e) {
        log.error(e.getMessage());
        System.err.println(e.getCause() + "              " + e.getStackTrace());
    }
    return false;
}

From source file:net.nan21.dnet.core.web.controller.AbstractDnetController.java

/**
 * Generic exception handler//from www.  j av a  2s. c  om
 * 
 * @param e
 * @param response
 * @return
 * @throws IOException
 */
@ExceptionHandler(value = Exception.class)
@ResponseBody
protected String handleException(Exception e, HttpServletResponse response) throws IOException {

    e.printStackTrace();

    if (e instanceof NotAuthorizedRequestException) {
        return this.handleException((NotAuthorizedRequestException) e, response);
    } else if (e instanceof InvocationTargetException) {
        StringBuffer sb = new StringBuffer();
        if (e.getMessage() != null) {
            sb.append(e.getMessage() + "\n");
        }
        Throwable exc = ((InvocationTargetException) e).getTargetException();

        if (exc.getMessage() != null) {
            sb.append(exc.getMessage() + "\n");
        }

        if (exc.getCause() != null) {
            if (sb.length() > 0) {
                sb.append(" Reason: ");
            }
            sb.append(exc.getCause().getLocalizedMessage());
        }

        exc.printStackTrace();
        response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
        response.getOutputStream().print(sb.toString());
        return null;
    }
    StringBuffer sb = new StringBuffer();
    if (e.getLocalizedMessage() != null) {
        sb.append(e.getLocalizedMessage());
    } else if (e.getCause() != null) {
        if (sb.length() > 0) {
            sb.append(" Reason: ");
        }
        sb.append(e.getCause().getLocalizedMessage());
    }
    if (sb.length() == 0) {
        if (e.getStackTrace() != null) {
            response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
            e.printStackTrace(response.getWriter());
            return null;
        }
    }
    response.setStatus(HttpStatus.EXPECTATION_FAILED.value());
    response.getOutputStream().print(sb.toString());
    response.getOutputStream().flush();
    return null;

}

From source file:org.apache.jsp.sources_jsp.java

private void saveShare(HttpServletRequest request, HttpServletResponse response) {
       try {/*  www.  j  a  v  a 2s  .  co m*/
           String oldId = formShareId;

           String apiAddress = "";
           String urlShareTitle = URLEncoder.encode(shareTitle.trim(), "UTF-8");
           String urlShareDescription = URLEncoder.encode(shareDescription.trim(), "UTF-8");

           if (oldId != null) {
               apiAddress = "social/share/update/json/" + oldId + "/source/" + urlShareTitle + "/"
                       + urlShareDescription;
           } else {
               apiAddress = "social/share/add/json/source/" + urlShareTitle + "/" + urlShareDescription;
           }

           //
           JSONObject source = new JSONObject(sourceJson);
           source.remove("title");
           source.put("title", shareTitle.trim());
           source.remove("description");
           source.put("description", shareDescription.trim());

           // CommunityID Array - Delete and replace with id from community id dropdown list
           if (communityId.length() > 0) {
               source.remove("communityIds");
               JSONArray communityIds = new JSONArray();
               communityIds.put(communityId);
               source.put("communityIds", communityIds);
               sourceJson = source.toString(4);
           } //TESTED

           // Post the update to our rest API and check the results of the post
           JSONObject json_response = new JSONObject(postToRestfulApi(apiAddress, sourceJson, request, response))
                   .getJSONObject("response");
           if (json_response.getString("success").equalsIgnoreCase("true")) {
               messageToDisplay = "Success: " + json_response.getString("message");
           } else {
               messageToDisplay = "Error: " + json_response.getString("message");
           }
       } catch (Exception e) {
           messageToDisplay = "Error: " + e.getMessage() + " " + e.getStackTrace().toString();
       }
   }