List of usage examples for java.lang.reflect InvocationTargetException getCause
public Throwable getCause()
From source file:rb.ComplexRBSystem.java
public void cal_derived_output() { if (is_derived_output()) { Method meth;/*from ww w . j ava 2s.c o m*/ try { Class<?> partypes[] = new Class[1]; partypes[0] = double[].class; meth = oldAffFcnCl.getMethod("cal_derived_output", partypes); } catch (NoSuchMethodException nsme) { throw new RuntimeException("getMethod for cal_derived_output failed", nsme); } try { Object arglist[] = new Object[1]; double[] input = new double[4]; for (int i = 0; i < getNumOutputs(); i++) { input[0] = RB_outputs[i].getReal(); input[1] = RB_outputs[i].getImaginary(); input[2] = RB_output_error_bounds[i].getReal(); input[3] = RB_output_error_bounds[i].getImaginary(); arglist[0] = input; Object theta_obj = meth.invoke(oldAffFcnObj, arglist); double[] output = (double[]) theta_obj; RB_outputs[i] = new Complex(output[0], output[1]); RB_output_error_bounds[i] = new Complex(output[2], output[3]); } } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite.getCause()); } } }
From source file:rb.app.ComplexRBSystem.java
public boolean is_derived_output() { Method meth;//from www .j av a 2 s .c o m try { Class partypes[] = null; meth = mAffineFnsClass.getMethod("is_derived_output", partypes); } catch (NoSuchMethodException nsme) { return false; } try { Object arglist[] = null; Object theta_obj = meth.invoke(mTheta, arglist); boolean val = (Boolean) theta_obj; return val; } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite.getCause()); } }
From source file:at.ac.sbg.icts.spacebrew.client.SpacebrewClient.java
/** * Callback method for the <code>WebsocketClient</code> object. * /*from w ww . j av a 2 s . c o m*/ * @param string The received message * @throws Throwable */ @Override public void onMessage(String string) { Object temp = JSONValue.parse(string); JSONObject container = (JSONObject) temp; JSONObject message = (JSONObject) container.get("message"); String name = (String) message.get("name"); String type = (String) message.get("type"); String value = (String) message.get("value"); if (subscriberMethods.containsKey(name)) { Throwable cause = null; try { Method method = subscriberMethods.get(name).get(type); if (type.equals(SpacebrewMessage.TYPE_BOOLEAN)) { method.invoke(callback, Boolean.parseBoolean(value)); } else if (type.equals(SpacebrewMessage.TYPE_RANGE)) { method.invoke(callback, sanitizeRangeMessage(value)); } else if (type.equals(SpacebrewMessage.TYPE_STRING)) { method.invoke(callback, value); } } catch (InvocationTargetException e) { cause = e.getCause(); } catch (IllegalAccessException e) { cause = e.getCause(); } if (cause != null) { log.error( "Could not pass incoming spacebrew message to callback, exception occurred while calling callback method for subscriber with name \"{}\" and type \"{}\"!", name, type); StringWriter errors = new StringWriter(); cause.printStackTrace(new PrintWriter(errors)); log.debug("Stacktrace: \n" + errors); } } if (subscriberObjects.containsKey(name)) { Object subscriber = null; try { subscriber = subscriberObjects.get(name).get(type); if (type.equals(SpacebrewMessage.TYPE_BOOLEAN)) { ((BooleanSubscriber) subscriber).receive(Boolean.parseBoolean(value)); } else if (type.equals(SpacebrewMessage.TYPE_RANGE)) { ((RangeSubscriber) subscriber).receive(sanitizeRangeMessage(value)); } else if (type.equals(SpacebrewMessage.TYPE_STRING)) { ((StringSubscriber) subscriber).receive(value); } } catch (Exception e) { log.error( "Could not pass message to callback, exception occured while passing message to subscriber with name \"{}\"", name); log.debug("Exception: {}", e); } } }
From source file:com.ibm.team.build.internal.hjplugin.RTCScm.java
@Override public boolean checkout(AbstractBuild<?, ?> build, Launcher arg1, FilePath workspacePath, BuildListener listener, File changeLogFile) throws IOException, InterruptedException { listener.getLogger().println(Messages.RTCScm_checkout_started()); File passwordFileFile = getPasswordFileFile(); String baselineSetName = getBaselineSetName(build); String localBuildToolKit;// w w w . j ava 2 s . c om String nodeBuildToolKit; String passwordToUse = null; try { localBuildToolKit = getDescriptor().getMasterBuildToolkit(getBuildTool(), listener); nodeBuildToolKit = getDescriptor().getBuildToolkit(getBuildTool(), build.getBuiltOn(), listener); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("checkout : " + build.getProject().getName() + " " + build.getDisplayName() + " " //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ + build.getBuiltOnStr() + " Load directory=\"" + workspacePath.getRemote() + "\"" + //$NON-NLS-2$ " Build tool=\"" + getBuildTool() + "\"" + //$NON-NLS-1$ //$NON-NLS-2$ " Local Build toolkit=\"" + localBuildToolKit + "\"" + //$NON-NLS-1$ //$NON-NLS-2$ " Node Build toolkit=\"" + nodeBuildToolKit + "\"" + //$NON-NLS-1$ //$NON-NLS-2$ " Server URI=\"" + getServerURI() + "\"" + //$NON-NLS-1$ //$NON-NLS-2$ " Userid=\"" + getUserId() + "\"" + //$NON-NLS-1$ //$NON-NLS-2$ " Authenticating with " //$NON-NLS-1$ + (passwordFileFile == null ? " configured password " : passwordFileFile.getAbsolutePath()) //$NON-NLS-1$ + " Build workspace=\"" + getBuildWorkspace() + "\"" + //$NON-NLS-2$ " Baseline Set name=\"" + baselineSetName + "\""); //$NON-NLS-1$ //$NON-NLS-2$ } RTCFacadeWrapper facade = RTCFacadeFactory.getFacade(localBuildToolKit, null); passwordToUse = (String) facade.invoke("determinePassword", new Class[] { //$NON-NLS-1$ String.class, // password, File.class, // passwordFile, }, getPassword(), getPasswordFileFile()); } catch (InvocationTargetException e) { Throwable eToReport = e.getCause(); if (eToReport == null) { eToReport = e; } PrintWriter writer = listener.fatalError(Messages.RTCScm_checkout_failure(eToReport.getMessage())); eToReport.printStackTrace(writer); LOGGER.log(Level.FINER, "determinePassword had invocation failure " + eToReport.getMessage(), //$NON-NLS-1$ eToReport); // if we can't check out then we can't build it throw new AbortException(Messages.RTCScm_checkout_failure2(eToReport.getMessage())); } catch (Exception e) { PrintWriter writer = listener.fatalError(Messages.RTCScm_checkout_failure3(e.getMessage())); e.printStackTrace(writer); LOGGER.log(Level.FINER, "determinePassword failure " + e.getMessage(), e); //$NON-NLS-1$ // if we can't check out then we can't build it throw new AbortException(Messages.RTCScm_checkout_failure4(e.getMessage())); } OutputStream changeLogStream = new FileOutputStream(changeLogFile); RemoteOutputStream changeLog = new RemoteOutputStream(changeLogStream); if (workspacePath.isRemote()) { sendJarsToSlave(workspacePath); } boolean debug = Boolean.parseBoolean(build.getEnvironment(listener).get(DEBUG_PROPERTY)); RTCCheckoutTask checkout = new RTCCheckoutTask( build.getProject().getName() + " " + build.getDisplayName() + " " + build.getBuiltOnStr(), //$NON-NLS-1$ //$NON-NLS-2$ nodeBuildToolKit, getServerURI(), getUserId(), passwordToUse, getTimeout(), getBuildWorkspace(), baselineSetName, listener, changeLog, workspacePath.isRemote(), debug); workspacePath.act(checkout); return true; }
From source file:rb.app.ComplexRBSystem.java
public void cal_derived_output() { if (is_derived_output()) { Method meth;/*from ww w .j a va 2s . c o m*/ try { Class partypes[] = new Class[1]; partypes[0] = double[].class; meth = mAffineFnsClass.getMethod("cal_derived_output", partypes); } catch (NoSuchMethodException nsme) { throw new RuntimeException("getMethod for cal_derived_output failed", nsme); } try { Object arglist[] = new Object[1]; double[] input = new double[4]; for (int i = 0; i < get_n_outputs(); i++) { input[0] = RB_outputs[i].getReal(); input[1] = RB_outputs[i].getImaginary(); input[2] = RB_output_error_bounds[i].getReal(); input[3] = RB_output_error_bounds[i].getImaginary(); arglist[0] = input; Object theta_obj = meth.invoke(mTheta, arglist); double[] output = (double[]) theta_obj; RB_outputs[i] = new Complex(output[0], output[1]); RB_output_error_bounds[i] = new Complex(output[2], output[3]); } } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite.getCause()); } } }
From source file:org.ajax4jsf.renderkit.compiler.MethodCallElement.java
void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) { String logMessage = (utils)/* w w w. j a va2 s. c o m*/ ? Messages.getMessage(Messages.METHOD_CALL_ERROR_1, methodName, context.getComponent().getId()) : Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId()); String excMessage = (utils) ? Messages.getMessage(Messages.METHOD_CALL_ERROR_2, new Object[] { methodName, context.getComponent().getId(), e.getCause().getMessage() }) : Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[] { methodName, context.getComponent().getId(), e.getCause().getMessage() }); MethodCallElement._log.error(logMessage, e); throw new FacesException(excMessage, e); }
From source file:org.apache.hadoop.hbase.util.FSUtils.java
/** * Create the specified file on the filesystem. By default, this will: * <ol>/*w w w.j ava 2s. c o m*/ * <li>overwrite the file if it exists</li> * <li>apply the umask in the configuration (if it is enabled)</li> * <li>use the fs configured buffer size (or 4096 if not set)</li> * <li>use the default replication</li> * <li>use the default block size</li> * <li>not track progress</li> * </ol> * * @param fs {@link FileSystem} on which to write the file * @param path {@link Path} to the file to write * @param perm permissions * @param favoredNodes * @return output stream to the created file * @throws IOException if the file cannot be created */ public static FSDataOutputStream create(FileSystem fs, Path path, FsPermission perm, InetSocketAddress[] favoredNodes) throws IOException { if (fs instanceof HFileSystem) { FileSystem backingFs = ((HFileSystem) fs).getBackingFs(); if (backingFs instanceof DistributedFileSystem) { // Try to use the favoredNodes version via reflection to allow backwards- // compatibility. try { return (FSDataOutputStream) (DistributedFileSystem.class .getDeclaredMethod("create", Path.class, FsPermission.class, boolean.class, int.class, short.class, long.class, Progressable.class, InetSocketAddress[].class) .invoke(backingFs, path, perm, true, getDefaultBufferSize(backingFs), getDefaultReplication(backingFs, path), getDefaultBlockSize(backingFs, path), null, favoredNodes)); } catch (InvocationTargetException ite) { // Function was properly called, but threw it's own exception. throw new IOException(ite.getCause()); } catch (NoSuchMethodException e) { LOG.debug("DFS Client does not support most favored nodes create; using default create"); if (LOG.isTraceEnabled()) LOG.trace("Ignoring; use default create", e); } catch (IllegalArgumentException e) { LOG.debug("Ignoring (most likely Reflection related exception) " + e); } catch (SecurityException e) { LOG.debug("Ignoring (most likely Reflection related exception) " + e); } catch (IllegalAccessException e) { LOG.debug("Ignoring (most likely Reflection related exception) " + e); } } } return create(fs, path, perm, true); }
From source file:org.nuxeo.ecm.platform.relations.jena.JenaGraph.java
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final String name = method.getName(); if (name.equals("commit")) { return null; } else if (name.equals("setAutoCommit")) { return null; } else {//from w w w .ja va 2 s. c o m try { return method.invoke(connection, args); } catch (InvocationTargetException e) { throw e.getCause(); } } }
From source file:org.talend.osgi.hook.OsgiLoaderTest.java
@Test() public void CheckFailAccessinClassInFragmentLib() throws IOException, BundleException, SecurityException, IllegalArgumentException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { Bundle bundleNoJar = osgiBundle.getBundleContext().installBundle(BUNDLE_NO_LIB_FOLDER_URL); Bundle bundle = osgiBundle.getBundleContext().installBundle(BUNDLE_CALLING_LIB_FOLDER_URL); try {//from ww w .j a v a 2s . co m // this should fail if the Activator fails to load the class from the fragment lib try { // this forces the bundle classloader to be initialised bundleNoJar.getResource("foo"); //$NON-NLS-1$ callBundleMethodToCallLibApi(bundle); fail("starting bundle should have thrown an exception."); //$NON-NLS-1$ } catch (InvocationTargetException be) { if (!(be.getCause() instanceof NoClassDefFoundError)) { throw be; } // else do nothing cause this is an expected exception } // no assert here because the above should fail in case of error. } finally { bundle.uninstall(); bundleNoJar.uninstall(); } bundle = Platform.getBundle(BUNDLE_CALLING_LIB); assertNull(bundle); bundleNoJar = Platform.getBundle(BUNDLE_NO_LIB); assertNull(bundleNoJar); }
From source file:org.talend.osgi.hook.OsgiLoaderTest.java
@Test public void CheckNoExistingJarClassLoadGeneratesMissingJarObservableCallButNoJarReturned() throws IOException, BundleException, SecurityException, IllegalArgumentException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { final Boolean[] observerCalled = new Boolean[1]; observerCalled[0] = false;/*from w ww . j a v a2 s .c om*/ Observer observer = new Observer() { @Override public void update(Observable o, Object arg) { observerCalled[0] = true; } }; setupMissingJarLoadingObserver(observer); Bundle bundleNoJar = osgiBundle.getBundleContext().installBundle(BUNDLE_NO_LIB_FOLDER_URL); Bundle bundle = osgiBundle.getBundleContext().installBundle(BUNDLE_CALLING_LIB_FOLDER_URL); try { try { // this forces the bundle classloader to be initialised bundleNoJar.getResource("foo"); //$NON-NLS-1$ callBundleMethodToCallLibApi(bundle); fail("Bundle start should have thrown an exception cause no lib is provided"); //$NON-NLS-1$ } catch (InvocationTargetException be) { if (!(be.getCause() instanceof NoClassDefFoundError)) { throw be; } // else do nothing cause this is an expected exception } // check finding of existing jar in fragment assertTrue(observerCalled[0]); } finally { bundle.uninstall(); bundleNoJar.uninstall(); unsetupMissingJarLoadingObserver(observer); } bundle = Platform.getBundle(BUNDLE_CALLING_LIB); assertNull(bundle); bundleNoJar = Platform.getBundle(BUNDLE_NO_LIB); assertNull(bundleNoJar); }