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:ee.ria.xroad.proxy.clientproxy.ClientException.java

ClientException(String faultCode, Throwable cause) {
    super(faultCode, cause.getMessage());

    faultDetail = ExceptionUtils.getStackTrace(cause);

    // All the client messages have prefix Client...
    withPrefix(ErrorCodes.CLIENT_X);//from w  w  w .  jav a 2 s.  c om
}

From source file:io.galeb.router.client.hostselectors.HostSelectorLookup.java

public static HostSelector getHostSelector(String name) {
    Class<? extends HostSelector> hostSelectorClass = hostSelectorMap.get(name);
    if (hostSelectorClass == null) {
        LOGGER.warn("HostSelector " + name + " not found. Using default.");
        return defaultHostSelector();
    }//ww w . ja va  2  s  .  co  m
    try {
        return hostSelectorClass.getDeclaredConstructor().newInstance();
    } catch (InstantiationException | IllegalAccessException | NoSuchMethodException
            | InvocationTargetException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
        return defaultHostSelector();
    }
}

From source file:com.heliosmi.portal.aspect.LoggingAspect.java

@Around("allBeans()")
public Object profiler(ProceedingJoinPoint pjp) throws Throwable {

    long start = System.nanoTime();
    String classMethodName = pjp.getTarget().getClass().getSimpleName() + "." + pjp.getSignature().getName();
    log.info(classMethodName + " - called with param(s) " + ToStringBuilder.reflectionToString(pjp.getArgs()));

    Object returnValue = null;/*from   w  w  w.j  av  a  2  s  .  c o  m*/
    try {
        returnValue = pjp.proceed();
    } catch (Exception exception) {
        log.error(ToStringBuilder.reflectionToString(ExceptionUtils.getRootCause(exception)));
        log.error(ExceptionUtils.getStackTrace(exception));
        throw exception;
    }

    long end = System.nanoTime();
    log.info(classMethodName + " - finished. Took " + (end - start) + " milliseconds. ");

    return returnValue;
}

From source file:com.aurel.track.exchange.docx.importer.HtmlConverter.java

public static ByteArrayOutputStream convertToHTML(String docxFileName) {

    LoggingConfigBL.setLevel(LOGGER, Level.DEBUG);
    LOGGER.debug("Creating html from " + docxFileName + "...");

    // HTML exporter setup (required)
    // .. the HTMLSettings object
    HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
    htmlSettings.setImageDirPath(docxFileName + "_files");
    htmlSettings.setImageTargetUri(docxFileName.substring(docxFileName.lastIndexOf("/") + 1) + "_files");
    WordprocessingMLPackage wordMLPackage = null;
    try {/*  ww  w  .j ava 2s  .co  m*/
        wordMLPackage = Docx4J.load(new java.io.File(docxFileName));
    } catch (Docx4JException e) {
        LOGGER.error("Loading the wordMLPackage failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return null;
    }
    LOGGER.debug(docxFileName + "loaded");
    htmlSettings.setWmlPackage(wordMLPackage);
    //Other settings (optional)

    // Sample sdt tag handler (tag handlers insert specific
    // html depending on the contents of an sdt's tag).
    // This will only have an effect if the sdt tag contains
    // the string @class=XXX

    // output to an OutputStream.

    OutputStream outputStream = null;

    // If you want XHTML output
    Docx4jProperties.setProperty("docx4j.Convert.Out.HTML.OutputMethodXML", true);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Saving the html file to disk...");
        try {
            outputStream = new FileOutputStream(docxFileName + ".html");
        } catch (FileNotFoundException e) {
            LOGGER.error("Creating the outpot stream failed with " + e.getMessage());
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }
        if (outputStream != null) {
            try {
                Docx4J.toHTML(htmlSettings, outputStream, Docx4J.FLAG_EXPORT_PREFER_XSL);
            } catch (Docx4JException e) {
                LOGGER.error("Creating the html failed with " + e.getMessage());
                LOGGER.debug(ExceptionUtils.getStackTrace(e));
                return null;
            }
            try {
                outputStream.close();
            } catch (IOException e) {
                LOGGER.error("Closing the FileOutputStream failed with " + e.getMessage());
            }
        }
    }
    outputStream = new ByteArrayOutputStream();
    //Don't care what type of exporter you use
    //Prefer the exporter, that uses a xsl transformation
    try {
        Docx4J.toHTML(htmlSettings, outputStream, Docx4J.FLAG_EXPORT_PREFER_XSL);
    } catch (Docx4JException e) {
        LOGGER.error("Creating the html failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
        return null;
    }
    //Prefer the exporter, that doesn't use a xsl transformation (= uses a visitor)
    return (ByteArrayOutputStream) outputStream;

}

From source file:com.graudata.space.jmeter.samplers.CmisSamplerBase.java

@Override
public SampleResult runTest(JavaSamplerContext ctx) {

    try {//from   w  w  w. j av  a  2  s  . c  o m
        session = JmeterUtil.getSession(ctx.getParameter("host"), ctx.getParameter("user"),
                ctx.getParameter("pw"));
        return doRunTest(ctx);
    } catch (Throwable e) {
        SampleResult result = new SampleResult();
        result.setResponseCode(e.getMessage());
        String st = ExceptionUtils.getStackTrace(e);
        result.setResponseData(e.getMessage() + "\n" + st, "UTF-8");
        return result;
    }

}

From source file:com.aurel.track.fieldType.fieldChange.converter.BooleanSetterConverter.java

/**
 * Convert the string to object value after load
 * @param value//from   ww  w  . j a  v a 2 s  . c o m
 * @param setter
 * @return
 */
@Override
public Object getActualValueFromStoredString(String value, Integer setter) {
    if (value == null || value.trim().length() == 0) {
        return null;
    } else {
        try {
            return Boolean.valueOf(value);
        } catch (Exception e) {
            LOGGER.warn("Converting the " + value + " to Boolean failed with " + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return Boolean.FALSE;
        }
    }
}

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

/**
 * This method replaces all occurrences of 
 * oldOID with newOID going through all related
 * tables in the database./* www. j  av  a2  s .  c o  m*/
 * @param oldOID object identifier to be replaced
 * @param newOID object identifier of replacement
 */
public static void replace(Class[] peerClasses, String[] fields, Integer oldOID, Integer newOID) {
    Criteria selectCriteria = new Criteria();
    Criteria updateCriteria = new Criteria();
    for (int i = 0; i < peerClasses.length; ++i) {
        Class peerClass = peerClasses[i];
        String field = fields[i];
        selectCriteria.clear();
        updateCriteria.clear();
        selectCriteria.add(field, oldOID, Criteria.EQUAL);
        updateCriteria.add(field, newOID);
        try {
            Class partypes[] = new Class[2];
            partypes[0] = Criteria.class;
            partypes[1] = Criteria.class;
            Method meth = peerClass.getMethod("doUpdate", partypes);

            Object arglist[] = new Object[2];
            arglist[0] = selectCriteria;
            arglist[1] = updateCriteria;
            meth.invoke(peerClass, arglist);
        } catch (Exception e) {
            LOGGER.error("Exception when trying to replace " + "oldOID " + oldOID + " with " + "newOID "
                    + newOID + " for class " + peerClass.toString() + " and field " + field + ": "
                    + e.getMessage(), e);
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
        }
    }
}

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

public static String importProjectTypes(File uploadFile) {
    LOGGER.info("Importing ProjectType from file:" + uploadFile.getName() + "...");
    try {/*from  w w w  .j a  v  a2s . co  m*/
        ImportContext importContext = new ImportContext();
        importContext.setOverrideExisting(false);
        importContext.setOverrideOnlyNotModifiedByUser(false);
        EntityImporter entityImporter = new EntityImporter();
        List<ImportResult> importResultList = entityImporter.importFile(uploadFile, importContext);
    } catch (EntityImporterException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    } catch (Exception e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    return null;
}

From source file:com.adobe.acs.commons.fam.Failure.java

/**
 * @param exception the exception to set
 *///from  ww  w  .  j a  va 2 s  .  com
public void setException(Exception exception) {
    this.exception = exception;
    if (exception != null) {
        this.error = exception.getMessage();
        this.stackTrace = ExceptionUtils.getStackTrace(exception);
    }
}

From source file:com.aurel.track.lucene.util.InstancePool.java

private Object _get(String className) {
    className = className.trim();//from  w w  w  .j  a  va 2  s  . co m

    Object obj = _classPool.get(className);

    if (obj == null) {
        try {
            obj = Class.forName(className).newInstance();
            _put(className, obj);
        } catch (ClassNotFoundException cnofe) {
            LOGGER.error(ExceptionUtils.getStackTrace(cnofe));
        } catch (InstantiationException ie) {
            LOGGER.error(ExceptionUtils.getStackTrace(ie));
        } catch (IllegalAccessException iae) {
            LOGGER.error(ExceptionUtils.getStackTrace(iae));
        }
    }

    return obj;
}