Example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getStackTrace.

Prototype

public static String getStackTrace(final Throwable throwable) 

Source Link

Document

Gets the stack trace from a Throwable as a String.

The result of this method vary by JDK version as this method uses Throwable#printStackTrace(java.io.PrintWriter) .

Usage

From source file:com.aurel.track.persist.TDepartmentPeer.java

/**
 * Loads a TDepartmentBean by primary key
 * @param departmentID// w w  w  .j  a va2 s.  c o m
 * @return
 */
@Override
public TDepartmentBean loadByPrimaryKey(Integer departmentID) {
    TDepartment tDepartment = null;
    try {
        tDepartment = retrieveByPK(departmentID);
    } catch (Exception e) {
        LOGGER.warn(
                "Loading of a department by primary key " + departmentID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tDepartment != null) {
        return tDepartment.getBean();
    }
    return null;
}

From source file:com.aurel.track.persist.TWorkflowActivityPeer.java

@Override
public TWorkflowActivityBean loadByPrimaryKey(Integer objectID) {
    TWorkflowActivity tobject = null;/*from  w w w  . ja v a 2s . com*/
    try {
        tobject = retrieveByPK(objectID);
    } catch (Exception e) {
        LOGGER.warn(
                "Loading of a workflow activity by primary key " + objectID + " failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (tobject != null) {
        return tobject.getBean();
    }
    return null;
}

From source file:com.qwazr.server.ServerException.java

public WebApplicationException getHtmlException(boolean withStackTrace) {
    final String message = getMessage();
    final StringBuilder sb = new StringBuilder();
    sb.append("<html><body><h2>Error ");
    sb.append(statusCode);/*from  w  w  w . ja  va 2s  . com*/
    sb.append("</h2>\n<p><pre><code>\n");
    sb.append(message);
    sb.append("\n</code></pre></p>");
    if (withStackTrace) {
        sb.append("<p><pre><code>\n");
        sb.append(ExceptionUtils.getStackTrace(this));
        sb.append("\n</code></pre></p>\n</body></html>");
    }
    final Response response = Response.status(statusCode).type(MediaType.TEXT_HTML).entity(sb.toString())
            .build();
    return new WebApplicationException(message, this, response);
}

From source file:com.aurel.track.struts2.interceptor.GuestLoginInterceptor.java

@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
    //get the actual request
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();
    //force the creation of a new session if it does not exist yet
    request.getSession();//from  w  w  w .j  av a 2  s  .c  om
    Map<String, Object> session = actionInvocation.getInvocationContext().getSession();
    //if session is new set the newly created session map into the Action context
    //(instead of null). Otherwise the SessionAware interface sets the wrong session object
    //which does not contain the session attributes (user, etc.)
    if (session == null || session.isEmpty()) {
        session = new SessionMap(ServletActionContext.getRequest());
        ActionContext.getContext().setSession(session);
    }
    TPersonBean personBean = (TPersonBean) session.get(Constants.USER_KEY);
    if (personBean == null && ApplicationBean.getInstance().getSiteBean() != null) {
        if (!BypassLoginHelper.loginAsGuest(request, session)) {
            boolean fromAjax = false;
            try {
                fromAjax = "true".equalsIgnoreCase(request.getParameter("fromAjax"));
            } catch (Exception ex) {
                LOGGER.error(ExceptionUtils.getStackTrace(ex));
            }
            if (fromAjax) {
                Locale locale = (Locale) session.get(Constants.LOCALE_KEY);
                if (locale == null) {
                    locale = Locale.getDefault();
                }
                JSONUtility.encodeJSONFailure(response,
                        LocalizeUtil.getLocalizedTextFromApplicationResources("common.noLoggedUser", locale),
                        JSONUtility.ERROR_CODE_NO_USER_LOGIN);
                return null;
            }
            AuthenticationBL.storeUrlOnSession(request, session);
            return "logon";//TODO rename to Action.LOGIN;
        }
    }
    if (LOGGER.isDebugEnabled()) {
        return ActionLogBL.logActionTime(actionInvocation, LOGGER);
    } else {
        return actionInvocation.invoke();
    }
}

From source file:io.stallion.jobs.JobInstanceDispatcher.java

@Override
public void run() {
    Log.info("Try to lock job for run {0}", definition.getName());
    boolean locked = JobStatusController.instance().lockJob(definition.getName());
    if (!locked) {
        Log.warn("Job is locked, skipping run command. {0}", definition.getName());
        return;/*from w w  w  . j av  a 2  s .  co m*/
    }
    if (JobStatusController.instance().isJobReadyToRun(definition, this.now)) {
        Log.warn("Job nextexecuteminutestamp time has not arrived. Not executing.");
        return;
    }
    Log.info("Job locked, execute now {0}", definition.getName());
    // Retrieve the status from the store to make sure we have the up-to-date version
    status = JobStatusController.instance().getOrCreateForName(definition.getName());
    status.setStartedAt(DateUtils.mils());
    JobStatusController.instance().save(status);

    try {
        // Run the job
        job.execute();
        status.setCompletedAt(DateUtils.mils());
        status.setFailedAt(0);
        status.setFailCount(0);
        status.setError("");
        ZonedDateTime nextRunAt = definition.getSchedule().nextAt(DateUtils.utcNow().plusMinutes(3));
        Long nextCompleteBy = nextRunAt.plusMinutes(definition.getAlertThresholdMinutes()).toInstant()
                .toEpochMilli();
        Log.info("Job Completed: {0} Threshold minutes: {1} next complete by: {2}", definition.getName(),
                definition.getAlertThresholdMinutes(), nextCompleteBy);
        status.setShouldSucceedBy(nextCompleteBy);
        JobStatusController.instance().save(status);
    } catch (Exception e) {
        Log.exception(e, "Error running job " + definition.getName());
        status.setFailCount(status.getFailCount() + 1);
        status.setError(e.toString() + ": " + e.getMessage() + "\n" + ExceptionUtils.getStackTrace(e));
        status.setFailedAt(DateUtils.mils());
        if (HealthTracker.instance() != null) {
            HealthTracker.instance().logException(e);
        }
        JobStatusController.instance().save(status);
    } finally {
        JobStatusController.instance().resetLockAndNextRunAt(status, now.plusMinutes(1));
    }
}

From source file:com.flat20.fingerplay.FingerPlayActivity.java

@Override
protected void onStart() {
    super.onStart();
    if (!BuildConfig.DEBUG) {
        EasyTracker.getInstance().activityStart(this);
        Tracker tracker = EasyTracker.getTracker();
        if (tracker != null) {
            tracker.setExceptionParser(new ExceptionParser() {
                @Override/*from w w  w  . ja  va  2s .co  m*/
                public String getDescription(String s, Throwable throwable) {
                    return "Thread: " + s + ", Exception: " + ExceptionUtils.getStackTrace(throwable);
                }
            });
        }
    }
}

From source file:com.aurel.track.fieldType.fieldChange.config.ItemPickerFieldChangeConfig.java

/**
 * Adds the field type specific json content to stringBuilder (without curly brackets)
 * @param stringBuilder/*ww w .  ja  v a2 s .c o  m*/
 * @param value
 * @param dataSource
 * @param personBean
 * @param locale
 */
@Override
public void addSpecificJsonContent(StringBuilder stringBuilder, Object value, Object dataSource,
        TPersonBean personBean, Locale locale) {
    if (value != null) {
        Integer[] itemIDs = (Integer[]) value;
        if (itemIDs.length > 0) {
            Integer itemID = itemIDs[0];
            if (itemID != null) {
                TWorkItemBean workItemBean;
                try {
                    workItemBean = ItemBL.loadWorkItem(itemID);
                    if (workItemBean != null) {
                        JSONUtility.appendStringValue(stringBuilder, "txtIssueNo",
                                ItemBL.getItemNo(workItemBean));
                        JSONUtility.appendStringValue(stringBuilder, "txtIssueTitle",
                                workItemBean.getSynopsis());
                    }
                } catch (ItemLoaderException e) {
                    LOGGER.info("Loading the item " + itemID + " failed with " + e.getMessage());
                    LOGGER.debug(ExceptionUtils.getStackTrace(e));
                }
            }
            JSONUtility.appendIntegerValue(stringBuilder, JSONUtility.JSON_FIELDS.VALUE, itemID);
        }
    }
}

From source file:de.static_interface.sinklibrary.util.Debug.java

private static void logInternal(@Nonnull Level level, @Nonnull String message, @Nullable Throwable throwable) {
    if (!SinkLibrary.getInstance().getSettings().isDebugEnabled()) {
        return;/*from  w w w  .j a  v a  2  s  .  co  m*/
    }
    if (throwable != null) {
        String thr = ExceptionUtils.getStackTrace(throwable);
        logToFile(level, String.format(ChatColor.stripColor(message) + "%n%s", thr));
    } else {
        logToFile(level, ChatColor.stripColor(message));
    }

    if (SinkLibrary.getInstance().getSettings().isDebugEnabled()) {
        Bukkit.getLogger().log(level,
                "[Debug] " + Debug.getCallerClassName() + " #" + getCallerMethodName() + ": " + message);
    }
}

From source file:com.aurel.track.item.action.NewItemChildActionPlugin.java

@Override
protected ItemLocationForm extractItemLocation(Locale locale, TPersonBean user, Map<String, Object> params,
        Integer workItemID, Integer parentID) {
    ItemLocationForm form = super.extractItemLocation(locale, user, params, workItemID, parentID);
    form.setParentID(parentID != null ? parentID : workItemID);
    try {/*w w w.j a  v  a  2 s . c om*/
        HashMap<String, Object> newlyCreatedLinkSettings = (HashMap<String, Object>) params
                .get("newlyCreatedLinkSettings");
        if (newlyCreatedLinkSettings != null) {
            form.setNewlyCreatedLinkSettings(newlyCreatedLinkSettings);
        }
    } catch (Exception ex) {
        LOGGER.error(ExceptionUtils.getStackTrace(ex));
    }
    return form;
}

From source file:com.aurel.track.screen.action.AbstractTabAction.java

/**
 * Reload the tab/* www . j ava2 s .  co m*/
 * @return
 */
public String reload() {
    try {
        tab = getAbstractTabDesignBL().loadFullTab(componentID);
        getAbstractPanelDesignBL().calculateFieldWrappers(tab);
    } catch (Exception ex) {
        LOGGER.error(ExceptionUtils.getStackTrace(ex));
    }

    try {
        JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse());
        PrintWriter out = ServletActionContext.getResponse().getWriter();
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        JSONUtility.appendBooleanValue(sb, JSONUtility.JSON_FIELDS.SUCCESS, true);
        JSONUtility.appendJSONValue(sb, JSONUtility.JSON_FIELDS.DATA, getScreenJSON().encodeTab(tab), true);
        sb.append("}");
        out.println(sb);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}