Example usage for java.lang IllegalArgumentException printStackTrace

List of usage examples for java.lang IllegalArgumentException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:br.gov.lexml.server.LexMLOAIHandler.java

/**
 * init is called one time when the Servlet is loaded. This is the place where one-time
 * initialization is done. Specifically, we load the properties file for this application, and
 * create the AbstractCatalog object for subsequent use.
 * // ww w.ja v  a2s.  c o m
 * @param config servlet configuration information
 * @exception ServletException there was a problem with initialization
 */
@Override
public void init(final ServletConfig config) throws ServletException {
    super.init(config);

    getBuildVersion();

    try {
        // Trecho para inicializar o layer lexml para provimento
        // dos registros
        try {
            LexMLOAI.helper.inicializar();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
            throw new ServletException(e.getMessage());
        } catch (Throwable e) {
            e.printStackTrace();
            throw new ServletException(e.getMessage());
        }
        // fim inicializacao do LexmL
        HashMap attributes = null;
        ServletContext context = getServletContext();
        Properties properties = (Properties) context.getAttribute(PROPERTIES_SERVLET_CONTEXT_ATTRIBUTE);
        if (properties == null) {
            final String PROPERTIES_INIT_PARAMETER = "properties";
            log.debug("OAIHandler.init(..): No '" + PROPERTIES_SERVLET_CONTEXT_ATTRIBUTE
                    + "' servlet context attribute. Trying to use init parameter '" + PROPERTIES_INIT_PARAMETER
                    + "'");

            InputStream in = getClass().getResourceAsStream("/oaicat.properties");
            if (in != null) {
                properties = new Properties();
                properties.load(in);
                attributes = getAttributes(properties);
            } else {
                log.error("Arquivo oaicat.properties nao encontrado.");
            }
        } else {
            log.debug("Load context properties");
            attributes = getAttributes(properties);
        }

        log.debug("Store global properties");
        attributesMap.put("global", attributes);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
    } catch (IOException e) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
    } catch (Throwable e) {
        e.printStackTrace();
        throw new ServletException(e.getMessage());
    } finally {
        JPAUtil.closeEntityManager();
    }
}

From source file:org.elasticwarehouse.core.graphite.RRDManager.java

public boolean addValue(long t, String source, Long value) throws IOException {
    Sample sample = rrdDb_.createSample();
    sample.setTime(t);/*from   ww w .  j a  v a2s  .  co  m*/
    sample.setValue(source, value);
    //logger.debug(sample.dump());
    try {
        sample.update();
        return true;
    } catch (IllegalArgumentException e) {
        EWLogger.logerror(e);
        e.printStackTrace();
        return false;
    }
}

From source file:de.fuberlin.wiwiss.marbles.loading.CacheController.java

/**
 * Adds retrieved URL data to the cache//w w w .  j ava2 s.c  om
 * @param url   The URL that was retrieved
 * @param data   The retrieved data
 * @param method   Used to obtain metadata
 */

public synchronized void addURLData(String url, Graph data, HttpMethod method) {
    RepositoryConnection dataConn = null;
    InferencerConnection inferencerConn = null;
    RepositoryConnection metaDataConn = null;

    try {
        dataConn = dataRepository.getConnection();
        inferencerConn = (InferencerConnection) dataRepository.getSail().getConnection();
        metaDataConn = metaDataRepository.getConnection();

        URI urlDataContext = dataRepository.getValueFactory().createURI(url);
        URI urlInferencerContext = dataRepository.getValueFactory().createURI(url);
        URI urlMetadata = metaDataRepository.getValueFactory().createURI(url);

        /* Remove cached data and previous metadata */
        inferencerConn.removeInferredStatement((Resource) null, null, null, urlInferencerContext);
        /* 
         * Because inferencerConn now holds the transaction lock on the store,
         * we need to commit changes first or we'll run into a deadlock when removing statements
         * using dataConn. They could be removed using dataConn; but the problem
         * would remain for the adding of statements.
         */
        inferencerConn.commit();
        dataConn.remove((Resource) null, null, null, urlDataContext);
        metaDataConn.remove(urlMetadata, null, null, contextCacheDataURI);

        /* Add retrieved data */
        if (data != null)
            dataConn.add(data);

        /* Add metadata */
        if (method != null) {
            for (String headerField : cachedHeaderFields) {
                Header header;

                if (null != (header = method.getResponseHeader(headerField))) {
                    metaDataConn.add(urlMetadata,
                            metaDataRepository.getValueFactory().createURI(Constants.nsHTTP, headerField),
                            metaDataRepository.getValueFactory().createLiteral(header.getValue()),
                            contextCacheDataURI);
                }
            }

            /* Add status code */
            if (null != method
                    .getStatusLine()) /* or we'll run into a NullPointerException when calling getStatusCode() */
                metaDataConn.add(urlMetadata,
                        metaDataRepository.getValueFactory().createURI(Constants.nsHTTP, "responseCode"),
                        metaDataRepository.getValueFactory().createLiteral(method.getStatusCode()),
                        contextCacheDataURI);
        }

        /* We'll make use of the date header to specify when the document was retrieved */
        metaDataConn.add(urlMetadata, metaDataRepository.getValueFactory().createURI(Constants.nsHTTP, "date"),
                metaDataRepository.getValueFactory().createLiteral(DateUtil.formatDate(new Date())),
                contextCacheDataURI);

        /* Commit */
        //         inferencerConn.commit();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (RepositoryException e) {
        e.printStackTrace();
    } catch (SailException e) {
        e.printStackTrace();
    } finally {
        if (dataConn != null)
            try {
                dataConn.close();
            } catch (RepositoryException e) {
                e.printStackTrace();
            }
        if (inferencerConn != null)
            try {
                inferencerConn.close();
            } catch (SailException e) {
                e.printStackTrace();
            }
        if (metaDataConn != null)
            try {
                metaDataConn.close();
            } catch (RepositoryException e) {
                e.printStackTrace();
            }
    }
}

From source file:org.kalypso.model.hydrology.internal.binding.cm.LinearSumGenerator.java

/**
 * @see org.kalypso.model.rcm.binding.ILinearSumGenerator#getTimestamp()
 *//*  w  w w.  ja va  2  s  .co m*/
@Override
public LocalTime getTimestamp() {
    /* Get the property. */
    final String timestampText = getProperty(PROPERTY_TIMESTAMP, String.class);
    if (StringUtils.isBlank(timestampText))
        return null;

    try {
        /* Parse the timestamp. */
        return TimestampHelper.parseTimestamp(timestampText);
    } catch (final IllegalArgumentException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:com.ashok.location_basicexamplefromgoogle.MainActivity.java

/** ---------------------------------------------------
 * Display Latitute, Longitude and City name using Reverse-GeoCoding
 *//*from ww w  .  j a v  a  2  s . c o m*/
protected void displayLatLong_and_streetAddr(Location mLastLocation) {
    Double latitude, longitude;
    String addressLine = "addressLine";
    String cityAndState = "City&stateName";
    String countryName = "CountryName";
    latitude = mLastLocation.getLatitude();
    longitude = mLastLocation.getLongitude();

    //Get City, State anc Country name by using Reverse-Geocoding
    Geocoder geoCoder = new Geocoder(this, Locale.getDefault());
    try {//Reverse GeoCoding - Get street-address from Latitude, Longitude
        List<Address> address = geoCoder.getFromLocation(latitude, longitude, 1);
        addressLine = address.get(0).getAddressLine(0);
        cityAndState = address.get(0).getAddressLine(1);
        countryName = address.get(0).getAddressLine(2);
    } catch (IOException ioe) {
        Log.i(TAG, "Error:ReverseGeoCoding:NetworkNotAvailable:display_lat_lng_cityName()");
        mTxtError.setText("Error:ReverseGeoCoding:IOException.NetworkNotAvailable.display_lat_lng_cityName()");
        ioe.printStackTrace();
    } catch (IllegalArgumentException iae) {
        Log.i(TAG, "Error:ReverseGeoCoding:IllegalArgs:display_lat_lng_cityName()");
        mTxtError.setText("Error:ReverseGeoCoding:IllegalArgs:display_lat_lng_cityName()");
        iae.printStackTrace();
    }
    mLatitudeText.setText(String.format("%s: %f", mLatitudeLabel, latitude));
    mLongitudeText.setText(String.format("%s: %f", mLongitudeLabel, longitude));
    mTxtAddressLine.setText(addressLine);
    mTxtCityAndState.setText(cityAndState);
    mTxtCountryName.setText(countryName);
}

From source file:org.cocos2dx.plugin.UserFacebook.java

public void logPurchase(JSONObject info) {
    int length = info.length();
    if (3 == length) {
        try {//from   w w w  . j  a v  a2s.c  om
            Double purchaseNum = info.getDouble("Param1");
            String currency = info.getString("Param2");

            JSONObject params = info.getJSONObject("Param3");
            Iterator<?> keys = params.keys();
            Bundle bundle = new Bundle();
            while (keys.hasNext()) {
                String key = keys.next().toString();
                bundle.putString(key, params.getString(key));
            }
            Currency currencyStr = null;
            try {
                currencyStr = Currency.getInstance(currency);
            } catch (IllegalArgumentException e) {
                currencyStr = Currency.getInstance(Locale.getDefault());
                e.printStackTrace();
            }

            FacebookWrapper.getAppEventsLogger().logPurchase(new BigDecimal(purchaseNum), currencyStr, bundle);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    } else if (2 == length) {
        try {
            Double purchaseNum = info.getDouble("Param1");
            String currency = info.getString("Param2");
            FacebookWrapper.getAppEventsLogger().logPurchase(new BigDecimal(purchaseNum),
                    Currency.getInstance(currency));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}

From source file:fr.bmartel.android.flowerpower.FlowerPowerActivity.java

@Override
protected void onPause() {
    super.onPause();
    //unregister receiver on pause
    //unregisterReceiver(mGattUpdateReceiver);

    if (!toSecondLevel) {

        if (device_list_view != null) {
            device_list_view.setAdapter(null);
        }//w  w  w.j  a v  a2  s .com

        if (currentService != null) {

            currentService.disconnectall();
            currentService.getListViewAdapter().clear();
            currentService.getListViewAdapter().notifyDataSetChanged();
            currentService.clearListAdapter();
        }
    }

    if (dialog != null) {
        dialog.cancel();
        dialog = null;
    }

    if (currentService != null) {
        currentService.removeScanListeners();
        if (currentService.isScanning())
            currentService.stopScan();
    }

    try {
        if (bound) {
            unbindService(mServiceConnection);
            bound = false;
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    }
}

From source file:org.kalypso.ogc.gml.loader.SldLoader.java

@Override
public Object load(final IPoolableObjectType key, final IProgressMonitor monitor) throws LoaderException {
    final String source = key.getLocation();
    final URL context = key.getContext();

    try {//from  w  w  w  . j  a  v a  2  s  .com
        monitor.beginTask(Messages.getString("org.kalypso.ogc.gml.loader.SldLoader.1"), 1000); //$NON-NLS-1$

        if (CatalogUtilities.isCatalogResource(source))
            return loadFromCatalog(context, source);

        /* Local url: sld and resources reside at the same location */
        final URL sldLocation = m_urlResolver.resolveURL(context, source);
        return loadFromUrl(sldLocation, sldLocation);
    } catch (final IllegalArgumentException e) {
        // This one may happen, because the platform-URL-connector does not always throw correct MalformedURLExceptions,
        // but throws this one, when opening the stream...
        e.printStackTrace();

        // REMARK: we no not pass the exception to the next level her (hence the printStackTrace)
        // in order to have a nicer error dialog later (avoids the same line aperaring twice in the details-panel)
        final LoaderException loaderException = new LoaderException(e.getLocalizedMessage());
        setStatus(loaderException.getStatus());
        throw loaderException;
    } catch (final MalformedURLException e) {
        e.printStackTrace();

        // REMARK: we no not pass the exception to the next level her (hence the printStackTrace)
        // in order to have a nicer error dialog later (avoids the same line aperaring twice in the details-panel)
        final LoaderException loaderException = new LoaderException(e.getLocalizedMessage());
        setStatus(loaderException.getStatus());
        throw loaderException;
    } catch (final IOException e) {
        e.printStackTrace();

        // REMARK: we no not pass the exception to the next level her (hence the printStackTrace)
        // in order to have a nicer error dialog later (avoids the same line aperaring twice in the details-panel)
        final LoaderException loaderException = new LoaderException(e.getLocalizedMessage());
        setStatus(loaderException.getStatus());
        throw loaderException;
    } catch (final XMLParsingException e) {
        e.printStackTrace();

        // REMARK: we no not pass the exception to the next level her (hence the printStackTrace)
        // in order to have a nicer error dialog later (avoids the same line aperaring twice in the details-panel)
        final LoaderException loaderException = new LoaderException(e.getLocalizedMessage());
        setStatus(loaderException.getStatus());
        throw loaderException;
    } catch (final CoreException e) {
        final IStatus status = e.getStatus();
        setStatus(status);
        if (!status.matches(IStatus.CANCEL))
            e.printStackTrace();

        throw new LoaderException(e.getStatus());
    } finally {
        monitor.done();
    }
}

From source file:com.polyvi.xface.extension.XAppExt.java

@Override
public XExtensionResult exec(String action, JSONArray args, XCallbackContext callbackCtx) throws JSONException {
    XExtensionResult.Status status = XExtensionResult.Status.OK;
    String result = "";
    try {/*from   w w  w  .j a v  a  2  s . co  m*/
        if (action.equals(COMMAND_EXITAPP)) {
            exitApp();
        } else if (COMMAND_OPEN_URL.equals(action)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            String url = args.getString(0);
            Uri uri = getUrlFromPath(mWebContext, url);
            if (null == uri) {
                status = XExtensionResult.Status.ERROR;
                result = "file not exist";
                return new XExtensionResult(status, result);
            }
            setDirPermisionUntilWorkspace(mWebContext, uri);
            setIntentByUri(intent, uri);
            getContext().startActivity(intent);
        } else if (COMMAND_INSTALL.equals(action)) {
            XPathResolver pathResolver = new XPathResolver(args.getString(0), mWebContext.getWorkSpace());
            install(pathResolver.resolve(), callbackCtx);
            return new XExtensionResult(XExtensionResult.Status.NO_RESULT);
        } else if (COMMAND_START_SYSTEM_COMPONENT.equals(action)) {
            if (!startSystemComponent(args.getInt(0))) {
                status = XExtensionResult.Status.ERROR;
                result = "Unsupported component:: " + args.getString(0);
            }
        } else if (COMMAND_SET_WIFI_SLEEP_POLICY.equals(action)) {
            if (!setWifiSleepPolicy(args.getString(0))) {
                status = XExtensionResult.Status.ERROR;
                result = "set wifi sleep policy error";
            }
        } else if (COMMAND_LOAD_URL.equals(action)) {
            boolean openExternal = Boolean.valueOf(args.getString(1));
            boolean clearHistory = Boolean.valueOf(args.getString(2));
            loadUrl(args.getString(0), openExternal, clearHistory, mWebContext);
        } else if (COMMAND_BACK_HISTORY.equals(action)) {
            backHistory(mWebContext);
        } else if (COMMAND_CLEAR_HISTORY.equals(action)) {
            clearHistory(mWebContext);
        } else if (COMMAND_CLEAR_CACHE.equalsIgnoreCase(action)) {
            clearCache(mWebContext);
        } else if (COMMAND_START_NATIVE_APP.equalsIgnoreCase(action)) {
            if (!XAppUtils.startNativeApp(mExtensionContext.getSystemContext().getContext(), args.getString(0),
                    XConstant.TAG_APP_START_PARAMS, args.getString(1))) {
                status = XExtensionResult.Status.ERROR;
            }
        } else if (COMMAND_IS_NATIVE_APP_INSTALLED.equals(action)) {
            boolean installResult = false;
            if (isAppInstalled(args.getString(0))) {
                installResult = true;
            }
            return new XExtensionResult(status, installResult);
        } else if (COMMAND_TEL_LINK_ENABLE.equals(action)) {
            XConfiguration.getInstance().setTelLinkEnabled(args.optBoolean(0, true));
        } else if (COMMAND_QUERY_INSTALLED_NATIVEAPP.equals(action)) {
            return new XExtensionResult(status, queryInstalledNativeApp(args.getString(0)));
        } else if (COMMAND_UNINSTALL_NATIVEAPP.equals(action)) {
            uninstallNativeApp(args.getString(0), callbackCtx);
            return new XExtensionResult(XExtensionResult.Status.NO_RESULT);
        } else {
            status = XExtensionResult.Status.INVALID_ACTION;
            result = "Unsupported Operation: " + action;
        }
        return new XExtensionResult(status, result);
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
        return new XExtensionResult(XExtensionResult.Status.ERROR);
    }
}