List of usage examples for java.lang NoSuchMethodError printStackTrace
public void printStackTrace()
From source file:org.apache.directory.fortress.core.rest.RestUtils.java
/** * Perform an HTTP Post REST operation.//from w ww . jav a 2 s .co m * * @param userId * @param password * @param szInput * @param function * @return String containing response * @throws RestException */ public String post(String userId, String password, String szInput, String function) throws RestException { LOG.debug("post uri=[{}], function=[{}], request=[{}]", uri, function, szInput); String szResponse = null; HttpPost post = new HttpPost(uri + function); post.addHeader("Accept", "text/xml"); setMethodHeaders(post); try { HttpEntity entity = new StringEntity(szInput, ContentType.TEXT_XML); post.setEntity(entity); org.apache.http.client.HttpClient httpclient = HttpClientBuilder.create() .setDefaultCredentialsProvider(getCredentialProvider(userId, password)).build(); HttpResponse response = httpclient.execute(post); String error; switch (response.getStatusLine().getStatusCode()) { case HTTP_OK: szResponse = IOUtils.toString(response.getEntity().getContent(), "UTF-8"); LOG.debug("post uri=[{}], function=[{}], response=[{}]", uri, function, szResponse); break; case HTTP_401_UNAUTHORIZED: error = "post uri=[" + uri + "], function=[" + function + "], 401 function unauthorized on host"; LOG.error(error); throw new RestException(GlobalErrIds.REST_UNAUTHORIZED_ERR, error); case HTTP_403_FORBIDDEN: error = "post uri=[" + uri + "], function=[" + function + "], 403 function forbidden on host"; LOG.error(error); throw new RestException(GlobalErrIds.REST_FORBIDDEN_ERR, error); case HTTP_404_NOT_FOUND: error = "post uri=[" + uri + "], function=[" + function + "], 404 not found from host"; LOG.error(error); throw new RestException(GlobalErrIds.REST_NOT_FOUND_ERR, error); default: error = "post uri=[" + uri + "], function=[" + function + "], error received from host: " + response.getStatusLine().getStatusCode(); LOG.error(error); throw new RestException(GlobalErrIds.REST_UNKNOWN_ERR, error); } } catch (IOException ioe) { String error = "post uri=[" + uri + "], function=[" + function + "] caught IOException=" + ioe; LOG.error(error); throw new RestException(GlobalErrIds.REST_IO_ERR, error, ioe); } catch (WebApplicationException we) { String error = "post uri=[" + uri + "], function=[" + function + "] caught WebApplicationException=" + we; LOG.error(error); throw new RestException(GlobalErrIds.REST_WEB_ERR, error, we); } catch (java.lang.NoSuchMethodError e) { String error = "post uri=[" + uri + "], function=[" + function + "] caught Exception=" + e; LOG.error(error); e.printStackTrace(); throw new RestException(GlobalErrIds.REST_UNKNOWN_ERR, error); } finally { // Release current connection to the connection pool. post.releaseConnection(); } return szResponse; }