Example usage for java.lang ClassNotFoundException getStackTrace

List of usage examples for java.lang ClassNotFoundException getStackTrace

Introduction

In this page you can find the example usage for java.lang ClassNotFoundException getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:hm.binkley.util.XPropsConverter.java

@SuppressWarnings("unchecked")
private static <T> Class<T> tokenFor(final String type) {
    try {/*from   w w  w .  j a  v a 2 s. c  o m*/
        return (Class<T>) Class.forName(type);
    } catch (final ClassNotFoundException e) {
        final IllegalArgumentException x = new IllegalArgumentException(type + ": " + e);
        x.setStackTrace(e.getStackTrace());
        throw x;
    }
}

From source file:com.mellanox.hadoop.mapred.MapOutputLocation.java

synchronized /*private*/ void doFallbackInit(Throwable t) throws IOException {
    if (fallbackPlugin != null)
        return; // already done

    exitGetMapEvents = true; //sanity
    String devModeProperty = "mapred.rdma.developer.mode";
    LOG.info("checking " + devModeProperty + "...");
    if (jobConf.getBoolean(devModeProperty, false)) {
        LOG.fatal("Got UDA Fatal Error and cannot fallback to Vanilla since I am under " + devModeProperty
                + ". Aborting...\n" + StringUtils.stringifyException(t));
        // throw( new UdaRuntimeException("Got UDA Fatal Error and cannot fallback to Vanilla since I am under " + devModeProperty, t) );
        System.exit(1);/*from   w  ww  .  j  a v a 2  s . c om*/
    }

    if (t != null) {
        LOG.error(
                "Critical failure has occured in UdaPlugin - We'll try to use vanilla as fallbackPlugin. \n\tException is:"
                        + StringUtils.stringifyException(t));
    }

    try {
        fallbackPlugin = UdaMapredBridge.getShuffleConsumerPlugin(getVanillaPluginClass(), reduceTask,
                umbilical, jobConf, reporter);
        LOG.info("Succesfuly switched to Using fallbackPlugin");
    } catch (ClassNotFoundException e) {
        UdaRuntimeException ure = new UdaRuntimeException(
                "Failed to initialize UDA Shuffle and failed to fallback to vanilla Shuffle because of ClassNotFoundException",
                e);
        ure.setStackTrace(e.getStackTrace());
        throw ure;
    }
}

From source file:rems.Global.java

public static void runReport(String outputUsd, String outfileName, String jsprReportPath, String reportTitle,
        String rptSQL) {// w  ww. j a va 2 s.  co  m
    try {
        //Compile jrxml file. 
        System.out.println("Inside Jasper:" + jsprReportPath);
        Global.updateLogMsg(Global.logMsgID, "\r\nInside Jasper:" + jsprReportPath, Global.logTbl,
                Global.gnrlDateStr, Global.rnUser_ID);
        //System.in.read();
        String orgNm = Global.getOrgName(Global.UsrsOrg_ID).replace("\r\n", " ").replace("\r", " ")
                .replace("\n", " ");
        String pstl = Global.getOrgPstlAddrs(Global.UsrsOrg_ID).replace("\r\n", " ").replace("\r", " ")
                .replace("\n", " ");
        //Contacts Nos
        String cntcts = Global.getOrgContactNos(Global.UsrsOrg_ID).replace("\r\n", " ").replace("\r", " ")
                .replace("\n", " ");
        //Email Address
        String email = Global.getOrgEmailAddrs(Global.UsrsOrg_ID).replace("\r\n", " ").replace("\r", " ")
                .replace("\n", " ");
        String website = Global.getOrgWebsite(Global.UsrsOrg_ID).replace("\r\n", " ").replace("\r", " ")
                .replace("\n", " ");

        String online = "";
        if (!email.trim().equals("")) {
            online += "Email: " + email;
            if (!website.equals("")) {
                online += " Website: " + website;
            }
        }
        String fileName = jsprReportPath;
        File theFile = new File(fileName);
        JasperDesign jasperDesign = JRXmlLoader.load(theFile);
        //Build a new query
        //rptSQL
        String theQuery = rptSQL;
        //System.out.println(rptSQL);
        // update the data query
        JRDesignQuery newQuery = new JRDesignQuery();
        newQuery.setText(theQuery);
        jasperDesign.setQuery(newQuery);

        JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
        System.out.println("Compiled Successfully");
        Global.updateLogMsg(Global.logMsgID, "\r\nCompiled Successfully", Global.logTbl, Global.gnrlDateStr,
                Global.rnUser_ID);
        //JasperReport jasperReport = JasperCompileManager.compileReport(reportPath);            
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("P_ImageUrl", Global.getOrgImgsDrctry() + "/" + String.valueOf(Global.UsrsOrg_ID) + ".png");
        params.put("P_ReportTitle", reportTitle);
        params.put("P_OrgName", orgNm);
        params.put("P_OrgAddress", pstl);
        params.put("P_ContactInfo", cntcts);
        params.put("P_WebEmail", online);
        Connection connection;

        Class.forName("org.postgresql.Driver");
        connection = DriverManager.getConnection(
                "jdbc:postgresql://" + Global.Hostnme + ":" + Global.Portnum + "/" + Global.Dbase, Global.Uname,
                Global.Pswd);

        System.out.println("Filling report...");
        Global.updateLogMsg(Global.logMsgID, "\r\nFilling report...", Global.logTbl, Global.gnrlDateStr,
                Global.rnUser_ID);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, connection);

        if (outputUsd.equals("MICROSOFT EXCEL")) {
            JRXlsExporter xlsExporter = new JRXlsExporter();

            xlsExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            xlsExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outfileName));
            SimpleXlsReportConfiguration xlsReportConfiguration = new SimpleXlsReportConfiguration();
            //SimpleXlsExporterConfiguration xlsExporterConfiguration = new SimpleXlsExporterConfiguration();
            xlsReportConfiguration.setOnePagePerSheet(false);
            xlsReportConfiguration.setRemoveEmptySpaceBetweenRows(true);
            xlsReportConfiguration.setDetectCellType(true);
            xlsReportConfiguration.setWhitePageBackground(false);
            xlsExporter.setConfiguration(xlsReportConfiguration);
            xlsExporter.exportReport();
        } else if (outputUsd.equals("PDF")) {
            JasperExportManager.exportReportToPdfFile(jasperPrint, outfileName);
        } else if (outputUsd.equals("HTML")) {
            JasperExportManager.exportReportToHtmlFile(jasperPrint, outfileName);
        } else if (outputUsd.equals("STANDARD")) {
            JasperExportManager.exportReportToPdfFile(jasperPrint, outfileName);
        } else if (outputUsd.equals("MICROSOFT WORD")) {
            JRRtfExporter rtfExporter = new JRRtfExporter();
            rtfExporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            rtfExporter.setExporterOutput(new SimpleWriterExporterOutput(outfileName));
            SimpleRtfReportConfiguration rtfReportConfiguration = new SimpleRtfReportConfiguration();
            //SimpleRtfExporterConfiguration xlsExporterConfiguration = new SimpleRtfExporterConfiguration();              
            rtfExporter.setConfiguration(rtfReportConfiguration);
            rtfExporter.exportReport();
        } else if (outputUsd.equals("CHARACTER SEPARATED FILE (CSV)")) {
            JRCsvExporter exporter = new JRCsvExporter();
            exporter.setExporterInput(new SimpleExporterInput(jasperPrint));
            exporter.setExporterOutput(new SimpleWriterExporterOutput(outfileName));
            SimpleCsvReportConfiguration rtfReportConfiguration = new SimpleCsvReportConfiguration();
            //SimpleCsvExporterConfiguration xlsExporterConfiguration = new SimpleCsvExporterConfiguration();              
            exporter.setConfiguration(rtfReportConfiguration);
            exporter.exportReport();
        } else {
            JasperExportManager.exportReportToPdfFile(jasperPrint, outfileName);
        }

        //JasperViewer.viewReport(jasperPrint, false);
        //            if (Desktop.isDesktopSupported() && Global.callngAppType.equals("DESKTOP")) {
        //                try {
        //                    File myFile = new File(outfileName);
        //                    Desktop.getDesktop().open(myFile);
        //                } catch (IOException ex) {
        //                    // no application registered for PDFs
        //                }
        //            }
        //            Runtime runTime = Runtime.getRuntime();
        //            Process process = runTime
        //            .exec("C:/Users/richard.adjei-mensah/Desktop/Test1.pdf");
        //
        //            System.out.println("Closing report");
        //            process.destroy();
        connection.close();
    } catch (JRException ex) {
        System.out.println(ex.getMessage());
        Global.errorLog += ex.getMessage() + System.getProperty("line.separator") + ex.toString()
                + Arrays.toString(ex.getStackTrace());
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    } catch (ClassNotFoundException e) {
        System.out.println(e.getMessage());
        Global.errorLog += e.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(e.getStackTrace());
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    } catch (SQLException e) {
        System.out.println(e.getMessage());
        Global.errorLog += e.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(e.getStackTrace());
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        Global.errorLog += ex.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(ex.getStackTrace());
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    } finally {
        //System.out.println(ex.getMessage());
        //Global.errorLog += ex.getMessage();
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    }
    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        System.out.println(e.getMessage());
        Global.errorLog += e.getMessage() + System.getProperty("line.separator")
                + Arrays.toString(e.getStackTrace());
        Global.writeToLog();
        Global.updateLogMsg(Global.logMsgID, "\r\n\r\n\r\nLog Messages ==>\r\n\r\n" + Global.errorLog,
                Global.logTbl, Global.gnrlDateStr, Global.rnUser_ID);
    }
}

From source file:rems.Program.java

static void do_connection(String hostnm, String prtnum, String uname, String pwd, String dbase) {
    try {/*from w  ww .j  a  v  a2  s .  c  o m*/
        if (pwd.contains("(E)")) {
            pwd = Global.decrypt(pwd.replace("(E)", ""), Global.AppKey);
        }
        Global.connStr = "jdbc:postgresql://" + hostnm + ":" + prtnum + "/" + dbase + "";

        Class.forName("org.postgresql.Driver");
        Global.globalSQLConn = DriverManager.getConnection(Global.connStr, uname, pwd);
        Global.globalSQLConn.setAutoCommit(false);

        Global.Hostnme = hostnm;
        Global.Portnum = prtnum;
        Global.Uname = uname;
        Global.Pswd = pwd;
        Global.Dbase = dbase;
        int lvid = Global.getLovID("Security Keys");
        String apKey = Global.getEnbldPssblValDesc("AppKey", lvid);

        if (!apKey.equals("") && lvid > 0) {
            Global.AppKey = apKey;
        } else {
            Global.AppKey = "ROMeRRTRREMhbnsdGeneral KeyZzfor Rhomi|com Systems "
                    + "Tech. !Ltd Enterpise/Organization @763542ERPorbjkSOFTWARE"
                    + "asdbhi68103weuikTESTfjnsdfRSTLU../";
        }
    } catch (ClassNotFoundException ex) {
        Global.errorLog = ex.getMessage() + "\r\n\r\n" + Arrays.toString(ex.getStackTrace()) + "\r\n\r\n";
        Global.writeToLog();
        killThreads();
    } catch (SQLException ex) {
        Global.errorLog = ex.getMessage() + "\r\n\r\n" + Arrays.toString(ex.getStackTrace()) + "\r\n\r\n";
        Global.writeToLog();
        killThreads();
    } finally {
    }
}