Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.jbosson.plugins.amq.ArtemisServerDiscoveryComponent.java

public final Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {

    // populate system properties in plugin properties
    Set<DiscoveredResourceDetails> discoveredResources = new LinkedHashSet<DiscoveredResourceDetails>();
    Map<String, List<DiscoveredResourceDetails>> duplicatesByKey = new LinkedHashMap<String, List<DiscoveredResourceDetails>>();

    // get discovered processes that match the process-scan
    @SuppressWarnings("unchecked")
    List<ProcessScanResult> discoveredProcesses = context.getAutoDiscoveredProcesses();

    for (ProcessScanResult process : discoveredProcesses) {
        try {//from  w  w w  . ja  v a 2s  .  co m
            ProcessInfo processInfo = process.getProcessInfo();
            DiscoveredResourceDetails details1 = discoverResourceDetails(context, processInfo);
            if (details1 != null) {
                if (discoveredResources.contains(details1)) {
                    List<DiscoveredResourceDetails> duplicates = duplicatesByKey.get(details1.getResourceKey());
                    if (duplicates == null) {
                        duplicates = new ArrayList<DiscoveredResourceDetails>();
                        duplicatesByKey.put(details1.getResourceKey(), duplicates);
                    }
                    duplicates.add(details1);
                }
                discoveredResources.add(details1);
            }
        } catch (RuntimeException re) {
            re.printStackTrace();
            // Don't let a runtime exception for a particular ProcessInfo cause the entire discovery scan to fail.
            if (log.isDebugEnabled()) {
                log.debug("Error when trying to discover Fuse Server process [" + process + "].", re);
            } else {
                log.warn("Error when trying to discover Fuse Server process [" + process
                        + "] (enable DEBUG for stack trace): " + re);
            }
        }
    }

    for (String duplicateKey : duplicatesByKey.keySet()) {
        List<DiscoveredResourceDetails> duplicates = duplicatesByKey.get(duplicateKey);
        log.error("Multiple Resources with the same key (" + duplicateKey
                + ") were discovered - none will be reported to the plugin container! This most likely means that there are multiple java processes running with the same value for the "
                + getResourceKeyProperty(context.getDefaultPluginConfiguration())
                + " system property specified on their command lines. Here is the list of Resources: "
                + duplicates);
        discoveredResources.remove(duplicates.get(0));
    }

    // populate Fuse Server specific properties
    Set<DiscoveredResourceDetails> resultSet = new HashSet<DiscoveredResourceDetails>();
    for (DiscoveredResourceDetails details : discoveredResources) {
        try {
            if (!populateResourceProperties(context, details)) {
                // required resource type 'marker' property was missing, for e.g. a custom versionFile
                continue;
            }
            // configure log file after resource properties are set
            final Configuration pluginConfiguration = details.getPluginConfiguration();
            final ProcessInfo processInfo = details.getProcessInfo();
            final String homePath = getSystemPropertyValue(processInfo,
                    pluginConfiguration.getSimpleValue(HOME_PROPERTY));
            initLogEventSourcesConfigProp(new File(homePath), pluginConfiguration, processInfo);

            resultSet.add(details);
        } catch (InvalidPluginConfigurationException e) {
            log.warn(String.format("Ignoring resource %s, due to error: %s", details.getResourceName(),
                    e.getMessage()), e);
        }
    }

    return resultSet;
}

From source file:org.sakaiproject.tool.assessment.business.questionpool.QuestionPoolTreeImpl.java

/**
 * Get the HTML id of the current object.
 *
 * @return An HTML representation of the pool Id.
 *///from   w ww.  ja v a2s. c  o m
public String getCurrentObjectHTMLId() {
    QuestionPoolFacade current = (QuestionPoolFacade) getCurrentObject();
    try {
        QuestionPoolFacade parent = (QuestionPoolFacade) getParent();
        if (parent == null) {
            Collection childList = getChildList(new Long("0"));

            return Integer.toString(((ArrayList) childList)
                    .indexOf(((QuestionPoolFacade) getCurrentObject()).getQuestionPoolId()) + 1);
        } else {
            setCurrentId(current.getParentPoolId());
            String result = getCurrentObjectHTMLId();
            Collection childList = getChildList(parent.getQuestionPoolId());
            setCurrentId(current.getQuestionPoolId());

            return result + "-" + (((ArrayList) childList)
                    .indexOf(((QuestionPoolFacade) getCurrentObject()).getQuestionPoolId()) + 1);
        }
    }

    catch (RuntimeException e) {
        e.printStackTrace();
        return "0";
    }

}

From source file:org.netxilia.server.rest.html.sheet.impl.SheetModelServiceImpl.java

private SheetModel buildModel(SheetFullName sheetName, boolean overviewMode, int mainSheetColumnCount,
        int startRow, Formula filter, boolean createSheetIfMissing)
        throws StorageException, NetxiliaBusinessException {
    ISheet sheet = null;/* w  w  w  . j a va2 s. co  m*/

    try {
        SheetType type = sheetName.getType();

        try {
            sheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId()).getSheet(sheetName.getSheetName());
        } catch (NotFoundException e) {
            if (createSheetIfMissing) {
                try {
                    sheet = workbookProcessor.getWorkbook(sheetName.getWorkbookId())
                            .addNewSheet(sheetName.getSheetName(), type);
                } catch (AlreadyExistsException e1) {
                    // if the sheet was created in the mean time - nothing to do
                }
            } else {
                throw new NotFoundException("Cannot find sheet:" + sheetName);
            }
        }

        boolean readOnly = true;
        try {
            aclService.checkPermission(sheet.getFullName(), Permission.write);
            readOnly = false;
        } catch (AccessControlException e) {
            // readonly
        }

        SheetDimensions dim = sheet.getDimensions().getNonBlocking();
        int totalColumns = dim.getColumnCount() + getExtraCols(type);

        // synchronize the number of columns from summary and main sheet
        if (type == SheetType.summary) {
            totalColumns = mainSheetColumnCount;
        }
        SheetData sheetData = sheet.receiveSheet().getNonBlocking();
        List<ColumnModel> columns = new LazyArrayList<ColumnModel>(totalColumns, new LazyColumnResolver());
        List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking();

        SpanTable spans = new SpanTable(sheetData.getSpans());

        for (int c = 0; c < columnData.size(); ++c) {
            AreaReference fullColumnRef = new AreaReference(
                    new CellReference(null, CellReference.MAX_ROW_INDEX, c));

            Alias alias = findAliasByReference(sheetData, fullColumnRef);
            columns.add(new ColumnModel(columnData.get(c), alias, defaultColumnWidth));
        }

        List<RowModel> rows = Collections.emptyList();
        // int totalRows = 0;

        int firstRow = startRow;
        int lastRow = Math.min(startRow + dim.getRowCount() + getExtraRows(type), pageSize + startRow);
        int rowCount = lastRow - firstRow;

        List<Integer> rowIds = null;
        if (filter != null) {
            rowIds = sheetOperations.filter(sheet, filter).getNonBlocking();
            if (rowIds.size() > 0) {
                firstRow = rowIds.get(0);
                lastRow = rowIds.get(rowIds.size() - 1) + 1;
            } else {
                lastRow = firstRow;
            }
            rowCount = rowIds.size();
        }
        rows = new LazyArrayList<RowModel>(rowCount, new LazyRowResolver(firstRow, totalColumns));
        List<RowData> rowData = sheet.receiveRows(Range.range(firstRow, lastRow)).getNonBlocking();

        Matrix<CellData> cellData = sheet
                .receiveCells(new AreaReference(new CellReference(sheetName.getSheetName(), firstRow, 0),
                        new CellReference(sheetName.getSheetName(), lastRow, totalColumns)))
                .getNonBlocking();

        for (Integer rowIndex : rowIds != null ? getRowIdIterable(rowIds)
                : getRowIdIterable(firstRow, lastRow)) {
            int relativeRowIndex = rowIndex - firstRow;
            if (relativeRowIndex >= rowData.size()) {
                continue;
            }
            RowData row = rowData.get(relativeRowIndex);
            if (row == null) {
                continue;
            }

            List<CellModel> cells = new LazyArrayList<CellModel>(totalColumns, new LazyCellResolver());

            for (CellData cell : cellData.getRow(relativeRowIndex)) {
                CellModel cellModel;

                int colSpan = cell != null ? spans.getColSpan(cell.getReference()) : 1;
                int rowSpan = cell != null ? spans.getRowSpan(cell.getReference()) : 1;

                if (cell == null) {
                    cellModel = new CellModel(emptyCellContent);
                } else if (colSpan < 0 || rowSpan < 0) {
                    // the cell is part of a merged area
                    cellModel = new CellModel(skipCellContent);
                } else {
                    ColumnData columnDataForCell = cell.getReference().getColumnIndex() < columnData.size()
                            ? columnData.get(cell.getReference().getColumnIndex())
                            : null;
                    RichValue formattedValue = styleService.formatCell(sheetName.getWorkbookId(), cell, row,
                            columnDataForCell);

                    StringBuilder cellContent = new StringBuilder();
                    cellContent.append("<td");
                    if (cell.getFormula() != null) {
                        cellContent.append(" title='").append(cell.getFormula()).append("'");
                    } else if (cell.getValue() != null) {
                        // XXX assumes Strings are not formatted which may be wrong. other types may also be
                        // skipped (i.e. BINARY)
                        if (cell.getValue().getValueType() != GenericValueType.STRING) {
                            cellContent.append(" title='").append(cell.getValue().getStringValue()).append("'");
                        }
                    }

                    if (formattedValue.getStyles() != null
                            && formattedValue.getStyles().toString().length() > 0) {
                        cellContent.append(" class='").append(formattedValue.getStyles()).append("'");
                    }

                    if (colSpan > 1) {
                        cellContent.append(" colspan='").append(colSpan).append("'");
                    }
                    if (rowSpan > 1) {
                        cellContent.append(" rowspan='").append(rowSpan).append("'");
                    }

                    cellContent.append(">");
                    if (colSpan > 1) {
                        cellContent.append("<div class='merge'>");
                        cellContent.append(formattedValue.getDisplay());
                        cellContent.append("</div>");
                    } else {
                        cellContent.append(formattedValue.getDisplay());
                    }
                    cellContent.append("</td>");
                    cellModel = new CellModel(cellContent.toString());
                }
                cells.add(cellModel);
            }
            rows.add(new RowModel(row, defaultRowHeight, cells));
        }

        SheetModel model = new SheetModel(jsonSerializer, overviewMode, sheetName, rows, columns,
                sheetData.getAliases(), sheetData.getCharts(), sheetData.getSpans(), rowCount, pageSize,
                readOnly);
        return model;
    } catch (RuntimeException ex) {
        ex.printStackTrace();
        throw ex;
    }
}

From source file:de.fu_berlin.inf.dpp.Saros.java

protected void setupLoggers() {
    /*/*w  ww . ja  v a2 s . co  m*/
     * HACK this is not the way OSGi works but it currently fulfill its
     * purpose
     */
    final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

    try {
        // change the context class loader so Log4J will find the appenders
        Thread.currentThread().setContextClassLoader(STFController.class.getClassLoader());

        PropertyConfigurator.configure(Saros.class.getClassLoader().getResource("saros.log4j.properties")); //$NON-NLS-1$
    } catch (RuntimeException e) {
        System.err.println("initializing log support failed"); //$NON-NLS-1$
        e.printStackTrace();
    } finally {
        Thread.currentThread().setContextClassLoader(contextClassLoader);
    }

    log = Logger.getLogger("de.fu_berlin.inf.dpp"); //$NON-NLS-1$

}

From source file:net.schweerelos.parrot.ui.GraphViewComponent.java

private void fireNodeSelected(NodeWrapper newSelection) {
    List<PickListener> listeners;
    synchronized (this) {
        listeners = Collections.synchronizedList(pickListeners);
    }//  ww  w . j  av a 2s  .  c o m
    synchronized (listeners) {
        for (PickListener listener : listeners) {
            try {
                listener.picked(newSelection);
            } catch (RuntimeException re) {
                re.printStackTrace();
                pickListeners.remove(listener);
            }
        }
    }
}

From source file:nl.nikhef.eduroam.WiFiEduroam.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.logon);//from   w  w  w .  j a v  a 2  s .  c om

    username = (EditText) findViewById(R.id.username);
    password = (EditText) findViewById(R.id.password);

    alertDialog = new AlertDialog.Builder(this).create();

    Button myButton = (Button) findViewById(R.id.button1);
    if (myButton == null)
        throw new RuntimeException("button1 not found. Odd");

    myButton.setOnClickListener(new Button.OnClickListener() {
        public void onClick(View _v) {
            if (busy) {
                return;
            }
            busy = true;
            // Most of this stuff runs in the background
            Thread t = new Thread() {
                @Override
                public void run() {
                    try {
                        if (csr == null) {
                            updateStatus("Generating certificate signing request... This may take a while");
                            csr = new CSR(username.getText().toString() + "@nikhef.nl");
                        }

                        updateStatus("Sending CSR to the server...");
                        postData(username.getText().toString(), password.getText().toString(), csr.getCSR());

                        updateStatus("Installing WiFi profile...");
                        if (android.os.Build.VERSION.SDK_INT >= 11 && android.os.Build.VERSION.SDK_INT <= 17) {
                            installCertificates();
                        } else if (android.os.Build.VERSION.SDK_INT >= 18) {
                            saveWifiConfig();
                            updateStatus("All done!");
                            // Clear the password field in the UI thread
                            mHandler.post(new Runnable() {
                                @Override
                                public void run() {
                                    password.setText("");
                                };
                            });

                        } else {
                            throw new RuntimeException("What version is this?! API Mismatch");
                        }
                    } catch (RuntimeException e) {
                        updateStatus("Runtime Error: " + e.getMessage());
                        e.printStackTrace();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    busy = false;
                }
            };
            t.start();

        }
    });

}

From source file:org.vpac.grisu.client.view.swing.mainPanel.Grisu.java

/**
 * This method initializes jContentPane/*from  ww  w  .j a v  a 2  s.com*/
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
    if (jContentPane == null) {
        jContentPane = new JPanel();
        jContentPane.setLayout(new BorderLayout());
        try {
            jContentPane.add(getJTabbedPane(), BorderLayout.CENTER);
        } catch (RuntimeException e) {
            // something's gone wrong with something. Exiting...
            e.printStackTrace();
            Utils.showErrorMessage(jFrame, em.getUser(), "severeError", Utils.getStackTrace(e), e);
            System.exit(1);
        }

    }
    return jContentPane;
}

From source file:com.sun.japex.ChartGenerator.java

private int generateTestCaseLineCharts(String baseName, String extension) {
    int nOfFiles = 0;
    List<DriverImpl> driverInfoList = _testSuite.getDriverInfoList();

    // Get number of tests from first driver
    final int nOfTests = driverInfoList.get(0).getAggregateTestCases().size();

    int groupSizesIndex = 0;
    int[] groupSizes = calculateGroupSizes(nOfTests, _plotGroupSize);

    try {//from   w  w w.  j av  a2  s.  c  om
        String resultUnit = _testSuite.getParam(Constants.RESULT_UNIT);

        // Generate charts 
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        int i = 0, thisGroupSize = 0;
        for (; i < nOfTests; i++) {

            for (DriverImpl di : driverInfoList) {
                TestCaseImpl tc = (TestCaseImpl) di.getAggregateTestCases().get(i);

                dataset.addValue(tc.getDoubleParamNoNaN(Constants.RESULT_VALUE),
                        _plotDrivers ? di.getName() : tc.getName(), _plotDrivers ? tc.getName() : di.getName());
            }

            thisGroupSize++;

            // Generate chart for this group if complete
            if (thisGroupSize == groupSizes[groupSizesIndex]) {
                JFreeChart chart = ChartFactory.createLineChart(
                        (_plotDrivers ? "Results per Driver (" : "Results per Test (") + resultUnit + ")", "",
                        resultUnit, dataset, PlotOrientation.VERTICAL, true, true, false);

                configureLineChart(chart);

                chart.setAntiAlias(true);
                ChartUtilities.saveChartAsJPEG(new File(baseName + Integer.toString(nOfFiles) + extension),
                        chart, _chartWidth, _chartHeight);

                nOfFiles++;
                groupSizesIndex++;
                thisGroupSize = 0;
                dataset = new DefaultCategoryDataset();
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        e.printStackTrace();
    }

    return nOfFiles;
}

From source file:istata.service.StataService.java

/**
 * start a stata program instance (under development)
 *//*www  .j a v  a 2s .c  o  m*/
public void destroyStata() {
    logger.info("Destroy Stata");

    try {
        IStata stata = stataFactory.getInstance();
        stata.destroy();
    } catch (RuntimeException ex) {
        logger.warn("Destroy Stata failed", ex);
        ex.printStackTrace();
    }
}

From source file:org.red5.server.war.RootContextLoaderServlet.java

/**
 * Clearing the in-memory configuration parameters, we will receive
 * notification that the servlet context is about to be shut down
 *///w  w  w.j  av  a2s. c o m
@Override
public void contextDestroyed(ServletContextEvent sce) {
    synchronized (instance) {
        logger.info("Webapp shutdown");
        // XXX Paul: grabbed this from
        // http://opensource.atlassian.com/confluence/spring/display/DISC/Memory+leak+-+classloader+won%27t+let+go
        // in hopes that we can clear all the issues with J2EE containers
        // during shutdown
        try {
            ServletContext ctx = sce.getServletContext();
            // if the ctx being destroyed is root then kill the timer
            if (ctx.getContextPath().equals("/ROOT")) {
                timer.cancel();
            } else {
                // remove from registered list
                registeredContexts.remove(ctx);
            }
            // prepare spring for shutdown
            Introspector.flushCaches();
            // dereg any drivers
            for (Enumeration e = DriverManager.getDrivers(); e.hasMoreElements();) {
                Driver driver = (Driver) e.nextElement();
                if (driver.getClass().getClassLoader() == getClass().getClassLoader()) {
                    DriverManager.deregisterDriver(driver);
                }
            }
            // shutdown jmx
            JMXAgent.shutdown();
            // shutdown spring
            Object attr = ctx.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
            if (attr != null) {
                // get web application context from the servlet context
                ConfigurableWebApplicationContext applicationContext = (ConfigurableWebApplicationContext) attr;
                ConfigurableBeanFactory factory = applicationContext.getBeanFactory();
                // for (String scope : factory.getRegisteredScopeNames()) {
                // logger.debug("Registered scope: " + scope);
                // }
                try {
                    for (String singleton : factory.getSingletonNames()) {
                        logger.debug("Registered singleton: " + singleton);
                        factory.destroyScopedBean(singleton);
                    }
                } catch (RuntimeException e) {
                }
                factory.destroySingletons();

                ctx.removeAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
                applicationContext.close();
            }
            instance.getContextLoader().closeWebApplicationContext(ctx);
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            // http://jakarta.apache.org/commons/logging/guide.html#Classloader_and_Memory_Management
            // http://wiki.apache.org/jakarta-commons/Logging/UndeployMemoryLeak?action=print
            LogFactory.release(Thread.currentThread().getContextClassLoader());
        }
    }
}