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:br.com.senac.Bean.UsuarioBean.java

public void salvar() {
    try {/*  w  w  w. j a  v a2s. co m*/
        UsuarioDAO usuarioDAO = new UsuarioDAO();
        usuario.setSenha(DigestUtils.md5Hex(usuario.getSenha()));
        usuarioDAO.merge(usuario);

        usuario = new Usuario();

        TipoDAO tipoDAO = new TipoDAO();
        tipos = tipoDAO.listar();
        CidadeDAO cidadeDAO = new CidadeDAO();
        cidades = cidadeDAO.listar();
        EstadoDAO estadoDAO = new EstadoDAO();
        estados = estadoDAO.listar();

        usuarios = usuarioDAO.listar();

        Messages.addGlobalInfo("Usurio salvo com sucesso");
    } catch (RuntimeException erro) {
        Messages.addFlashGlobalError("Ocorreu um erro ao tentar salvar um novo Usurio");
        erro.printStackTrace();
    }
}

From source file:org.etudes.jforum.cache.JBossCacheEngine.java

/**
 * @see org.etudes.jforum.cache.CacheEngine#stop()
 *///from  w ww .j av  a 2  s.  c o m
public void stop() {

    try {
        if (this.cache != null) {
            this.cache.stopService();
        }
    } catch (RuntimeException e) {
        logger.warn("Error while stopping the jboss cache service: " + e);
        e.printStackTrace();
    }
}

From source file:es.urjc.mctwp.image.management.ImagePluginManager.java

/**
 * Obtain a node for header image informacion
 * /* w ww.  jav  a 2 s  .  c o  m*/
 * @param image
 * @return DOMNode
 * @throws ImageException
 */
public Node obtainNode(Image image) throws ImageException {
    Node result = null;

    List<ImagePlugin> lstPlugins = getPlugins(image);
    if (lstPlugins != null)
        for (ImagePlugin plugin : lstPlugins) {
            try {
                result = plugin.toXml(image);
                if (result != null)
                    break;
            } catch (RuntimeException re) {
                logger.error(re.getLocalizedMessage());
                re.printStackTrace();
            }
        }

    return result;
}

From source file:es.urjc.mctwp.image.management.ImagePluginManager.java

/**
 * Writes into outputDir a DICOM representation of the Image
 * /*ww  w  .  j  a v  a 2  s. co m*/
 * @param image
 * @param outputDir
 * @return List<File>
 * @throws ImageException
 */
public List<File> obtainDICOM(Image image, File outputDir) throws ImageException {
    List<File> result = null;

    List<ImagePlugin> lstPlugins = getPlugins(image);
    if (lstPlugins != null)
        for (ImagePlugin plugin : lstPlugins) {
            try {
                result = plugin.toDicom(image, outputDir);
                if (result != null)
                    break;
            } catch (RuntimeException re) {
                logger.error(re.getLocalizedMessage());
                re.printStackTrace();
            }
        }

    return result;
}

From source file:es.urjc.mctwp.image.management.ImagePluginManager.java

/**
 * Builds an image from a file//w  w w  . j a va2s.  co m
 * 
 * @param file
 *            file that represent the image
 * @return null if there is no creator for this file
 * @throws ImageException
 */
public PatientInfo obtainPatientStudyInfo(Image image) throws ImageException {
    PatientInfo result = null;

    List<ImagePlugin> lstPlugins = getPlugins(image);
    if (lstPlugins != null)
        for (ImagePlugin plugin : lstPlugins) {
            try {
                result = plugin.getPatientInfo(image);
                if (result != null)
                    break;
            } catch (RuntimeException re) {
                logger.error(re.getLocalizedMessage());
                re.printStackTrace();
            }
        }

    return result;
}

From source file:uk.ac.ebi.arrayexpress.utils.saxon.search.Controller.java

public String highlightQuery(Integer queryId, String fieldName, String text) {
    // return text;
    if (null == this.queryHighlighter) {
        // sort of lazy init if we forgot to specify more advanced
        // highlighter
        this.setQueryHighlighter(new QueryHighlighter());
    }/*from www .  j  av a  2  s  . c o  m*/
    QueryInfo queryInfo = this.queryPool.getQueryInfo(queryId);
    try {

        return queryHighlighter.setEnvironment(getEnvironment(queryInfo.getIndexId())).highlightQuery(queryInfo,
                fieldName, text);
    } catch (RuntimeException e) {
        e.printStackTrace();
        logger.debug("DEBUG1!!->" + queryId);
        logger.error("ERROR!!->");
        logger.error("ERROR12!!->" + queryInfo);
        logger.error("ERROR2!!->" + queryInfo.getIndexId());
        logger.error("ERROR3!!->" + getEnvironment(queryInfo.getIndexId()));
    }
    return null;
}

From source file:es.urjc.mctwp.image.management.ImagePluginManager.java

/**
 * Obtain a thumbnail from an image/*from   ww  w .  j a v  a2s. c  o m*/
 * 
 * @param image
 * @return thumbnail
 * @throws ImageException
 */
public ThumbNail obtainThumb(Image image) throws ImageException {
    ThumbNail result = null;

    List<ImagePlugin> lstPlugins = getPlugins(image);
    if (lstPlugins != null)
        for (ImagePlugin plugin : lstPlugins) {

            try {
                File thumb = plugin.toPng(image);
                if (thumb != null) {
                    result = new ThumbNail();
                    result.setContent(thumb);
                    result.setId(image.getId());

                    PatientInfo info = plugin.getPatientInfo(image);
                    if (info != null)
                        result.setPatInfo(info);

                    break;
                }
            } catch (RuntimeException re) {
                logger.error(re.getLocalizedMessage());
                re.printStackTrace();
            }
        }

    return result;
}

From source file:fm.krui.kruifm.TrackUpdateHandler.java

@Override
protected Integer doInBackground(Void... arg0) {

    // Get song info and album art URL
    try {//www .  j a  v a  2s .c o  m
        trackInfo = getSongInfo();
        Log.v(TAG, "---");
        Log.v(TAG, "Returned track name = " + trackInfo[0]);
        Log.v(TAG, "Returned track artist = " + trackInfo[1]);
        Log.v(TAG, "Returned track album = " + trackInfo[2]);
        Log.v(TAG, "---");
    } catch (RuntimeException e) {
        Log.e(TAG, "RuntimeException thrown when getting song info!");
        e.printStackTrace();
    }

    // Check if the returned info is a new track or the same as the previous track
    if ((!trackInfo[0].equals(currentTrackInfo[0])) || (!trackInfo[1].equals(currentTrackInfo[1]))
            || (!trackInfo[2].equals(currentTrackInfo[2]))) {
        Log.v(TAG, "Song information has changed. UI will be updated.");

        // UI UPDATE HERE
        listener.broadcastMessage(StreamService.BROADCAST_COMMAND_UPDATE_PENDING);

        // If either the song, artist, or album name is different than the current song playing, we have downloaded a new track and we need to update the UI.
        // If album art update is requested, get the location of the album art and download it.
        if (updateAlbumArt) {
            artUrl = getAlbumArtURL(trackInfo[1], trackInfo[2]);
            Log.v(TAG, "Returned album art = " + artUrl);
            Log.v(TAG, "Grabbing album art from " + artUrl);
            albumArt = downloadAlbumArt(artUrl);
        } else {
            Log.v(TAG, "User has elected to not download album art. Skipping...");
        }

    } else {
        // If the information is the same, don't waste resources updating information with itself.
        Log.v(TAG, "Song information is equivalent to the song currently playing. No UI update necessary.");
        return NO_UPDATE;
    }

    return UPDATE_REQUESTED;
}

From source file:com.hmatalonga.greenhub.managers.sampling.DataEstimator.java

@Override
public void onReceive(Context context, Intent intent) {
    if (context == null) {
        LOGE(TAG, "Error, context is null");
        return;/*from   w ww . j  a  v  a2s .  co  m*/
    }

    if (intent == null) {
        LOGE(TAG, "Data Estimator error, received intent is null");
        return;
    }

    LOGI(TAG, "onReceive action => " + intent.getAction());

    if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) {
        try {
            level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
            scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
            mHealth = intent.getIntExtra(BatteryManager.EXTRA_HEALTH, 0);
            plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0);
            present = intent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT);
            status = intent.getIntExtra(BatteryManager.EXTRA_STATUS, 0);
            technology = intent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
            temperature = ((float) intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, 0)) / 10;
            voltage = ((float) intent.getIntExtra(BatteryManager.EXTRA_VOLTAGE, 0)) / 1000;
        } catch (RuntimeException e) {
            e.printStackTrace();
        }

        // We don't send battery level alerts here because we need to check if the level changed
        // So we verify that inside the DataEstimator Service

        if (temperature > SettingsUtils.fetchTemperatureWarning(context)) {
            if (SettingsUtils.isBatteryAlertsOn(context) && SettingsUtils.isTemperatureAlertsOn(context)) {

                // Check temperature limit rate
                Calendar lastAlert = Calendar.getInstance();
                long lastSavedTime = SettingsUtils.fetchLastTemperatureAlertDate(context);

                // Set last alert time with saved preferences
                if (lastSavedTime != 0) {
                    lastAlert.setTimeInMillis(lastSavedTime);
                }
                int minutes = SettingsUtils.fetchTemperatureAlertsRate(context);

                lastAlert.add(Calendar.MINUTE, minutes);

                // If last saved time isn't default and now is after limit rate then notify
                if (lastSavedTime == 0 || Calendar.getInstance().after(lastAlert)) {
                    // Notify for temperature alerts...
                    if (temperature > SettingsUtils.fetchTemperatureHigh(context)) {
                        Notifier.batteryHighTemperature(context);
                        SettingsUtils.saveLastTemperatureAlertDate(context, System.currentTimeMillis());
                    } else if (temperature <= SettingsUtils.fetchTemperatureHigh(context)
                            && temperature > SettingsUtils.fetchTemperatureWarning(context)) {
                        Notifier.batteryWarningTemperature(context);
                        SettingsUtils.saveLastTemperatureAlertDate(context, System.currentTimeMillis());
                    }
                }
            }
        }
    }

    // On some phones, scale is always 0.
    if (scale == 0)
        scale = 100;

    if (level > 0) {
        Inspector.setCurrentBatteryLevel(level, scale);

        // Location updates disabled for now
        // requestLocationUpdates();

        // Update last known location...
        // if (lastKnownLocation == null) {
        //    lastKnownLocation = LocationInfo.getLastKnownLocation(context);
        // }

        Intent service = new Intent(context, DataEstimatorService.class);
        service.putExtra("OriginalAction", intent.getAction());
        service.fillIn(intent, 0);

        if (SettingsUtils.isPowerIndicatorShown(context)) {
            LOGI(TAG, "Updating notification status bar");
            Notifier.updateStatusBar(context);
        }

        EventBus.getDefault().post(new BatteryLevelEvent(level));

        startWakefulService(context, service);
    }
}

From source file:se.vgregion.incidentreport.pivotaltracker.impl.PivotalTrackerServiceImpl.java

/** */
private TyckTillProjectData getSingleProject(String projectId, String token) throws Exception {
    if (token == null) {
        throw new RuntimeException("Token cannot be null. Please set it first.");
    }//w ww  .  jav  a2  s.  com

    DefaultHttpClient client = getNewClient();
    TyckTillProjectData result = null;
    try {
        HttpResponse response = HTTPUtils.makeRequest(GET_PROJECT + "/" + projectId, token, client);
        HttpEntity entity = response.getEntity();

        // Convert the xml response into an object
        result = getProjectData(entity.getContent()).get(0);
    } catch (RuntimeException e) {
        e.printStackTrace();
    } finally {
        client.getConnectionManager().shutdown();
    }
    return result;
}