Example usage for java.lang RuntimeException getMessage

List of usage examples for java.lang RuntimeException getMessage

Introduction

In this page you can find the example usage for java.lang RuntimeException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:de.bstreit.java.oscr.initialdata.LoadInitialDataApp.java

public static void main(String[] args) throws BeansException, SQLException {
    System.out.println("Loading...");

    try (final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
            SpringConfigurationDoesComponentScan.class)) {

        context.getBean(LoadInitialDataApp.class).start();

    } catch (RuntimeException e) {
        if (!"Aborted".equals(e.getMessage())) {
            throw e;
        }/* w ww.j  a  v  a2s .c  om*/
    }
}

From source file:com.myjeeva.poi.demo.Excel2JavaDemo.java

/**
 * @param args/*from w w  w. ja  va 2  s . c o  m*/
 * @throws FileNotFoundException
 */
public static void main(String[] args) throws FileNotFoundException {
    String SAMPLE_PERSON_DATA_FILE_PATH = "src/main/resources/Sample-Person-Data.xlsx";

    // Input File initialize
    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // Excel Cell Mapping
    Map<String, String> cellMapping = new HashMap<String, String>();
    cellMapping.put("HEADER", "Person Id,Name,Height,Email Address,DOB,Salary");
    cellMapping.put("A", "personId");
    cellMapping.put("B", "name");
    cellMapping.put("C", "height");
    cellMapping.put("D", "emailId");
    cellMapping.put("E", "dob");
    cellMapping.put("F", "salary");

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;
    try {

        ExcelWorkSheetHandler<PersonVO> workSheetHandler = new ExcelWorkSheetHandler<PersonVO>(PersonVO.class,
                cellMapping);

        pkg = OPCPackage.open(inputStream);
        ExcelReader excelReader = new ExcelReader(pkg, workSheetHandler);
        excelReader.process();

        if (workSheetHandler.getValueList().isEmpty()) {
            // No data present
            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            // Displaying data ead from Excel file
            displayPersonList(workSheetHandler.getValueList());
        }

    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}

From source file:cool.pandora.modeller.ModellerApplication.java

public static void main(final String[] args) {
    final String rootContextDirectoryClassPath = "cool/pandora/modeller/ctx";

    final String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";

    final String richclientApplicationContextPath = rootContextDirectoryClassPath
            + "/common/richclient-application-context.xml";

    final String businessLayerContextPath = rootContextDirectoryClassPath
            + "/common/business-layer-context.xml";

    try {//from  w w  w.  ja v  a2s.c o m
        new ApplicationLauncher(startupContextPath,
                new String[] { richclientApplicationContextPath, businessLayerContextPath });
    } catch (final IllegalStateException ex1) {
        log.error("IllegalStateException during startup", ex1);
        JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final PropertyAccessException ex) {
        log.error("PropertyAccessException during startup", ex);
        JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n",
                "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final RuntimeException e) {
        log.error("RuntimeException during startup", e);
        final String msg = e.getMessage();
        if (msg.contains("SAXParseException")) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "An error occured parsing application context.  You may " + "have no "
                            + "internet access.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n",
                    "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);
    }
}

From source file:gov.loc.repository.bagger.BaggerApplication.java

public static void main(String[] args) {
    String rootContextDirectoryClassPath = "/gov/loc/repository/bagger/ctx";

    String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";

    String richclientApplicationContextPath = rootContextDirectoryClassPath
            + "/common/richclient-application-context.xml";

    String businessLayerContextPath = rootContextDirectoryClassPath + "/common/business-layer-context.xml";

    try {//w w w.  j a  v  a  2s . co  m
        new ApplicationLauncher(startupContextPath,
                new String[] { richclientApplicationContextPath, businessLayerContextPath });
    } catch (IllegalStateException ex1) {
        LogFactory.getLog(BaggerApplication.class).error("IllegalStateException during startup", ex1);
        JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (PropertyAccessException ex) {
        LogFactory.getLog(BaggerApplication.class).error("PropertyAccessException during startup", ex);
        JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (RuntimeException e) {
        LogFactory.getLog(BaggerApplication.class).error("RuntimeException during startup", e);
        String msg = e.getMessage();
        if (msg.contains("SAXParseException")) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "An error occured parsing application context.  You may have no internet access.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);
    }
}

From source file:com.myjeeva.poi.ExcelWorkSheetRowCallbackHandlerTest.java

public static void main(String[] args) throws Exception {

    String SAMPLE_PERSON_DATA_FILE_PATH = "src/test/resources/Sample-Person-Data.xlsx";

    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;/*from   ww w  .j av  a 2s .  c o  m*/
    try {
        ExcelWorkSheetRowCallbackHandler sheetRowCallbackHandler = new ExcelWorkSheetRowCallbackHandler(
                new ExcelRowContentCallback() {

                    @Override
                    public void processRow(int rowNum, Map<String, String> map) {

                        // Do any custom row processing here, such as save
                        // to database
                        // Convert map values, as necessary, to dates or
                        // parse as currency, etc
                        System.out.println("rowNum=" + rowNum + ", map=" + map);

                    }

                });

        pkg = OPCPackage.open(inputStream);

        ExcelSheetCallback sheetCallback = new ExcelSheetCallback() {
            private int sheetNumber = 0;

            @Override
            public void startSheet(int sheetNum, String sheetName) {
                this.sheetNumber = sheetNum;
                System.out.println("Started processing sheet number=" + sheetNumber + " and Sheet Name is '"
                        + sheetName + "'");
            }

            @Override
            public void endSheet() {
                System.out.println("Processing completed for sheet number=" + sheetNumber);
            }
        };

        System.out.println("Constructor: pkg, sheetRowCallbackHandler, sheetCallback");
        ExcelReader example1 = new ExcelReader(pkg, sheetRowCallbackHandler, sheetCallback);
        example1.process();

        System.out.println("\nConstructor: filePath, sheetRowCallbackHandler, sheetCallback");
        ExcelReader example2 = new ExcelReader(SAMPLE_PERSON_DATA_FILE_PATH, sheetRowCallbackHandler,
                sheetCallback);
        example2.process();

        System.out.println("\nConstructor: file, sheetRowCallbackHandler, sheetCallback");
        ExcelReader example3 = new ExcelReader(file, sheetRowCallbackHandler, null);
        example3.process();

    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandlerTest.java

/**
 * @param args/*  w ww  .  j av a 2s .  co  m*/
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    String SAMPLE_PERSON_DATA_FILE_PATH = "src/test/resources/Sample-Person-Data.xlsx";

    // Input File initialize
    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // Excel Cell Mapping
    Map<String, String> cellMapping = new HashMap<String, String>();
    cellMapping.put("HEADER", "Person Id,Name,Height,Email Address,DOB,Salary");
    cellMapping.put("A", "personId");
    cellMapping.put("B", "name");
    cellMapping.put("C", "height");
    cellMapping.put("D", "emailId");
    cellMapping.put("E", "dob");
    cellMapping.put("F", "salary");

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;
    try {

        ExcelWorkSheetHandler<PersonVO> workSheetHandler = new ExcelWorkSheetHandler<PersonVO>(PersonVO.class,
                cellMapping);

        pkg = OPCPackage.open(inputStream);

        ExcelSheetCallback sheetCallback = new ExcelSheetCallback() {
            private int sheetNumber = 0;

            @Override
            public void startSheet(int sheetNum, String sheetName) {
                this.sheetNumber = sheetNum;
                System.out.println("Started processing sheet number=" + sheetNumber + " and Sheet Name is '"
                        + sheetName + "'");
            }

            @Override
            public void endSheet() {
                System.out.println("Processing completed for sheet number=" + sheetNumber);
            }
        };

        System.out.println("Constructor: pkg, workSheetHandler, sheetCallback");
        ExcelReader example1 = new ExcelReader(pkg, workSheetHandler, sheetCallback);
        example1.process();

        if (workSheetHandler.getValueList().isEmpty()) {
            // No data present
            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            // Displaying data ead from Excel file
            displayPersonList(workSheetHandler.getValueList());
        }

        System.out.println("\nConstructor: filePath, workSheetHandler, sheetCallback");
        ExcelReader example2 = new ExcelReader(SAMPLE_PERSON_DATA_FILE_PATH, workSheetHandler, sheetCallback);
        example2.process();

        System.out.println("\nConstructor: file, workSheetHandler, sheetCallback");
        ExcelReader example3 = new ExcelReader(file, workSheetHandler, null);
        example3.process();

    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}

From source file:com.mycompany.javaapplicaton3.ExcelWorkSheetHandlerTest.java

/**
 * @param args/*ww w.ja va 2  s  .  c om*/
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    String SAMPLE_PERSON_DATA_FILE_PATH = "C:/Users/lprates/Documents/Sample-Person-Data.xlsx";

    // Input File initialize
    File file = new File(SAMPLE_PERSON_DATA_FILE_PATH);
    InputStream inputStream = new FileInputStream(file);

    // Excel Cell Mapping
    Map<String, String> cellMapping = new HashMap<String, String>();
    cellMapping.put("HEADER", "Person Id,Name,Height,Email Address,DOB,Salary");
    cellMapping.put("A", "personId");
    cellMapping.put("B", "name");
    cellMapping.put("C", "height");
    cellMapping.put("D", "emailId");
    cellMapping.put("E", "dob");
    cellMapping.put("F", "salary");

    // The package open is instantaneous, as it should be.
    OPCPackage pkg = null;
    try {

        ExcelWorkSheetHandler<PersonVO> workSheetHandler = new ExcelWorkSheetHandler<PersonVO>(PersonVO.class,
                cellMapping);

        pkg = OPCPackage.open(inputStream);

        ExcelSheetCallback sheetCallback = new ExcelSheetCallback() {
            private int sheetNumber = 0;

            public void startSheet(int sheetNum, String sheetName) {
                this.sheetNumber = sheetNum;
                System.out.println("Started processing sheet number=" + sheetNumber + " and Sheet Name is '"
                        + sheetName + "'");
            }

            @Override
            public void endSheet() {
                System.out.println("Processing completed for sheet number=" + sheetNumber);
            }

            public void startSheet(int sheetNum) {
                System.out.println("Started processing sheet number=" + sheetNum);
            }

        };

        System.out.println("Constructor: pkg, workSheetHandler, sheetCallback");
        ExcelReader example1 = new ExcelReader(pkg, workSheetHandler, sheetCallback);
        example1.process("Lot 1 Data");

        if (workSheetHandler.getValueList().isEmpty()) {
            // No data present
            LOG.error("sHandler.getValueList() is empty");
        } else {

            LOG.info(workSheetHandler.getValueList().size()
                    + " no. of records read from given excel worksheet successfully.");

            // Displaying data ead from Excel file
            displayPersonList(workSheetHandler.getValueList());
        }
        /*
              System.out.println("\nConstructor: filePath, workSheetHandler, sheetCallback");
              ExcelReader example2 =
                  new ExcelReader(SAMPLE_PERSON_DATA_FILE_PATH, workSheetHandler, sheetCallback);
              example2.process();
                
              System.out.println("\nConstructor: file, workSheetHandler, sheetCallback");
              ExcelReader example3 = new ExcelReader(file, workSheetHandler, null);
              example3.process();
        */
    } catch (RuntimeException are) {
        LOG.error(are.getMessage(), are.getCause());
    } catch (InvalidFormatException ife) {
        LOG.error(ife.getMessage(), ife.getCause());
    } catch (IOException ioe) {
        LOG.error(ioe.getMessage(), ioe.getCause());
    } finally {
        IOUtils.closeQuietly(inputStream);
        try {
            if (null != pkg) {
                pkg.close();
            }
        } catch (IOException e) {
            // just ignore IO exception
        }
    }
}

From source file:de.fhg.iais.asc.ui.MyCortexStarter.java

/**
 * Starts Cortex./*from w  w w  .  ja  va  2 s . com*/
 * 
 * @param args
 *        the command line arguments
 * @see #configure(ListIterator) The list of applicable command line
 *      arguments
 */
public static void main(String[] args) {
    try {
        configureLogging();
        MyCortexStarter starter = new MyCortexStarter(".");
        starter.start(args);
        LOG.info("Cortex services started.");

        // register a shutdown hook which makes it possible to stop the
        // services with a soft kill
        Runtime.getRuntime().addShutdownHook(new ShutdownHookThread(starter));
    } catch (RuntimeException e) {
        LOG.warn("Start of Cortex failed: " + e.getMessage());
    }
}

From source file:de.fhg.iais.cortex.Starter.java

/**
 * Starts Cortex./*  w w w. ja  v  a  2 s .  com*/
 * 
 * @param args
 *        the command line arguments
 * @see #configure(ListIterator) The list of applicable command line
 *      arguments
 */
public static void main(String[] args) {
    try {
        configureLogging();
        Starter starter = new Starter(".");
        starter.start(args);
        LOG.info("Cortex services started.");

        // register a shutdown hook which makes it possible to stop the
        // services with a soft kill
        Runtime.getRuntime().addShutdownHook(new ShutdownHookThread(starter));
    } catch (RuntimeException e) {
        LOG.warn("Start of Cortex failed: " + e.getMessage());
    }
}

From source file:jmxsh.Main.java

/** 
Entry-point when jmxsh is executed./*from w  w w  .j  a  va 2s . c  o  m*/
        
Parses command line options, evaluates tcl files, then goes to
interactive mode if desired.
        
@param args Command line arguments passed to jmxsh.
*/
public static void main(String[] args) {

    Main mainObj = new Main();

    try {
        mainObj.run(args);
    } catch (RuntimeException e) {
        System.err.println("Error: " + e.getMessage());
        logger.fatal("Runtime Exception received in main(): " + e.getMessage(), e);
        System.exit(1);
    }

    System.exit(0);

}