List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:jdbc.pool.JDBCPoolOracleConnectionTest.java
public void testGetInstanceStringFile1() { testGetInstanceNull();/* www . j a v a 2 s . c o m*/ System.out.println("testGetInstanceStringFile1 Start"); try { try { CConnectionPoolManager.getInstance(); System.out.println("Instance is created. WRONG"); } catch (IllegalArgumentException e) { System.out.println("Instance is not created. Alright"); } CConnectionPoolManager manager = CConnectionPoolManager.getInstance( "C:/Documents and Settings/kedarr/workspace/jdbcpool/config/log4j.properties", new File( "C:/Documents and Settings/kedarr/workspace/jdbcpool/config/pool1245645558888.properties")); System.out.println("It came here Kedar in trouble" + manager); fail("getInstance(invalid data) was supposed to throw Configuration exception but did not."); } catch (ConfigurationException e) { e.printStackTrace(); assertTrue("Caught ConfigurationException", true); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } System.out.println("testGetInstanceStringFile1 end"); }
From source file:org.niceday.AsyncHttpGet.java
@Override public void run() { try {//from w w w. j a v a 2 s . c o m if (parameter != null && parameter.size() > 0) { StringBuilder bulider = new StringBuilder(); for (RequestParameter p : parameter) { if (bulider.length() != 0) { bulider.append("&"); } bulider.append(Utils.encode(p.getName())); bulider.append("="); //TODO it should be encoded //but the server don`t support!!!! //what a fuck!!!!!!!!!!!!!!!!!!! bulider.append(p.getValue()); } url += "?" + bulider.toString(); } Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url); request = new HttpGet(url); HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { ByteArrayOutputStream content = new ByteArrayOutputStream(); response.getEntity().writeTo(content); String ret = new String(content.toByteArray()).trim(); content.close(); Object Object = null; if (AsyncHttpGet.this.handler != null) { Object = AsyncHttpGet.this.handler.handle(ret); if (AsyncHttpGet.this.requestCallback != null && Object != null) { AsyncHttpGet.this.requestCallback.onSuccess(Object); return; } if (Object == null || "".equals(Object.toString())) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); } } else { if (this.requestCallback != null) { AsyncHttpGet.this.requestCallback.onSuccess(ret); } } } else { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); } Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " finished !"); } catch (java.lang.IllegalArgumentException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (org.apache.http.conn.ConnectTimeoutException e) { RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (java.net.SocketTimeoutException e) { RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (UnsupportedEncodingException e) { RequestException exception = new RequestException(RequestException.UNSUPPORTED_ENCODEING_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " UnsupportedEncodingException " + e.getMessage()); } catch (org.apache.http.conn.HttpHostConnectException e) { RequestException exception = new RequestException(RequestException.CONNECT_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " HttpHostConnectException " + e.getMessage()); } catch (ClientProtocolException e) { RequestException exception = new RequestException(RequestException.CLIENT_PROTOL_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); e.printStackTrace(); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " ClientProtocolException " + e.getMessage()); } catch (IOException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpGet.this.requestCallback.onFail(exception); e.printStackTrace(); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpGet request to url :" + url + " IOException " + e.getMessage()); } finally { //request. } super.run(); }
From source file:org.niceday.AsyncHttpPost.java
@Override public void run() { try {/*from www . j a v a 2 s . c o m*/ request = new HttpPost(url); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url); request.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, connectTimeout); request.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, readTimeout); if (parameter != null && parameter.size() > 0) { List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>(); for (RequestParameter p : parameter) { list.add(new BasicNameValuePair(p.getName(), p.getValue())); } ((HttpPost) request).setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8)); } HttpResponse response = httpClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode == HttpStatus.SC_OK) { ByteArrayOutputStream content = new ByteArrayOutputStream(); response.getEntity().writeTo(content); String ret = new String(content.toByteArray()).trim(); content.close(); Object Object = null; if (AsyncHttpPost.this.handler != null) { Object = AsyncHttpPost.this.handler.handle(ret); if (AsyncHttpPost.this.requestCallback != null && Object != null) { AsyncHttpPost.this.requestCallback.onSuccess(Object); return; } if (Object == null || "".equals(Object.toString())) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); } } else { AsyncHttpPost.this.requestCallback.onSuccess(ret); } } else { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, "," + statusCode); AsyncHttpPost.this.requestCallback.onFail(exception); } Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " finished !"); } catch (java.lang.IllegalArgumentException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); Log.d(AsyncHttpGet.class.getName(), "AsyncHttpPost request to url :" + url + " onFail " + e.getMessage()); } catch (org.apache.http.conn.ConnectTimeoutException e) { RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (java.net.SocketTimeoutException e) { RequestException exception = new RequestException(RequestException.SOCKET_TIMEOUT_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " onFail " + e.getMessage()); } catch (UnsupportedEncodingException e) { RequestException exception = new RequestException(RequestException.UNSUPPORTED_ENCODEING_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " UnsupportedEncodingException " + e.getMessage()); } catch (org.apache.http.conn.HttpHostConnectException e) { RequestException exception = new RequestException(RequestException.CONNECT_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " HttpHostConnectException " + e.getMessage()); } catch (ClientProtocolException e) { RequestException exception = new RequestException(RequestException.CLIENT_PROTOL_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); e.printStackTrace(); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " ClientProtocolException " + e.getMessage()); } catch (IOException e) { RequestException exception = new RequestException(RequestException.IO_EXCEPTION, ""); AsyncHttpPost.this.requestCallback.onFail(exception); e.printStackTrace(); Log.d(AsyncHttpPost.class.getName(), "AsyncHttpGet request to url :" + url + " IOException " + e.getMessage()); } finally { //request. } super.run(); }
From source file:com.projity.field.Field.java
public final String getText(Object object, FieldContext context) { if (!isApplicable(object)) return NOT_APPLICABLE; if (password) // don't show passwords return PASSWORD_MASK; if (context == null) context = specialFieldContext;//from w w w . j a v a 2 s.com Object value = null; try { value = getValue(object, context); if (hasOptions()) { return convertValueToStringUsingOptions(value); } } catch (IllegalArgumentException e1) { e1.printStackTrace(); } return toText(value, object); }
From source file:com.projity.field.Field.java
public final String getText(Node node, WalkersNodeModel nodeModel, FieldContext context) { Object object = node.getImpl(); if (!isApplicable(object)) return NOT_APPLICABLE; if (password) // don't show passwords return PASSWORD_MASK; if (context == null) context = specialFieldContext;// ww w.j av a 2s. com Object value = null; try { value = getValue(node, nodeModel, context); if (hasOptions()) { return convertValueToStringUsingOptions(value); } } catch (IllegalArgumentException e1) { e1.printStackTrace(); } return toText(value, object); }
From source file:com.projity.field.Field.java
private final Object invokeContextMethod(Method method, Object object, FieldContext context, boolean noContext) { if (context == null) context = specialFieldContext;//from www . jav a2s . com if (method == null) return null; try { if (noContext) { if (isIndexed()) return method.invoke(object, new Object[] { new Integer(getIndex()), null }); else return method.invoke(object, (Object[]) null); } else { if (isIndexed()) return method.invoke(object, new Object[] { new Integer(getIndex()), context }); else return method.invoke(object, new Object[] { context }); } } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } return null; }
From source file:com.projity.field.Field.java
private Object getPropertyValue(Object object, FieldContext context) { Object result = null;/*from w w w . j av a 2 s . c o m*/ if (context == null) context = specialFieldContext; if (isFormula()) { result = this.evaluateFormula(object); // for now not time distrib } else { if (methodGet == null) return null; try { if (getHasNoContext) result = methodGet.invoke(object, (isIndexed() ? new Object[] { new Integer(index) } : new Object[] {})); else { result = methodGet.invoke(object, (isIndexed() ? new Object[] { new Integer(index), context } : new Object[] { context })); } } catch (IllegalArgumentException e) { System.out.println("Bad field " + this); e.printStackTrace(); } catch (IllegalAccessException e) { System.out.println("Bad field " + this); e.printStackTrace(); } catch (InvocationTargetException e) { System.out.println("Bad field " + this); e.printStackTrace(); } } return result; }
From source file:jp.terasoluna.fw.util.ConvertUtilTest.java
/** * testConvertIfNotNull04() <br>//from w w w . ja v a 2 s.c o m * <br> * () <br> * E <br> * <br> * () obj:Thread<br> * () clazz:AlgorithmParameterGenerator.class<br> * <br> * () IllegalArgumentException????<br> * <br> * obj??clazz????????IllegalArgumentException?????? <br> * @throws Exception ????? */ @Test public void testConvertIfNotNull04() throws Exception { // ?? Thread thread = new Thread(); // try { ConvertUtil.convert(thread, AlgorithmParameterGenerator.class); fail(); } catch (IllegalArgumentException e) { e.printStackTrace(); } }
From source file:org.apache.wookie.WidgetWebMenuServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(true); Messages localizedMessages = LocaleHandler.localizeMessages(request); IWidgetAdminManager manager = (IWidgetAdminManager) session .getAttribute(WidgetAdminManager.class.getName()); if (manager == null) { manager = new WidgetAdminManager(localizedMessages); session.setAttribute(WidgetAdminManager.class.getName(), manager); }//from w w w .j a va 2s. co m Configuration properties = (Configuration) request.getSession().getServletContext() .getAttribute("properties"); //$NON-NLS-1$ request.setAttribute("version", properties.getString("widget.version")); //$NON-NLS-1$ //$NON-NLS-2$ String task = request.getParameter("operation"); //$NON-NLS-1$ Operation op = null; // sanity check... if (task != null) { // if this is called with a string not contained within the enumerated list an exception is thrown try { op = Operation.valueOf(task); } catch (IllegalArgumentException e) { op = null; request.setAttribute("error_value", localizedMessages.getString("WidgetWebMenuServlet.0")); //$NON-NLS-1$ //$NON-NLS-2$ } } if (op != null) { switch (op) { case INDEX: { doForward(request, response, fMainPage); break; } case NEW_DESIGN: { listOperation(request, session, manager); doForward(request, response, fNewDesignPage); break; } case LISTWIDGETS: { listOperation(request, session, manager); doForward(request, response, fListWidgetsPage); break; } case DEMO_WIDGET: { String idKey = request.getParameter("idkey"); try { IPersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager(); String guid = persistenceManager.findWidgetInstanceByIdKey(idKey).getWidget().getGuid(); AbstractWookieConnectorService conn = getConnectorService(request); conn.setCurrentUser("testuser"); org.apache.wookie.connector.framework.WidgetInstance instanceOne = conn .getOrCreateInstance(guid); conn.setPropertyForInstance(instanceOne, "setpersonalproperty", "moderator", "true"); conn.setCurrentUser("testuser2"); org.apache.wookie.connector.framework.WidgetInstance instanceTwo = conn .getOrCreateInstance(guid); request.setAttribute("firstWidgetURL", instanceOne.getUrl()); request.setAttribute("secondWidgetURL", instanceTwo.getUrl()); request.setAttribute("widgetHeight", instanceOne.getHeight()); request.setAttribute("widgetWidth", instanceOne.getWidth()); request.setAttribute("proxy", WidgetInstancesController.checkProxy(request)); doForward(request, response, fDemoWidgetPage); } catch (WookieConnectorException e) { e.printStackTrace(); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } break; } case INSTANTIATE: { instantiateOperation(request, manager); doForward(request, response, fInstantiateWidgetsPage); break; } case REQUESTAPIKEY: { requestApiKeyOperation(request, properties, manager); doForward(request, response, fMainPage); break; } default: { request.setAttribute("error_value", localizedMessages.getString("WidgetWebMenuServlet.2"));//$NON-NLS-1$ //$NON-NLS-2$ doForward(request, response, fMainPage); } } } else { doForward(request, response, fMainPage); } }
From source file:com.projity.field.Field.java
public boolean setInternalValue(Object object, Object value, FieldContext context) throws FieldParseException { if (context == null) context = specialFieldContext;// www .j a va2 s . c om if (!FieldContext.isForceValue(context) && isReadOnly(object, context)) { // don't allow setting of read only // fields // log.warn("Tried to set value of read only field" + getId()); return false; } if (value != null && value.equals(getValue(object, context))) // if // not // change, // do // nothing return false; // TODO certain time-distibued fields need to be // changed if (hasExternalType()) { // does the second pass, converting from // say, Date to long value = FieldConverter.convert(value, internalType, context); // convert // from // date // to // long // for // example if (value == null && !isMap()) // TODO is this how to treat null values? return false; } if (range != null) { range.validate(value, this); } if (methodSet == null) return false; if (FieldContext.isParseOnly(context)) // if just parsing, do not set return false; try { if (isMap()) { Map map = (Map) getPropertyValue(object, context); map.put(getId(), value); } else if (setHasNoContext) { methodSet.invoke(object, (isIndexed() ? new Object[] { new Integer(index), value } : new Object[] { value })); } else { methodSet.invoke(object, (isIndexed() ? new Object[] { new Integer(index), value, context } : new Object[] { value, context })); } //LC if (object instanceof DataObject) { if (context == null || !context.isNoDirty()) ((DataObject) object).setDirty(true); } } catch (IllegalArgumentException e) { throw new FieldParseException(e); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); e.printStackTrace(); if (cause != null && cause instanceof FieldParseException) throw (FieldParseException) cause; else { // setters can throw other values, so don't treat as bad exception throw new FieldParseException(cause.getMessage()); } } return true; }