List of usage examples for java.lang Exception getCause
public synchronized Throwable getCause()
From source file:org.codehaus.grepo.core.config.GenericRepositoryScanBeanDefinitionParser.java
/** * @param configContext The config context. * @param parserContext The parser context. *//*from www . j a v a 2 s . c om*/ protected void parseBeanNameGenerator(GenericRepositoryConfigContext configContext, ParserContext parserContext) { XmlReaderContext readerContext = parserContext.getReaderContext(); try { if (configContext.hasNameGenerator()) { BeanNameGenerator generator = (BeanNameGenerator) instantiateUserDefinedStrategy( configContext.getNameGenerator(), BeanNameGenerator.class, parserContext.getReaderContext().getResourceLoader().getClassLoader()); setBeanNameGenerator(generator); } } catch (Exception ex) { readerContext.error(ex.getMessage(), readerContext.extractSource(configContext.getElement()), ex.getCause()); } }
From source file:com.gisgraphy.domain.geoloc.service.fulltextsearch.FullTextSearchEngine.java
public List<? extends GisFeature> executeQueryToDatabaseObjects(FulltextQuery query) throws ServiceException { statsUsageService.increaseUsage(StatsUsageType.FULLTEXT); Assert.notNull(query, "Can not execute a null query"); ModifiableSolrParams params = query.parameterize(); List<GisFeature> gisFeatureList = new ArrayList<GisFeature>(); QueryResponse results = null;//from w w w . j a v a 2 s. co m try { results = solrClient.getServer().query(params); logger.info(query + " took " + (results.getQTime()) + " ms and returns " + results.getResults().getNumFound() + " results"); List<Long> ids = new ArrayList<Long>(); for (SolrDocument doc : results.getResults()) { ids.add((Long) doc.getFieldValue(FullTextFields.FEATUREID.getValue())); } gisFeatureList = gisFeatureDao.listByFeatureIds(ids); } catch (Exception e) { logger.error("An error has occurred during fulltext search to database object for query " + query + " : " + e.getCause().getMessage()); throw new FullTextSearchException(e); } return gisFeatureList; }
From source file:net.padaf.xmpbox.parser.XMLValueTypeDescriptionManager.java
/** * Load Value Types Descriptions from XML Stream * /*from www . ja va 2s .c om*/ * @param is * Stream where read data * @throws BuildPDFAExtensionSchemaDescriptionException * When problems to get or treat data in XML description file */ public void loadListFromXML(InputStream is) throws BuildPDFAExtensionSchemaDescriptionException { try { Object o = xstream.fromXML(is); if (o instanceof List<?>) { if (((List<?>) o).get(0) != null) { if (((List<?>) o).get(0) instanceof ValueTypeDescription) { vTypes = (List<ValueTypeDescription>) o; } else { throw new BuildPDFAExtensionSchemaDescriptionException( "Failed to get correct valuetypes descriptions from specified XML stream"); } } else { throw new BuildPDFAExtensionSchemaDescriptionException( "Failed to find a valuetype description into the specified XML stream"); } } } catch (Exception e) { e.printStackTrace(); throw new BuildPDFAExtensionSchemaDescriptionException( "Failed to get correct valuetypes descriptions from specified XML stream", e.getCause()); } finally { IOUtils.closeQuietly(is); } }
From source file:net.sf.ehcache.constructs.blocking.BlockingCacheTest.java
/** * Thrashes a BlockingCache which has a tiny timeout. Should throw * a LockTimeoutException caused by queued threads not getting the lock * in the required time.//from ww w.ja va 2 s.co m */ public void testThrashBlockingCacheTinyTimeout() throws Exception { Ehcache cache = manager.getCache("sampleCache1"); blockingCache = new BlockingCache(cache); blockingCache.setTimeoutMillis(1); long duration = 0; try { duration = thrashCache(blockingCache, 50, 400L, 1000L); fail(); } catch (Exception e) { assertEquals(LockTimeoutException.class, e.getCause().getClass()); } LOG.debug("Thrash Duration:" + duration); }
From source file:com.swissbit.homeautomation.asyncTask.AuthenticationAsync.java
/** *Handles the subscription and publish event for RaspberryPi Authentication */// w w w .j av a2s. com @Override protected Object doInBackground(Object[] params) { IKuraMQTTClient client = MQTTFactory.getClient(); boolean status = false; String requestId = null; String topic = null; if (!client.isConnected()) status = client.connect(); status = client.isConnected(); String[] topicData = MQTTFactory.getTopicToSubscribe(TopicsConstants.RASPBERRY_AUTH_SUB); requestId = topicData[1]; topic = topicData[0]; Log.d("Kura MQTTTopic", topic); Log.d("Kura requestId", requestId); //Subscribe to the topic. After publish, the response will be handles here. if (status) client.subscribe(topic, new MessageListener() { @Override public void processMessage(KuraPayload kuraPayload) { try { String metricData = String.valueOf(kuraPayload.getMetric("data")); if (metricData.isEmpty()) { Log.d("Metrics", "" + kuraPayload.metrics()); subscriptionResponse = false; } else { Log.d("Metrics", "" + kuraPayload.metrics()); subscriptionResponse = true; } if (lock.tryLock()) { try { Log.d("Notify", "After"); condition.signal(); } finally { lock.unlock(); } } Log.d("Inside onProcess", "" + subscriptionResponse); } catch (Exception e) { Log.e("Kura MQTT", e.getCause().getMessage()); } } }); if (!status) MQTTFactory.getClient().connect(); Log.d("AuthTopic", "" + MQTTFactory.getTopicToPublish(TopicsConstants.RASPBERRY_AUTH_PUB)); Log.d("EncryptAsyncFactory", "" + EncryptionFactory.getEncryptedString()); //Generate the payload payload = MQTTFactory.generatePayload(EncryptionFactory.getEncryptedString(), requestId); //Publish if (status) MQTTFactory.getClient().publish(MQTTFactory.getTopicToPublish(TopicsConstants.RASPBERRY_AUTH_PUB), payload); //Wait for sometime for the response if (lock.tryLock()) { try { Log.d("Notify", "Before"); condition.await(20, TimeUnit.SECONDS); Log.d("Notify", "After"); } catch (InterruptedException e) { e.printStackTrace(); } finally { lock.unlock(); } } return null; }
From source file:com.khs.sherpa.servlet.request.DefaultSherpaRequest.java
protected Object invokeMethod(Object target, Method method) { try {//from w w w . j a v a2s . co m Object obj = method.invoke(target, this.getParams(method)); return obj; } catch (Exception e) { if (e.getCause() != null && e.getCause().getClass().isAssignableFrom(SherpaRuntimeException.class)) { logger.throwing(target.getClass().getName(), method.getName(), e.getCause()); throw new SherpaRuntimeException(e.getCause().getMessage()); } logger.throwing(target.getClass().getName(), method.getName(), e); throw new SherpaRuntimeException("unable to execute method [" + method.getName() + "] in class [" + target.getClass().getCanonicalName() + "]", e); } finally { } }
From source file:com.blackducksoftware.tools.scmconnector.integrations.git.GitConnector.java
/** * Checkout or update from GIT./*from w w w.j av a 2s . c o m*/ */ @Override public int sync() { int exitStatus = -1; try { CommandLine command = CommandLine.parse(EXECUTABLE); String targetRepoParentPath = getFinalSourceDirectory(); String targetRepoPath = addPathComponentToPath(targetRepoParentPath, getModuleNameFromURLGit(repositoryURL)); File targetRepoParentDir = new File(targetRepoParentPath); File targetRepoDir = new File(targetRepoPath); boolean cloneExists = doesGitCloneExist(targetRepoDir); if (!cloneExists) { command.addArgument(GIT_COMMAND_CLONE); command.addArgument(repositoryURL); command.addArgument(targetRepoDir.getAbsolutePath()); exitStatus = commandLineExecutor.executeCommand(log, command, targetRepoParentDir, "yes"); } else { command.addArgument(GIT_COMMAND_PULL); exitStatus = commandLineExecutor.executeCommand(log, command, targetRepoDir, "yes"); } if (branch != null) { gitCheckoutBranchShaOrPrefixedTag(branch); } else if (tag != null) { gitCheckoutTag(tag); } else if (sha != null) { gitCheckoutBranchShaOrPrefixedTag(sha); } } catch (Exception e) { log.error("Unable to perform sync: " + e.getMessage(), e); log.info("Cause: " + e.getCause()); exitStatus = -1; } return exitStatus; }
From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.PasswordCipherer.java
/** * <p>Decodes the specified raw password with an implementation specific algorithm if allowEncoding is TRUE.</p> * Otherwise it returns encPass.//from w w w . java 2 s .c o m * @param encPass * @return * @throws DataAccessException */ public String decodePassword(String encPass) { synchronized (PasswordCipherer.class) { try { log.debug("Decode password: " + allowEncoding); if (!allowEncoding) return encPass; return cipherer.decode(encPass); } catch (Exception ex) { log.warn("Password decryption failed", ex); throw new DataAccessResourceFailureException(ex.getMessage(), ex.getCause()); } } }
From source file:com.jaspersoft.jasperserver.api.metadata.common.service.impl.PasswordCipherer.java
/** * <p>Encodes the specified raw password with an implementation specific algorithm if allowEncoding is TRUE.</p> * Otherwise it returns rawPass./*from www.jav a 2s . c om*/ * @param rawPass * @return * @throws DataAccessException */ public String encodePassword(String rawPass) throws DataAccessException { synchronized (PasswordCipherer.class) { try { log.debug("Encode password: " + allowEncoding); if (!allowEncoding) return rawPass; return cipherer.encode(rawPass); } catch (Exception ex) { log.warn("Password decryption failed", ex); throw new DataAccessResourceFailureException(ex.getMessage(), ex.getCause()); } } }