List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:at.gv.egovernment.moa.id.commons.db.MOASessionDBUtils.java
public static void initHibernate(Configuration config, Properties hibernateProperties) { String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY)); if (scm != null) { automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1 || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1; }/*from www.ja va 2 s . co m*/ Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\"."); if (automaticSessionHandling) { Logger.info("Hibernate is automatically handling session context management."); } else { Logger.info( "Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling."); } try { //Create the SessionFactory Logger.debug("Creating initial MOASession session factory..."); config.configure("hibernate_moasession.cfg.xml"); //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); sessionFactory = config.buildSessionFactory(serviceRegistry); Logger.debug("Initial MOASession session factory successfully created."); } catch (Throwable ex) { Logger.error("Initial MOASession session factory creation failed: " + ex.getMessage()); throw new ExceptionInInitializerError(ex); } }
From source file:com.googlecode.dex2jar.v3.Main.java
public static void niceExceptionMessage(Throwable t, int deep) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < deep + 1; i++) { sb.append("."); }// w w w. j ava 2s .c om sb.append(' '); if (t instanceof DexException) { sb.append(t.getMessage()); System.err.println(sb.toString()); if (t.getCause() != null) { niceExceptionMessage(t.getCause(), deep + 1); } } else { if (t != null) { System.err.println(sb.append("ROOT cause:").toString()); t.printStackTrace(System.err); } } }
From source file:com.salesforce.dva.argus.service.callback.DefaultCallbackService.java
private static HttpResponse errorResponse(String reason, Throwable t) { return new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), 500, String.format("%s: %s", reason, t.getMessage())); }
From source file:at.gv.egovernment.moa.id.commons.db.StatisticLogDBUtils.java
public static void initHibernate(Configuration config, Properties hibernateProperties) { String scm = StringUtils.trimToNull(hibernateProperties.getProperty(SESSION_HANDLING_KEY)); if (scm != null) { automaticSessionHandling = scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[0]) != -1 || scm.indexOf(AUTOMATIC_SESSION_HANDLING_VALUES[1]) != -1; }/*from w ww.ja v a2 s. c o m*/ Logger.debug("Evaluating hibernate property \"" + SESSION_HANDLING_KEY + "\"."); if (automaticSessionHandling) { Logger.info("Hibernate is automatically handling session context management."); } else { Logger.info( "Hibernate is NOT automatically handling session context management. Using build-in ThreadLocal session handling."); } try { //Create the SessionFactory Logger.debug("Creating initial StatisicLogger session factory..."); config.configure("hibernate_statistic.cfg.xml"); //serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry(); serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config.getProperties()).build(); sessionFactory = config.buildSessionFactory(serviceRegistry); Logger.debug("Initial StatisicLogger session factory successfully created."); } catch (Throwable ex) { Logger.error("Initial StatisicLogger session factory creation failed: " + ex.getMessage()); throw new ExceptionInInitializerError(ex); } }
From source file:org.wso2.carbon.integration.test.client.PizzaOrderClient.java
public static void sendPizzaOrder(String url) { KeyStoreUtil.setTrustStoreParams();/*w ww .ja va 2s. com*/ HttpClient httpClient = new SystemDefaultHttpClient(); try { HttpPost method = new HttpPost(url); String[] xmlElements = new String[] { "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0023</mypizza:OrderNo>\n" + " <mypizza:Type>PEPPERONI</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Quantity>2</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>", "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0024</mypizza:OrderNo>\n" + " <mypizza:Type>CHEESE</mypizza:Type>\n" + " <mypizza:Size>M</mypizza:Size>\n" + " <mypizza:Quantity>1</mypizza:Quantity>\n" + " <mypizza:Contact>Henry Clock</mypizza:Contact>\n" + " <mypizza:Address>2CYL Morris Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>", "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0025</mypizza:OrderNo>\n" + " <mypizza:Type>SEAFOOD</mypizza:Type>\n" + " <mypizza:Size>S</mypizza:Size>\n" + " <mypizza:Quantity>4</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>22RE Robinwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>", "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0026</mypizza:OrderNo>\n" + " <mypizza:Type>CHICKEN</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Contact>Alis Miranda</mypizza:Contact>\n" + " <mypizza:Address>779 Burl Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>", "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0026</mypizza:OrderNo>\n" + " <mypizza:Type>VEGGIE</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Quantity>1</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>" }; String[] batchedXmlElements = new String[] { "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0023</mypizza:OrderNo>\n" + " <mypizza:Type>PEPPERONI</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Quantity>2</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0024</mypizza:OrderNo>\n" + " <mypizza:Type>CHEESE</mypizza:Type>\n" + " <mypizza:Size>M</mypizza:Size>\n" + " <mypizza:Quantity>1</mypizza:Quantity>\n" + " <mypizza:Contact>Henry Clock</mypizza:Contact>\n" + " <mypizza:Address>2CYL Morris Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0025</mypizza:OrderNo>\n" + " <mypizza:Type>SEAFOOD</mypizza:Type>\n" + " <mypizza:Size>S</mypizza:Size>\n" + " <mypizza:Quantity>4</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>22RE Robinwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>", "<mypizza:PizzaOrderStream xmlns:mypizza=\"http://samples.wso2.org/\">\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0026</mypizza:OrderNo>\n" + " <mypizza:Type>CHICKEN</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Quantity>1</mypizza:Quantity>\n" + " <mypizza:Contact>Alis Miranda</mypizza:Contact>\n" + " <mypizza:Address>779 Burl Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + " <mypizza:PizzaOrder>\n" + " <mypizza:OrderNo>0026</mypizza:OrderNo>\n" + " <mypizza:Type>VEGGIE</mypizza:Type>\n" + " <mypizza:Size>L</mypizza:Size>\n" + " <mypizza:Quantity>1</mypizza:Quantity>\n" + " <mypizza:Contact>James Mark</mypizza:Contact>\n" + " <mypizza:Address>29BX Finchwood Ave, Clovis, CA 93611</mypizza:Address>\n" + " </mypizza:PizzaOrder>\n" + "</mypizza:PizzaOrderStream>" }; int i = 0; for (String xmlElement : xmlElements) { StringEntity entity = new StringEntity(xmlElement); method.setEntity(entity); httpClient.execute(method).getEntity().getContent().close(); System.out.println("Sent event no :" + i++); } Thread.sleep(500); // We need to wait some time for the message to be sent } catch (Throwable t) { t.printStackTrace(); Assert.fail("Exception: " + t.getMessage()); } }
From source file:net.cbtltd.server.WebService.java
/** * Gets the connection to the JSON server. * * @param url the connection URL./*w w w . j a v a 2 s. com*/ * @param rq the request object. * @return the JSON string returned by the message. * @throws Throwable the exception thrown by the method. */ private static final String getConnection(URL url, String rq) throws Throwable { String jsonString = ""; HttpURLConnection connection = null; try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); //connection.setRequestMethod("POST"); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/json"); if (rq != null) { connection.setRequestProperty("Accept", "application/json"); connection.connect(); byte[] outputBytes = rq.getBytes("UTF-8"); OutputStream os = connection.getOutputStream(); os.write(outputBytes); } if (connection.getResponseCode() != 200) { throw new RuntimeException("HTTP:" + connection.getResponseCode() + "URL " + url); } BufferedReader br = new BufferedReader(new InputStreamReader((connection.getInputStream()))); String line; while ((line = br.readLine()) != null) { jsonString += line; } } catch (Throwable x) { throw new RuntimeException(x.getMessage()); } finally { if (connection != null) { connection.disconnect(); } } return jsonString; }
From source file:com.atlassian.connector.eclipse.team.ui.TeamUiMessageUtils.java
private static void internalOpenUnableToCompareErrorMessage(String repoUrl, String filePath, String oldRevision, String newRevision, Throwable e) { String message = "Unable to compare revisions. "; if (e != null) { message += "Following exception was catched:\n\n"; message += e.getMessage(); message += "\n\n"; }/* ww w. ja v a 2 s. c o m*/ message += "Please check that:\n\n" + getErrorHints(); message += "\n\nPlease check also Error Log for details."; MessageDialog.openInformation(null, MESSAGE_DIALOG_TITLE, message); }
From source file:com.lidroid.util.OtherUtils.java
public static void trustAllHttpsURLConnection() { // Create a trust manager that does not validate certificate chains if (sslSocketFactory == null) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override/*from w w w . j a v a2s. c o m*/ public java.security.cert.X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustAllCerts, null); sslSocketFactory = sslContext.getSocketFactory(); } catch (Throwable e) { Logger.e(e.getMessage(), e); } } if (sslSocketFactory != null) { HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); HttpsURLConnection.setDefaultHostnameVerifier( org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } }
From source file:com.alibaba.wasp.client.ServerCallable.java
private static RuntimeException unwrapRuntimeException(Throwable t) { if (StringUtils.isNotEmpty(t.getMessage())) { try {//from w w w .j av a 2s.co m Class exceptionClass = Class.forName(t.getMessage()); Constructor cn = exceptionClass.getConstructor(String.class); cn.setAccessible(true); String firstLine = t.getMessage(); Object ex = cn.newInstance(firstLine); if (ex instanceof RuntimeException) { return (RuntimeException) ex; } } catch (ClassNotFoundException e) { //ignore } catch (NoSuchMethodException e) { //ignore } catch (InvocationTargetException e) { //ignore } catch (InstantiationException e) { //ignore } catch (IllegalAccessException e) { //ignore } } return null; }
From source file:com.example.zch.imspeak.utils.OtherUtils.java
public static void trustAllHttpsURLConnection() { // Create a trust manager that does not validate certificate chains if (sslSocketFactory == null) { TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override/*from w w w. j a v a 2 s . c o m*/ public X509Certificate[] getAcceptedIssuers() { return null; } @Override public void checkClientTrusted(X509Certificate[] certs, String authType) { } @Override public void checkServerTrusted(X509Certificate[] certs, String authType) { } } }; try { SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustAllCerts, null); sslSocketFactory = sslContext.getSocketFactory(); } catch (Throwable e) { LogUtils.e(e.getMessage(), e); } } if (sslSocketFactory != null) { HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory); HttpsURLConnection.setDefaultHostnameVerifier( org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); } }