List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:eu.learnpad.simulator.mon.manager.ResponseDispatcher.java
public static void NotifyMeException(String ruleMatched, String enablerName, Exception exception) { ConsumerProfile enablerMatched = (ConsumerProfile) requestMap.get(ruleMatched); ComplexEventException exceptionRaised = ComplexEventException.Factory.newInstance(); if (exception.getCause() == null) { exceptionRaised.setCauseClassName("null"); } else {// w w w .j a va 2 s.c o m exceptionRaised.setCauseClassName(exception.getCause().getClass().getName()); } exceptionRaised.setClassName(exception.getClass().getName()); exceptionRaised.setLocalizedMessage(exception.getLocalizedMessage()); exceptionRaised.setMessage(exception.getMessage()); exceptionRaised.setStackTrace(exception.getStackTrace().toString()); ResponseDispatcher.sendResponse(exceptionRaised, enablerName, enablerMatched.getAnswerTopic()); DebugMessages.print(TimeStamp.getCurrentTime(), ResponseDispatcher.class.getSimpleName(), "ruleMatched: " + ruleMatched + " - enablerName: " + enablerName + " - evaluationResult: " + exceptionRaised.getClassName()); }
From source file:es.eucm.rage.realtime.BeaconingBundleOverallFullDataTest.java
static void runProducer(final Map trace) { try {//from w ww. j ava 2 s. co m String msg = gson.toJson(trace, Map.class); long index = (long) 0.4; final ProducerRecord<Long, String> record = new ProducerRecord<>(TOPIC, index, msg); producer.send(record).get(); } catch (Exception e) { assertTrue("Error sending to Kafka " + e.getMessage() + " cause " + e.getCause(), false); } finally { producer.flush(); // producer.close(); } }
From source file:com.qmetry.qaf.automation.ui.UiDriverFactory.java
private static WebDriver getDriverObj(Class<? extends WebDriver> of, Capabilities capabilities, String urlStr) { try {//from w w w . j a v a 2 s . c om Constructor<? extends WebDriver> constructor = of.getConstructor(Capabilities.class); return constructor.newInstance(capabilities); } catch (Exception e) { if (e.getCause() != null && e.getCause() instanceof WebDriverException) { throw (WebDriverException) e.getCause(); } try { return of.newInstance(); } catch (Exception e1) { try { Constructor<? extends WebDriver> constructor = of.getConstructor(URL.class, Capabilities.class); return constructor.newInstance(new URL(urlStr), capabilities); } catch (InvocationTargetException e2) { throw new WebDriverException(e2); } catch (InstantiationException e2) { throw new WebDriverException(e2); } catch (IllegalAccessException e2) { throw new WebDriverException(e2); } catch (IllegalArgumentException e2) { throw new WebDriverException(e2); } catch (MalformedURLException e2) { throw new WebDriverException(e2); } catch (NoSuchMethodException e2) { throw new WebDriverException(e2); } catch (SecurityException e2) { throw new WebDriverException(e2); } } } }
From source file:com.wineaccess.winelicensedetail.WineLicenseDetailAdapterHelper.java
/** * This method is used to update the WineLicenseDetail in the database. * //from w ww .ja va 2s. c om * @param wineLicenseDetailUpdatePO * is used to take the input in this PO. * @return output map containing response */ public static Map<String, Object> updateWineLicenseDetail( final WineLicenseDetailUpdatePO wineLicenseDetailUpdatePO) { logger.info("start updateWineLicenseDetail method"); String errorMsg = StringUtils.EMPTY; final Map<String, Object> output = new ConcurrentHashMap<String, Object>(); Response response = null; try { MasterData caLicenseType = null; WineModel wine = null; WineLicenseDetailModel wineLicenseDetailModel = null; if (wineLicenseDetailUpdatePO.getCaLicenseTypeId() != null && !wineLicenseDetailUpdatePO.getCaLicenseTypeId().isEmpty()) { caLicenseType = MasterDataRepository .getMasterDataById(Long.parseLong(wineLicenseDetailUpdatePO.getCaLicenseTypeId())); if (caLicenseType == null) { // caLicenseType not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_CA_LICENSE_TYPE, SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_CA_LICENSE_TYPE_TEXT, SUCCESS_CODE); logger.error("CA License Type not exist"); } } ProductItemModel productModel = ProductItemRepository .getProductItemById(Long.parseLong(wineLicenseDetailUpdatePO.getProductId())); if (productModel == null) { response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.UPDATE_WINE_PRODUCT_NOT_EXISTS, SystemErrorCode.UPDATE_WINE_PRODUCT_NOT_EXISTS_TEXT, SUCCESS_CODE); logger.error("productId not exist"); } if (response == null) { wine = WineRepository.getWineById(productModel.getItemId()); if (wine == null) { // wine not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE, SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_TEXT, SUCCESS_CODE); logger.error("wine not exist"); } } if (response == null) { wineLicenseDetailModel = WineLicenseDetailRepository.getWineLicenseDetailByWine(wine); if (wineLicenseDetailModel == null) { WineryLicenseDetailModel wineryLicenseDetailModel = WineryLicenseDetailRepository .getWineryLicenseDetailByWinery(wine.getWineryId()); if (wineryLicenseDetailModel == null) { // WineLicenseDetail not exist response = ApplicationUtils.errorMessageGenerate( SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_LICENSE_ID, SystemErrorCode.UPDATE_WINE_LICENSE_INVALID_WINE_LICENSE_ID_TEXT, SUCCESS_CODE); logger.error("Wine License detail not exist"); } else { wineLicenseDetailModel = new WineLicenseDetailModel(); wineLicenseDetailModel.setCaLicenseType(wineryLicenseDetailModel.getCaLicenseType()); wineLicenseDetailModel.setWine(wine); wineLicenseDetailModel.setContractExecuted(wineryLicenseDetailModel.getContractExecuted()); wineLicenseDetailModel.setShipCompliant(wineryLicenseDetailModel.getShipCompliant()); wineLicenseDetailModel.setShipEscrowNo(wineryLicenseDetailModel.getShipEscrowNo()); WineLicenseDetailRepository.save(wineLicenseDetailModel); WineLicenseDetailVO wineLicenseDetailVO = new WineLicenseDetailVO( SystemErrorCode.UPDATE_WINE_LICENSE_SUCCESS_TEXT); BeanUtils.copyProperties(wineLicenseDetailVO, wineLicenseDetailModel); wineLicenseDetailVO.setProductId(productModel.getId()); wineLicenseDetailVO.setWineId(wineLicenseDetailModel.getWine().getId()); response = new com.wineaccess.response.SuccessResponse(wineLicenseDetailVO, SUCCESS_CODE); } } } if (response == null) { wineLicenseDetailModel.setCaLicenseType(caLicenseType); wineLicenseDetailModel.setWine(wine); if (wineLicenseDetailUpdatePO.getContractExecuted() != null) { wineLicenseDetailModel.setContractExecuted( Boolean.parseBoolean(wineLicenseDetailUpdatePO.getContractExecuted())); } if (wineLicenseDetailUpdatePO.getShipCompliant() != null) { wineLicenseDetailModel .setShipCompliant(Boolean.parseBoolean(wineLicenseDetailUpdatePO.getShipCompliant())); } if (wineLicenseDetailUpdatePO.getShipEscrowNo() != null) { wineLicenseDetailModel.setShipEscrowNo(wineLicenseDetailUpdatePO.getShipEscrowNo()); } if (wineLicenseDetailUpdatePO.getShipCompliantProductKey() != null) { wineLicenseDetailModel .setShipCompliantProductKey(wineLicenseDetailUpdatePO.getShipCompliantProductKey()); } if (wineLicenseDetailUpdatePO.getPriceToRetailer() != null) { wineLicenseDetailModel .setPriceToRetailer(Double.parseDouble(wineLicenseDetailUpdatePO.getPriceToRetailer())); } if (wineLicenseDetailUpdatePO.getColaNumber() != null) { wineLicenseDetailModel.setColaNumber(wineLicenseDetailUpdatePO.getColaNumber()); } WineLicenseDetailRepository.update(wineLicenseDetailModel); WineLicenseDetailVO wineLicenseDetailVO = new WineLicenseDetailVO( SystemErrorCode.UPDATE_WINE_LICENSE_SUCCESS_TEXT); BeanUtils.copyProperties(wineLicenseDetailVO, wineLicenseDetailModel); wineLicenseDetailVO.setProductId(productModel.getId()); wineLicenseDetailVO.setWineId(wineLicenseDetailModel.getWine().getId()); response = new com.wineaccess.response.SuccessResponse(wineLicenseDetailVO, SUCCESS_CODE); } } catch (Exception e) { errorMsg = e.getCause().getMessage(); } if (errorMsg.contains("uk_wine_id")) { response = ApplicationUtils.errorMessageGenerate(SystemErrorCode.UPDATE_WINE_LICENSE_ALREADY_EXISTS, SystemErrorCode.UPDATE_WINE_LICENSE_ALREADY_EXISTS_TEXT, SUCCESS_CODE); logger.error("wine license detail already exists"); } output.put(OUPUT_PARAM_KEY, response); logger.info("exit updateWineLicenseDetail method"); return output; }
From source file:org.neo4j.ogm.drivers.http.request.HttpRequest.java
public static CloseableHttpResponse execute(CloseableHttpClient httpClient, HttpRequestBase request, Credentials credentials) throws HttpRequestException { LOGGER.debug("Thread: {}, request: {}", Thread.currentThread().getId(), request); CloseableHttpResponse response;//from ww w . j a va2 s. co m request.setHeader(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8")); request.setHeader(new BasicHeader(HTTP.USER_AGENT, "neo4j-ogm.java/2.0")); request.setHeader(new BasicHeader("Accept", "application/json;charset=UTF-8")); HttpAuthorization.authorize(request, credentials); // use defaults: 3 retries, 2 second wait between attempts RetryOnExceptionStrategy retryStrategy = new RetryOnExceptionStrategy(); while (retryStrategy.shouldRetry()) { try { response = httpClient.execute(request); StatusLine statusLine = response.getStatusLine(); HttpEntity responseEntity = response.getEntity(); if (statusLine.getStatusCode() >= 300) { String responseText = statusLine.getReasonPhrase(); if (responseEntity != null) { responseText = parseError(EntityUtils.toString(responseEntity)); LOGGER.warn("Thread: {}, response: {}", Thread.currentThread().getId(), responseText); } throw new HttpResponseException(statusLine.getStatusCode(), responseText); } if (responseEntity == null) { throw new ClientProtocolException("Response contains no content"); } return response; // don't close response yet, it is not consumed! } // if we didn't get a response at all, try again catch (NoHttpResponseException nhre) { LOGGER.warn("Thread: {}, No response from server: Retrying in {} milliseconds, retries left: {}", Thread.currentThread().getId(), retryStrategy.getTimeToWait(), retryStrategy.numberOfTriesLeft); retryStrategy.errorOccurred(); } catch (RetryException re) { throw new HttpRequestException(request, re); } catch (ClientProtocolException uhe) { throw new ConnectionException(request.getURI().toString(), uhe); } catch (IOException ioe) { throw new HttpRequestException(request, ioe); } // here we catch any exception we throw above (plus any we didn't throw ourselves), // log the problem, close any connection held by the request // and then rethrow the exception to the caller. catch (Exception exception) { LOGGER.warn("Thread: {}, exception: {}", Thread.currentThread().getId(), exception.getCause().getLocalizedMessage()); request.releaseConnection(); throw exception; } } throw new RuntimeException("Fatal Exception: Should not have occurred!"); }
From source file:ReflectionExecutor.java
/** * Execution of reflection with {@link ReflectionAction}. * /*from w w w . ja v a2 s .c o m*/ * @param <T> * @param action * @return */ public static <T> T doSafeAction(final ReflectionAction<T> action) { final SecurityManager securityManager = System.getSecurityManager(); if (securityManager == null) { try { return action.run(); } catch (Exception e) { throw new RuntimeException(e); } } try { return AccessController.doPrivileged(new PrivilegedExceptionAction<T>() { @Override public T run() throws Exception { return action.run(); } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (InvocationTargetException.class.isInstance(cause)) { InvocationTargetException e1 = (InvocationTargetException) cause; throw new Exception(e1.getTargetException()); } throw new Exception(cause); } }
From source file:com.glaf.core.security.RSAUtils.java
/** * /*from w ww . jav a2 s . c o m*/ * <p /> * {@code publicKey} {@code null} {@code plaintext} {@code null} * {@code null} * * @param publicKey * * @param plaintext * * @return */ public static String encryptString(PublicKey publicKey, String plaintext) { if (publicKey == null || plaintext == null) { return null; } byte[] data = plaintext.getBytes(); try { byte[] en_data = encrypt(publicKey, data); return new String(Hex.encodeHex(en_data)); } catch (Exception ex) { LOGGER.error(ex.getCause().getMessage()); } return null; }
From source file:com.glaf.core.security.RSAUtils.java
/** * /*from w w w .ja va2 s. co m*/ * <p /> * {@code plaintext} {@code null} {@code null} * * @param plaintext * * @return */ public static String encryptString(String plaintext) { if (plaintext == null) { return null; } byte[] data = plaintext.getBytes(); KeyPair keyPair = getKeyPair(); try { byte[] en_data = encrypt((RSAPublicKey) keyPair.getPublic(), data); return new String(Hex.encodeHex(en_data)); } catch (Exception ex) { LOGGER.error(ex.getCause().getMessage()); } return null; }
From source file:com.ctrip.infosec.rule.resource.DataProxy.java
/** * ??/*from w w w . j av a2 s .c om*/ * * @param serviceName * @param operationName * @param params * @return */ public static Map queryForMap(String serviceName, String operationName, Map<String, Object> params) { check(); beforeInvoke("DataProxy.queryForMap"); beforeInvoke("DataProxy." + serviceName + "." + operationName); try { String cacheKey = buildCacheKey(serviceName, operationName, params); Map newResult = (Map) ThreadLocalCache.get(cacheKey); if (newResult == null) { boolean _isAsync = Contexts.isAsync(); DataProxyQueryCommand command = new DataProxyQueryCommand(serviceName, operationName, params, _isAsync); newResult = command.execute(); if (serviceName.equals("UserProfileService")) { newResult = parseProfileResult(newResult); } if (newResult != null && !newResult.isEmpty()) { ThreadLocalCache.set(cacheKey, newResult); } } else { logger.info("hit cache, key = " + cacheKey); } return newResult; } catch (Exception ex) { fault("DataProxy.queryForMap"); fault("DataProxy." + serviceName + "." + operationName); logger.error(Contexts.getLogPrefix() + "DataProxy.", ex); TraceLogger.traceLog("DataProxy, EXCEPTION: " + (ex.getCause() == null ? ex.toString() : ex.getCause().toString())); } finally { afterInvoke("DataProxy.queryForMap"); afterInvoke("DataProxy." + serviceName + "." + operationName); } return Collections.EMPTY_MAP; }
From source file:fr.paris.lutece.plugins.search.solr.indexer.SolrIndexerService.java
/** * Adds the exception into the buffer and the logs * @param exception Exception to report// w w w .ja v a2 s.c o m */ private static void printIndexMessage(Exception exception) { _sbLogs.append(" - ERROR : "); _sbLogs.append(exception.getMessage()); if (exception.getCause() != null) { _sbLogs.append(" : "); _sbLogs.append(exception.getCause().getMessage()); } _sbLogs.append("</strong>\r\n"); AppLogService.error(exception.getMessage(), exception); }