List of usage examples for java.lang.reflect InvocationTargetException getCause
public Throwable getCause()
From source file:rb.app.QNTransientRBSystem.java
/** * Evaluate theta_c (for the quadratic nonlinearity) at the current parameter. *//*from ww w . j a v a 2 s . c om*/ public double eval_theta_c() { Method meth; try { Class partypes[] = new Class[1]; partypes[0] = double[].class; meth = mAffineFnsClass.getMethod("evaluateC", partypes); } catch (NoSuchMethodException nsme) { throw new RuntimeException("getMethod for evaluateC failed", nsme); } Double theta_val; try { Object arglist[] = new Object[1]; arglist[0] = current_parameters.getArray(); Object theta_obj = meth.invoke(mTheta, arglist); theta_val = (Double) theta_obj; } catch (IllegalAccessException iae) { throw new RuntimeException(iae); } catch (InvocationTargetException ite) { throw new RuntimeException(ite.getCause()); } return theta_val.doubleValue(); }
From source file:org.artifactory.support.core.bundle.AbstractSupportBundleService.java
/** * Fetches Throwable cause/* w ww . ja v a 2 s .c om*/ * * @param e exception to check * @return actual exception cause */ private String getCause(InvocationTargetException e) { return (e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); }
From source file:edu.harvard.iq.dataverse.ingest.IngestableDataChecker.java
public String detectTabularDataFormat(File fh) { boolean DEBUG = false; String readableFormatType = null; try {/*www . jav a2s . com*/ int buffer_size = this.getBufferSize(fh); dbgLog.fine("buffer_size: " + buffer_size); // set-up a FileChannel instance for a given file object FileChannel srcChannel = new FileInputStream(fh).getChannel(); // create a read-only MappedByteBuffer MappedByteBuffer buff = srcChannel.map(FileChannel.MapMode.READ_ONLY, 0, buffer_size); //this.printHexDump(buff, "hex dump of the byte-buffer"); //for (String fmt : defaultFormatSet){ buff.rewind(); dbgLog.fine("before the for loop"); for (String fmt : this.getTestFormatSet()) { // get a test method Method mthd = testMethods.get(fmt); //dbgLog.info("mthd: " + mthd.getName()); try { // invoke this method Object retobj = mthd.invoke(this, buff); String result = (String) retobj; if (result != null) { dbgLog.fine("result for (" + fmt + ")=" + result); if (DEBUG) { out.println("result for (" + fmt + ")=" + result); } if (readableFileTypes.contains(result)) { readableFormatType = result; } dbgLog.fine("readableFormatType=" + readableFormatType); return readableFormatType; } else { dbgLog.fine("null was returned for " + fmt + " test"); if (DEBUG) { out.println("null was returned for " + fmt + " test"); } } } catch (InvocationTargetException e) { Throwable cause = e.getCause(); // added null check because of "homemade.zip" from https://redmine.hmdc.harvard.edu/issues/3273 if (cause.getMessage() != null) { err.format(cause.getMessage()); e.printStackTrace(); } else { dbgLog.info("cause.getMessage() was null for " + e); e.printStackTrace(); } } catch (IllegalAccessException e) { e.printStackTrace(); } catch (BufferUnderflowException e) { dbgLog.info("BufferUnderflowException " + e); e.printStackTrace(); } } return readableFormatType; } catch (FileNotFoundException fe) { dbgLog.fine("exception detected: file was not foud"); fe.printStackTrace(); } catch (IOException ie) { dbgLog.fine("other io exception detected"); ie.printStackTrace(); } return readableFormatType; }
From source file:org.apache.openejb.math.stat.descriptive.DescriptiveStatistics.java
/** * Sets the implementation to be used by {@link #getPercentile(double)}. * The supplied <code>UnivariateStatistic</code> must provide a * <code>setQuantile(double)</code> method; otherwise * <code>IllegalArgumentException</code> is thrown. * * @param percentileImpl the percentileImpl to set * @throws IllegalArgumentException if the supplied implementation does not * provide a <code>setQuantile</code> method * @since 1.2//from ww w . java 2 s. com */ public synchronized void setPercentileImpl(final UnivariateStatistic percentileImpl) { try { percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME, new Class[] { Double.TYPE }) .invoke(percentileImpl, new Object[] { Double.valueOf(50.0d) }); } catch (final NoSuchMethodException e1) { throw MathRuntimeException.createIllegalArgumentException( "percentile implementation {0} does not support setQuantile", percentileImpl.getClass().getName()); } catch (final IllegalAccessException e2) { throw MathRuntimeException.createIllegalArgumentException(ILLEGAL_ACCESS_MESSAGE, SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName()); } catch (final InvocationTargetException e3) { throw MathRuntimeException.createIllegalArgumentException(e3.getCause()); } this.percentileImpl = percentileImpl; }
From source file:dk.netarkivet.archive.arcrepository.bitpreservation.FileBasedActiveBitPreservationTester.java
/** * Tests that the correct setup is done when running a checksum batch job and that the checksum batch job generates * the expected output.//w w w . j av a 2s . co m * <p> * Tests requirements of Assignment 3.1.2 * * @throws FileNotFoundException * @throws IOException */ @Test public void testRunChecksumJob() throws FileNotFoundException, IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method runChecksumJob = ReflectUtils.getPrivateMethod(FileBasedActiveBitPreservation.class, "runChecksumJob", Replica.class); FileBasedActiveBitPreservation acp = FileBasedActiveBitPreservation.getInstance(); // Test valid parameters: try { runChecksumJob.invoke(acp, (Replica) null); fail("Argument 'replica' must not be null"); } catch (InvocationTargetException e) { assertEquals("Should have thrown ANV", ArgumentNotValid.class, e.getCause().getClass()); // expected } Replica replica = Replica.getReplicaFromId(TestInfo.REPLICA_ID_ONE); runChecksumJob.invoke(acp, replica); File unsortedOutput = WorkFiles.getFile(replica, WorkFiles.CHECKSUMS_ON_BA); assertTrue("No output file generated for unsorted output", unsortedOutput.exists()); /* * No longer automatically sorting when not needed File sortedOutput = new File(outputSubDir, * Constants.SORTED_OUTPUT_FILE); assertTrue("No output file generated for sorted output", * sortedOutput.exists()); */ assertEquals("Unsorted output file should have been deleted from FTP " + "server", 0, TestRemoteFile.remainingFiles().size()); /* * assertEquals("The two files containing unsorted output" + " and sorted output do not have the same size", * unsortedOutput.length(), sortedOutput.length()); * * FileInputStream fis = new FileInputStream(sortedOutput); BufferedReader in = new BufferedReader(new * InputStreamReader(fis)); String line = null; String prevArcFileName = null; while ((line = in.readLine()) != * null) { String arcFileName = line.substring(0, line.indexOf(Constants.STRING_FILENAME_SEPARATOR)); if * (prevArcFileName != null) { assertTrue("Batch output is not sorted (lexicographically) " + * "according to ARC file name", arcFileName.compareTo(prevArcFileName) > 0); } prevArcFileName = arcFileName; } * in.close(); fis.close(); */ // ChecksumJobTester tests that the correct MD5 checksums are generated. acp.close(); }
From source file:org.apache.openejb.math.stat.descriptive.DescriptiveStatistics.java
/** * Returns an estimate for the pth percentile of the stored values. * <p>// w ww. ja v a2 s . c om * The implementation provided here follows the first estimation procedure presented * <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a> * </p><p> * <strong>Preconditions</strong>:<ul> * <li><code>0 < p ≤ 100</code> (otherwise an * <code>IllegalArgumentException</code> is thrown)</li> * <li>at least one value must be stored (returns <code>Double.NaN * </code> otherwise)</li> * </ul></p> * * @param p the requested percentile (scaled from 0 - 100) * @return An estimate for the pth percentile of the stored data * @throws IllegalStateException if percentile implementation has been * overridden and the supplied implementation does not support setQuantile * values */ public double getPercentile(final double p) { if (percentileImpl instanceof Percentile) { ((Percentile) percentileImpl).setQuantile(p); } else { try { percentileImpl.getClass().getMethod(SET_QUANTILE_METHOD_NAME, new Class[] { Double.TYPE }) .invoke(percentileImpl, new Object[] { Double.valueOf(p) }); } catch (final NoSuchMethodException e1) { // Setter guard should prevent throw MathRuntimeException.createIllegalArgumentException(UNSUPPORTED_METHOD_MESSAGE, percentileImpl.getClass().getName(), SET_QUANTILE_METHOD_NAME); } catch (final IllegalAccessException e2) { throw MathRuntimeException.createIllegalArgumentException(ILLEGAL_ACCESS_MESSAGE, SET_QUANTILE_METHOD_NAME, percentileImpl.getClass().getName()); } catch (final InvocationTargetException e3) { throw MathRuntimeException.createIllegalArgumentException(e3.getCause()); } } return apply(percentileImpl); }
From source file:com.quinsoft.zeidon.objectdefinition.LodDef.java
private int executeVmlConstraint(View view, ObjectConstraintType type) { Object object = getConstraintObject(view); try {// ww w. j a va 2 s . c o m Method method; try { method = object.getClass().getMethod(getConstraintOper(), ARGUMENT_TYPES1); Integer rc = (Integer) method.invoke(object, view, type.getVmlValue(), 0); return rc; } catch (NoSuchMethodException e1) { method = object.getClass().getMethod(getConstraintOper(), ARGUMENT_TYPES2); Integer rc = (Integer) method.invoke(object, view, type); return rc; } } catch (InvocationTargetException e) { Throwable target = e.getTargetException(); if (target instanceof ZeidonException) throw (ZeidonException) target; target = e.getCause(); if (target instanceof ZeidonException) throw (ZeidonException) target; throw ZeidonException.wrapException(e).appendMessage("Class = %s", object.getClass().getCanonicalName()) .appendMessage("Method name = %s", getConstraintOper()); } catch (Exception e) { throw ZeidonException.wrapException(e).appendMessage("Class = %s", object.getClass().getCanonicalName()) .appendMessage("Method name = %s", getConstraintOper()); } }
From source file:rb.ComplexRBSystem.java
public boolean is_derived_output() { Method meth;/*from w w w . ja v a2 s . c o m*/ try { Class<?> partypes[] = null; meth = oldAffFcnCl.getMethod("is_derived_output", partypes); } catch (NoSuchMethodException nsme) { return false; } try { Object arglist[] = null; Object theta_obj = meth.invoke(oldAffFcnObj, 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:org.ajax4jsf.renderkit.compiler.MethodCallElement.java
void handleInvocationTargetException(TemplateContext context, InvocationTargetException e) { MethodCallElement._log.error(// w w w .j av a 2 s . com Messages.getMessage(Messages.METHOD_CALL_ERROR_1a, methodName, context.getComponent().getId()), e); throw new FacesException(Messages.getMessage(Messages.METHOD_CALL_ERROR_2a, new Object[] { methodName, context.getComponent().getId(), e.getCause().getMessage() }), e); }
From source file:com.ibm.team.build.internal.hjplugin.RTCScm.java
@Override protected PollingResult compareRemoteRevisionWith(AbstractProject<?, ?> project, Launcher launcher, FilePath workspacePath, TaskListener listener, SCMRevisionState revisionState) throws IOException, InterruptedException { // if #requiresWorkspaceForPolling is false, expect that launcher and workspacePath are null listener.getLogger().println(Messages.RTCScm_checking_for_changes()); // check to see if there are incoming changes try {// www. jav a 2s .co m RTCFacadeWrapper facade = RTCFacadeFactory .getFacade(getDescriptor().getMasterBuildToolkit(getBuildTool(), listener), null); Boolean changesIncoming = (Boolean) facade.invoke("incomingChanges", //$NON-NLS-1$ new Class[] { String.class, // serverURI String.class, // userId String.class, // password File.class, // passwordFile int.class, // timeout String.class, // buildWorkspace Object.class, }, // listener getServerURI(), getUserId(), getPassword(), getPasswordFileFile(), getTimeout(), getBuildWorkspace(), listener); if (changesIncoming.equals(Boolean.TRUE)) { listener.getLogger().println(Messages.RTCScm_changes_found()); return PollingResult.SIGNIFICANT; } else { listener.getLogger().println(Messages.RTCScm_no_changes_found()); return PollingResult.NO_CHANGES; } } catch (InvocationTargetException e) { Throwable eToReport = e.getCause(); if (eToReport == null) { eToReport = e; } PrintWriter writer = listener .fatalError(Messages.RTCScm_checking_for_changes_failure(eToReport.getMessage())); eToReport.printStackTrace(writer); // if we can't check for changes then we can't build it throw new AbortException(Messages.RTCScm_checking_for_changes_failure2(eToReport.getMessage())); } catch (Exception e) { PrintWriter writer = listener.error(Messages.RTCScm_checking_for_changes_failure3(e.getMessage())); e.printStackTrace(writer); // if we can't check for changes then we can't build it throw new AbortException(Messages.RTCScm_checking_for_changes_failure3(e.getMessage())); } }