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.fieldType.runtime.base.CompositeComparable.java

@Override
public int compareTo(Object o) {
    CompositeComparable compositeComparable = (CompositeComparable) o;
    Map<Integer, Comparable> paramComparableMap = compositeComparable.getComparableMap();
    if ((comparableMap == null) && (paramComparableMap == null)) {
        return 0;
    }/*from   w  ww  . j a  v  a  2  s .  c om*/
    if (comparableMap == null) {
        return -1;
    }
    if (paramComparableMap == null) {
        return 1;
    }
    for (int i = 0; i < numberOfParts; i++) {
        Integer parameterCode = new Integer(i + 1);
        Comparable value0 = comparableMap.get(parameterCode);
        Comparable value1 = paramComparableMap.get(parameterCode);
        if ((value0 == null) && (value1 == null)) {
            return 0;
        }
        if (value0 == null) {
            return -1;
        }
        if (value1 == null) {
            return 1;
        }
        try {
            int compareResult = value0.compareTo(value1);
            if (compareResult != 0) {
                //return now only if the part if different
                return compareResult;
            }
        } catch (Exception e) {
            LOGGER.warn("Sorting the values " + value0 + " of class " + value0.getClass().getName() + " and "
                    + value1 + " of class " + value1.getClass().getName() + " failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    return 0;
}

From source file:lu.list.itis.dkd.aig.template.TemplateService.java

protected Response storeTemplate(final ServletContext context, final InputStream stream, final String name,
        final String folder) {
    try {//from  w ww.j  av  a2  s . c  o  m
        TemplateManager.store(context, stream, name, folder);
        return Response.ok().build();
    } catch (final UnsupportedEncodingException e) {
        Logger.getLogger(TemplateService.class.getSimpleName()).log(Level.SEVERE, e.getMessage(), e);
        return Response.serverError()
                .entity("UTF-8 was not supported by the stream reader!\n" + ExceptionUtils.getStackTrace(e)) //$NON-NLS-1$
                .build();
    } catch (final IOException e) {
        Logger.getLogger(TemplateService.class.getSimpleName()).log(Level.SEVERE, e.getMessage(), e);
        return Response.serverError().entity(
                "An error occured while attempting to store the template!\n" + ExceptionUtils.getStackTrace(e)) //$NON-NLS-1$
                .build();
    }
}

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

/**
 * Saves a userLevelBean to the TUserLevel table.
 * @param userLevelBean//from  w  w w . j  a  v  a  2s .c  o m
 * @return
 */
@Override
public Integer save(TUserLevelBean userLevelBean) {
    try {
        TUserLevel tUserLevel = TUserLevel.createTUserLevel(userLevelBean);
        tUserLevel.save();
        return tUserLevel.getObjectID();
    } catch (Exception e) {
        LOGGER.error("Saving of a user level failed with " + e.getMessage());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
        return null;
    }
}

From source file:com.garethahealy.camel.dynamic.loadbalancer.statistics.mbeans.BaseMBeanAttributeCollector.java

private ObjectName createAllRoutesObjectName() {
    ObjectName objectName = null;
    try {//from   w ww  .j a va2  s . c om
        objectName = new ObjectName(agent.getMBeanObjectDomainName() + ":type=routes,*");
    } catch (MalformedObjectNameException ex) {
        LOG.error(ExceptionUtils.getStackTrace(ex));
    }

    return objectName;
}

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

/**
 * Reload the panel/*from w  w w. java  2s  . c  o m*/
 * @return
 */
public String reload() {
    IPanel panWrapper = getAbstractPanelDesignBL().loadPanelWrapped(componentID);
    String s = encodePanel(panWrapper);
    try {
        JSONUtility.prepareServletResponseJSON(ServletActionContext.getResponse());
        PrintWriter out = ServletActionContext.getResponse().getWriter();
        out.println(s);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:com.aurel.track.dbase.JobScheduler.java

/**
 * Routine to start the Quartz scheduler. This reads the configuration file
 * /WEB-INF/quartz-jobs.xml and configures all jobs and triggers with
 * the appropriate job classes. Hence, all configuration is done via this
 * xml file, there is no coding necessary to add any additional jobs,
 * triggers and listeners.//w  w  w.j  ava2 s.  c  o  m
 * 
 */
public static void startScheduler() {
    try {
        StdSchedulerFactory sf = new StdSchedulerFactory();
        LOGGER.debug("Initialize scheduler factory...");
        sf.initialize(quartzProperties);
        LOGGER.debug("Getting the scheduler from factory");
        sched = sf.getScheduler();
    } catch (SchedulerException se) {
        LOGGER.error(se.getMessage());
        LOGGER.error("Trying recovery...");
        clearJobs(); // clean out any debris...
        try { // ... again
            sched = new StdSchedulerFactory(quartzProperties).getScheduler();
        } catch (SchedulerException se2) {
            LOGGER.error(ExceptionUtils.getStackTrace(se2), se2); // Emergency call, not much we can do here anymore
        }
    }

    //We get all jobs and triggers from the configuration file /WEB-INF/quartz-jobs.xml
    SimpleClassLoadHelper clh = new SimpleClassLoadHelper();
    InputStream in = null;
    try {
        XMLSchedulingDataProcessor xmlProcessor = new XMLSchedulingDataProcessor(clh);
        LOGGER.debug("Getting the quartz-jobs.xml configuration file");
        in = HandleHome.getStream(servletContext, "quartz-jobs.xml");
        // URL quartzJobsURL = servletContext.getResource("/WEB-INF/quartz-jobs.xml");
        // InputStream in = quartzJobsURL.openStream();
        LOGGER.debug("Process the quartz-jobs.xml configuration file");
        xmlProcessor.processStreamAndScheduleJobs(in, "quartz-jobs.xml", sched);
        LOGGER.debug("quartz-jobs.xml processed");
        in.close();
    } catch (Exception e) {
        LOGGER.error("Processing the configuration file failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    } finally {
        try {
            if (in != null) {
                in.close();
            }
        } catch (Exception fe) {
        }
    }

    try {
        LOGGER.info("Starting Quartz scheduler...");
        sched.start();
        LOGGER.info("Quartz scheduler started");
        initializeJabDataMapsInJobs(); // for all jobs with "Public static void setJobDataMap(JobDataMap jdm)
        LOGGER.info("Job data maps initialized");
    } catch (Exception se) {
        LOGGER.error(se.getMessage());
        LOGGER.error("Trying recovery...");
        clearJobs(); // clean out any debris...
        try { // ... again
            sched = new StdSchedulerFactory(quartzProperties).getScheduler();
            sched.start();
            System.err.println("Recovery was successful");
        } catch (SchedulerException se2) {
            LOGGER.error(ExceptionUtils.getStackTrace(se2), se2); // Emergency call, not much we can do here anymore
        }
    }
}

From source file:com.data2semantics.yasgui.server.IssueReporter.java

private String getBodyHtml() {
    String html = "";
    if (report.getBody() != null)
        html += report.getBody() + "<br><br>";
    if (report.getUserAgent() != null)
        html += "<strong>UserAgent</strong>: " + report.getUserAgent() + "<br>";
    if (report.getThrowable() != null) {
        html += "<strong>Stacktrace</strong>: <br>";
        html += ExceptionUtils.getStackTrace(report.getThrowable());
    }//from  w w w  . j  a  va2 s  .  c  o  m
    return html;
}

From source file:de.crowdcode.kissmda.cartridges.simplejava.JavaCodeFormatter.java

/**
 * Format the given code./*ww  w  . ja v a  2s  . c  om*/
 * 
 * @param compilationUnit
 *            Compilation Unit as unformatted code
 * @return formatted code
 */
public String format(String compilationUnit) {
    createCodeFormatter();
    String lineSeparator = getLineEnding(compilationUnit);

    TextEdit te = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT + CodeFormatter.F_INCLUDE_COMMENTS,
            compilationUnit, 0, compilationUnit.length(), 0, lineSeparator);
    IDocument doc = new Document(compilationUnit);
    try {
        te.apply(doc);
    } catch (MalformedTreeException e) {
        logger.log(Level.SEVERE, ExceptionUtils.getStackTrace(e));
    } catch (BadLocationException e) {
        logger.log(Level.SEVERE, ExceptionUtils.getStackTrace(e));
    }
    String formattedCode = doc.get();
    return formattedCode;
}

From source file:com.aurel.track.fieldType.runtime.system.text.SystemLabelDateRT.java

/**
 * Whether the value have been modified//from   ww w.  j a va 2 s  . co  m
 * Considered by assembling the history and mail
 * @param newValue
 * @param oldValue
 * @return
 */
@Override
public boolean valueModified(Object newValue, Object oldValue) {
    Date dateNew = null;
    if (newValue != null) {
        try {
            dateNew = (Date) newValue;
        } catch (Exception e) {
            LOGGER.warn("Converting the new value of type " + newValue.getClass().getName()
                    + " to Date failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    Date dateOld = null;
    if (oldValue != null) {
        try {
            dateOld = (Date) oldValue;
        } catch (Exception e) {
            LOGGER.warn("Converting the old value of type " + newValue.getClass().getName()
                    + " to Boolean failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
    //CreateDate and LastEditDate contain also time value near the date value
    //that's why we do not allow to group by them
    return EqualUtils.notEqualDateNeglectTime(dateNew, dateOld);
}

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

@Override
public Integer save(TCardFieldOptionBean cardFieldOptionBean) {
    try {//w  w w  .j a v a  2  s.  c  o  m
        TCardFieldOption cardFieldOption = BaseTCardFieldOption.createTCardFieldOption(cardFieldOptionBean);
        cardFieldOption.save();
        return cardFieldOption.getObjectID();
    } catch (Exception e) {
        LOGGER.error("Saving of a cardFieldOptionBean failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return null;
    }
}