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.bloomreach.zk.replicate.ZkReplicator.java

/**
 * Replicates Zookeeper Data from source to destination zk host
 * @param args/*from   w  w w . j a v a2  s.  c o m*/
 */
public static void main(String[] args) throws ZkDataTraversalException {

    String sourceZk = args[0];
    String destinationZk = args[1];
    ZkDataNode rootNode;
    //Traverse the data
    try {
        rootNode = new ZookeeperDataTraverser(sourceZk, ROOT_ZK_PATH).traverse();
    } catch (Exception e) {
        logger.info("Encountered Exception.." + ExceptionUtils.getStackTrace(e));
        throw new ZkDataTraversalException("Encountered Exception.." + ExceptionUtils.getStackTrace(e));
    }
    //Replicate the data
    ZookeeperDataReplicator replicator = new ZookeeperDataReplicator(destinationZk, ROOT_ZK_PATH, rootNode);
    replicator.replicate();
}

From source file:com.garethahealy.quotalimitsgenerator.cli.Application.java

public static void main(String[] args) {
    LOG.info("Starting...");

    DefaultCLIParser parser = new DefaultCLIParser(new DefaultParser());

    try {//from w w  w .  j  a v  a2s .c om
        CommandLine commandLine = parser.parse(args, parser.getOptions());
        CLIOptions options = parser.getParsedOptions(commandLine);

        LOG.info(options.toString());

        QuotaLimitModel quotaLimitModel = options.calculate();

        LOG.info(quotaLimitModel.toString());

        YamlTemplateProcessor yamlTemplateProcessor = new YamlTemplateProcessor();
        yamlTemplateProcessor.init();

        yamlTemplateProcessor.process(quotaLimitModel);
    } catch (NumberFormatException | IOException | ParseException | URISyntaxException | TemplateException ex) {
        LOG.error("We hit a problem! {}", ExceptionUtils.getStackTrace(ex));

        parser.displayHelp(false);
    }
}

From source file:com.garethahealy.fuse.aries.transactions.cli.Application.java

public static void main(String[] args) {
    LOG.info("Starting...");

    DefaultCLIParser parser = new DefaultCLIParser(new GnuParser());

    try {/*from  ww  w.j  ava  2s.co  m*/
        CommandLine commandLine = parser.parse(args, parser.getOptions());

        Map<String, String> databaseOptions = parser.getDatabaseOptions(commandLine);

        DbManagedConnectionFactory managedConnectionFactory = new MySqlManagedConnectionFactory();

        LOG.info("About to run Aries...");

        ConnectionManagerContainer connectionManagerContainer = getConnectionManagerContainer("datasource");
        connectionManagerContainer
                .doRecovery(managedConnectionFactory.getManagedConnectionFactory(databaseOptions));
    } catch (ParseException ex) {
        LOG.error("We hit a problem! {}", ExceptionUtils.getStackTrace(ex));

        parser.displayHelp(false);
    } catch (XAException ex) {
        LOG.error("We hit a problem! {}", ExceptionUtils.getStackTrace(ex));

        parser.displayHelp(false);
    } catch (SQLException ex) {
        LOG.error("We hit a problem! {}", ExceptionUtils.getStackTrace(ex));

        parser.displayHelp(false);
    }
}

From source file:com.trackplus.ddl.DataWriterTest.java

public static void main(String[] args) {

    String dirName = "d:\\tmp7\\7";
    String dbType = MetaDataBL.DATABASE_FIREBIRD;

    DatabaseInfo databaseInfo = createFirebirdDbInfo();
    Logger LOGGER = LogManager.getLogger(DataWriter.class);
    LoggingConfigBL.setLevel(LOGGER, Level.DEBUG);
    boolean emptyDB = false;
    try {/*from  w w w .jav  a  2s  .  c  o  m*/
        emptyDB = MetaDataBL.checkEmptyDatabase(databaseInfo);
    } catch (DDLException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
    if (!emptyDB) {
        LOGGER.error("Target database is not empty!");
    } else {
        String fileSchema = dirName + File.separator + dbType + "_schema.sql";
        LOGGER.info("Importing schema DB...");
        try {
            DataWriter.executeScript(fileSchema, databaseInfo);
            LOGGER.info("Importing schema DB successfuly!");
        } catch (DDLException e) {
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }

        LOGGER.info("Importing data...");
        try {
            DataWriter.writeDataToDB(databaseInfo, dirName);
            LOGGER.info("Importing data successfuly!");
        } catch (DDLException e) {
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }

        LOGGER.info("Importing constraints...");
        String fileSchemaConstraints = dirName + File.separator + dbType + "_schema_constraints.sql";
        try {
            DataWriter.executeScript(fileSchemaConstraints, databaseInfo);
            LOGGER.info("Importing constraints successfuly!");
        } catch (DDLException e) {
            LOGGER.error(ExceptionUtils.getStackTrace(e));
        }
    }
    System.out.println("Ready!");
}

From source file:com.trackplus.ddl.DataReaderTest.java

public static void main(String[] args) {
    DatabaseInfo databaseInfo = createFirebirdDbInfo();
    Logger LOGGER = LogManager.getLogger(DataReader.class);
    LoggingConfigBL.setLevel(LOGGER, Level.DEBUG);

    String dbaseDir = "d:\\svn2015\\core\\com.trackplus.core\\src\\main\\webapp\\dbase";
    String tmpDir = "d:\\tmp7\\7";
    File file = new File(tmpDir);
    if (!file.exists()) {
        file.mkdirs();//from  w  w  w.j  av  a  2 s .c o  m
    }
    exportSchema(new File(tmpDir), dbaseDir);

    try {
        DataReader.writeDataToSql(databaseInfo, tmpDir);
    } catch (DDLException e) {
        LOGGER.error(ExceptionUtils.getStackTrace(e));
    }
}

From source file:appmain.AppMain.java

public static void main(String[] args) {

    try {//from  w  ww  .j a v  a  2 s  .  c  o m
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.put("OptionPane.yesButtonText", "Igen");
        UIManager.put("OptionPane.noButtonText", "Nem");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    try {

        AppMain app = new AppMain();
        app.init();

        File importFolder = new File(DEFAULT_IMPORT_FOLDER);
        if (!importFolder.isDirectory() || !importFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az IMPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        File exportFolder = new File(DEFAULT_EXPORT_FOLDER);
        if (!exportFolder.isDirectory() || !exportFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    "Az EXPORT mappa nem elrhet!\n"
                            + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: "
                            + exportFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        List<File> xmlFiles = app.getXMLFiles(importFolder);
        if (xmlFiles == null || xmlFiles.isEmpty()) {
            JOptionPane.showMessageDialog(null,
                    "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(),
                    "Informci", JOptionPane.INFORMATION_MESSAGE);
            return;
        }

        StringBuilder fileList = new StringBuilder();
        xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName()));
        int ret = JOptionPane.showConfirmDialog(null,
                "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?",
                "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        if (ret == JOptionPane.OK_OPTION) {
            String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis()
                    + ".csv";
            File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName);
            app.writeCSV(csv, Arrays.asList(app.getHeaderLine()));
            xmlFiles.stream().forEach(xml -> {
                List<String> lines = app.readXMLData(xml);
                if (lines != null)
                    app.writeCSV(csv, lines);
            });
            if (csv.isFile() && csv.exists()) {
                JOptionPane.showMessageDialog(null,
                        "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(),
                        "Informci", JOptionPane.INFORMATION_MESSAGE);
                app.openFile(csv);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci",
                    JOptionPane.INFORMATION_MESSAGE);
        }

    } catch (Exception ex) {
        JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba",
                JOptionPane.ERROR_MESSAGE);
    }

}

From source file:namedatabasescraper.NameDatabaseScraper.java

/**
 * @param args the command line arguments
 *///w w w.ja  va  2 s.c o m
public static void main(String[] args) {
    try {
        NameDatabaseScraper.application = new NameDatabaseScraper();
    } catch (Exception ex) {
        logger.log(Level.SEVERE, null, ex);
        logger.log(Level.SEVERE, ExceptionUtils.getStackTrace(ex));
        System.exit(1);
    }
}

From source file:de.micromata.genome.tpsb.executor.GroovyShellExecutor.java

public static void main(String[] args) {
    String methodName = null;/*from  ww  w. j  a v  a  2 s .c  om*/
    if (args.length > 0 && StringUtils.isNotBlank(args[0])) {
        methodName = args[0];
    }
    GroovyShellExecutor exec = new GroovyShellExecutor();
    //System.out.println("GroovyShellExecutor start");
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String line;
    StringBuffer code = new StringBuffer();
    try {
        while ((line = in.readLine()) != null) {
            if (line.equals("--EOF--") == true) {
                break;
            }
            code.append(line);
            code.append("\n");

            //System.out.flush();
        }
    } catch (IOException ex) {
        throw new RuntimeException("Failure reading std in: " + ex.toString(), ex);
    }
    try {
        exec.executeCode(code.toString(), methodName);
    } catch (Throwable ex) { // NOSONAR "Illegal Catch" framework
        warn("GroovyShellExecutor failed with exception: " + ex.getClass().getName() + ": " + ex.getMessage()
                + "\n" + ExceptionUtils.getStackTrace(ex));
    }
    System.out.println("--EOP--");
    System.out.flush();
}

From source file:hu.bme.mit.sette.run.Run.java

public static void main(String[] args) {
    LOG.debug("main() called");

    // parse properties
    Properties prop = new Properties();
    InputStream is = null;/*from  w  ww .  ja v a2s. co  m*/

    try {
        is = new FileInputStream(SETTE_PROPERTIES);
        prop.load(is);
    } catch (IOException e) {
        System.err.println("Parsing  " + SETTE_PROPERTIES + " has failed");
        e.printStackTrace();
        System.exit(1);
    } finally {
        IOUtils.closeQuietly(is);
    }

    String[] basedirs = StringUtils.split(prop.getProperty("basedir"), '|');
    String snippetDir = prop.getProperty("snippet-dir");
    String snippetProject = prop.getProperty("snippet-project");
    String catgPath = prop.getProperty("catg");
    String catgVersionFile = prop.getProperty("catg-version-file");
    String jPETPath = prop.getProperty("jpet");
    String jPETDefaultBuildXml = prop.getProperty("jpet-default-build.xml");
    String jPETVersionFile = prop.getProperty("jpet-version-file");
    String spfPath = prop.getProperty("spf");
    String spfDefaultBuildXml = prop.getProperty("spf-default-build.xml");
    String spfVersionFile = prop.getProperty("spf-version-file");
    String outputDir = prop.getProperty("output-dir");

    Validate.notEmpty(basedirs, "At least one basedir must be specified in " + SETTE_PROPERTIES);
    Validate.notBlank(snippetDir, "The property snippet-dir must be set in " + SETTE_PROPERTIES);
    Validate.notBlank(snippetProject, "The property snippet-project must be set in " + SETTE_PROPERTIES);
    Validate.notBlank(catgPath, "The property catg must be set in " + SETTE_PROPERTIES);
    Validate.notBlank(jPETPath, "The property jpet must be set in " + SETTE_PROPERTIES);
    Validate.notBlank(spfPath, "The property spf must be set in " + SETTE_PROPERTIES);
    Validate.notBlank(outputDir, "The property output-dir must be set in " + SETTE_PROPERTIES);

    String basedir = null;
    for (String bd : basedirs) {
        bd = StringUtils.trimToEmpty(bd);

        if (bd.startsWith("~")) {
            // Linux home
            bd = System.getProperty("user.home") + bd.substring(1);
        }

        FileValidator v = new FileValidator(new File(bd));
        v.type(FileType.DIRECTORY);

        if (v.isValid()) {
            basedir = bd;
            break;
        }
    }

    if (basedir == null) {
        System.err.println("basedir = " + Arrays.toString(basedirs));
        System.err.println("ERROR: No valid basedir was found, please check " + SETTE_PROPERTIES);
        System.exit(2);
    }

    BASEDIR = new File(basedir);
    SNIPPET_DIR = new File(basedir, snippetDir);
    SNIPPET_PROJECT = snippetProject;
    OUTPUT_DIR = new File(basedir, outputDir);

    try {
        String catgVersion = readToolVersion(new File(BASEDIR, catgVersionFile));
        if (catgVersion != null) {
            new CatgTool(new File(BASEDIR, catgPath), catgVersion);
        }

        String jPetVersion = readToolVersion(new File(BASEDIR, jPETVersionFile));
        if (jPetVersion != null) {
            new JPetTool(new File(BASEDIR, jPETPath), new File(BASEDIR, jPETDefaultBuildXml), jPetVersion);
        }

        String spfVersion = readToolVersion(new File(BASEDIR, spfVersionFile));
        if (spfVersion != null) {
            new SpfTool(new File(BASEDIR, spfPath), new File(BASEDIR, spfDefaultBuildXml), spfVersion);
        }

        // TODO stuff
        stuff(args);
    } catch (Exception e) {
        System.err.println(ExceptionUtils.getStackTrace(e));

        ValidatorException vex = (ValidatorException) e;

        for (ValidationException v : vex.getValidator().getAllExceptions()) {
            v.printStackTrace();
        }

        // System.exit(0);

        e.printStackTrace();
        System.err.println("==========");
        e.printStackTrace();

        if (e instanceof ValidatorException) {
            System.err.println("Details:");
            System.err.println(((ValidatorException) e).getFullMessage());
        } else if (e.getCause() instanceof ValidatorException) {
            System.err.println("Details:");
            System.err.println(((ValidatorException) e.getCause()).getFullMessage());
        }
    }
}

From source file:Error.HandleError.java

public static void HandleError(Exception ex) {
    //do something with the error in a general way for the rest of the 
    String stack_trace = ExceptionUtils.getStackTrace(ex);
    System.out.println("*******************************************");
    System.out.println("*******************************************");
    System.out.println("ERROR HAS OCCURED!");
    System.out.println("DATE TIME: " + new Date());
    System.out.println("*******************************************");
    System.out.println(stack_trace);
    System.out.println("*******************************************");
}