Example usage for java.lang NoSuchMethodException printStackTrace

List of usage examples for java.lang NoSuchMethodException printStackTrace

Introduction

In this page you can find the example usage for java.lang NoSuchMethodException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:net.navasoft.madcoin.backend.services.WorkRequestQueryFilter.java

/**
 * Choose filter.// ww  w. j  a v a 2  s  .  c  o  m
 * 
 * @param entryVO
 *            the entry vo
 * @return the generic filter
 * @since 27/07/2014, 06:48:16 PM
 */
@Override
public GenericFilter<WorkRequestQueryVO> chooseFilter(WorkRequestQueryVO entryVO) {
    GenericFilter<WorkRequestQueryVO> selector = null;
    Method[] accessors = WorkRequestQueryVO.class.getMethods();
    try {
        accessors = (Method[]) ArrayUtils.removeElement(accessors,
                WorkRequestQueryVO.class.getMethod("getClass", ArrayUtils.EMPTY_CLASS_ARRAY));
    } catch (NoSuchMethodException e1) {
        e1.printStackTrace();
    } catch (SecurityException e1) {
        e1.printStackTrace();
    }
    try {
        if (entryVO != null) {
            for (Method beanGetters : accessors) {
                if (beanGetters.getName().startsWith("get")) {
                    Object fieldValue;
                    fieldValue = beanGetters.invoke(entryVO, ArrayUtils.EMPTY_OBJECT_ARRAY);
                    if (fieldValue != null) {
                        String fieldToFilter = beanGetters.getName().replace("get", "");
                        EFilters guessedFilters = null;
                        if (ArrayUtils.contains(mandatory, fieldToFilter)) {
                            guessedFilters = EFilters.valueOf(fieldToFilter.toUpperCase() + "_FILTER");
                        } else {
                            if (guessedFilters == null) {
                                guessedFilters = optionalCorrelation.get(fieldToFilter);
                            }
                        }
                        selector = (GenericFilter<WorkRequestQueryVO>) Class
                                .forName(guessedFilters.getImplementingClass()).getConstructor(EFilters.class)
                                .newInstance(guessedFilters);
                    }
                }
            }
            if (selector == null) {
                selector = WorkRequestNoFilter.class.newInstance();
            } else {
                selector.setScope(entryVO);
            }
            return selector;
        } else {
            selector = WorkRequestNoFilter.class.newInstance();
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    } catch (SecurityException e) {
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    return selector;
}

From source file:com.cegeka.GethBean.java

public void processPdf(OutputStream pdf, Exchange exchange) {
    Object receiver = exchange.getProperty("receiver");
    String methodName = (String) exchange.getProperty("method");

    try {/*  w w  w . j a  v a  2  s  .com*/
        Method method = receiver.getClass().getMethod(methodName, OutputStream.class);

        method.invoke(receiver, pdf);
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:com.paic.zhifu.wallet.activity.modules.redpacket.PagerContainer.java

private void init() {
    //Disable clipping of children so non-selected pages are visible
    setClipChildren(false);//from ww  w  . jav a  2  s .  c  o  m

    //Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    //You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    //  setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    try {
        Method setLayerTypeMethod = this.getClass().getMethod("setLayerType",
                new Class[] { int.class, Paint.class });
        setLayerTypeMethod.invoke(this, new Object[] { LAYER_TYPE_SOFTWARE, null });
    } catch (NoSuchMethodException e) {
        // Older OS, no HW acceleration anyway
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:com.smartitengineering.loadtest.engine.impl.management.AbstracltTestCaseBatchCreator.java

private TestCaseCreationFactory getTestCaseCreationFactory(UnitTestInstance testInstance)
        throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    final String instanceFactoryClassName = testInstance.getInstanceFactoryClassName();
    if (!StringUtils.isEmpty(instanceFactoryClassName)) {
        try {// w  w  w .  java2  s .co m
            final Class<? extends TestCaseCreationFactory> classForName = (Class<? extends TestCaseCreationFactory>) Class
                    .forName(instanceFactoryClassName);
            try {
                Method method = classForName.getDeclaredMethod("getInstance");
                if (method != null && Modifier.isStatic(method.getModifiers())) {
                    return (TestCaseCreationFactory) method.invoke(classForName);
                }
            } catch (NoSuchMethodException exception) {
                exception.printStackTrace();
            }
            return classForName.newInstance();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
    return DefaultTestCaseCreationFactory.getInstance();
}

From source file:com.example.testsurrondviewpager.PagerContainer.java

private void init() {
    //Disable clipping of children so non-selected pages are visible
    setClipChildren(false);//from   ww  w  .  j av a  2s .c o m
    setWeightSum(3.0f);
    setOrientation(LinearLayout.HORIZONTAL);
    //Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    //You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    //  setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    try {
        Method setLayerTypeMethod = this.getClass().getMethod("setLayerType",
                new Class[] { int.class, Paint.class });
        setLayerTypeMethod.invoke(this, new Object[] { LAYER_TYPE_SOFTWARE, null });
    } catch (NoSuchMethodException e) {
        // Older OS, no HW acceleration anyway
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
}

From source file:com.umeng.comm.ui.activities.FeedsActivity.java

/**
 * //from  ww  w  .  j a  v a 2 s.  c  o  m
 * ??apk?</br>
 */
private void addLoginPlatforms() {
    boolean isFromGenerateApk = getApplication().getClass().getSuperclass().equals(Application.class);
    if (isFromGenerateApk) {
        try {
            Method method = getApplication().getClass().getMethod("addLoginPlatforms", Activity.class);
            method.invoke(null, this);
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }
}

From source file:org.pentaho.di.repository.pur.WebServiceManager.java

private void registerRestSpecification(Class<?> serviceClass, String serviceName) {
    try {/*  w ww .  j a  va  2s  .  co  m*/
        registerSpecification(WebServiceSpecification.getRestServiceSpecification(serviceClass, serviceName));
    } catch (NoSuchMethodException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:sample.contact.ClientApplication.java

public void invokeContactService(Authentication authentication, int nrOfCalls) {
    StopWatch stopWatch = new StopWatch(nrOfCalls + " ContactService call(s)");
    Map<String, ContactService> contactServices = this.beanFactory.getBeansOfType(ContactService.class, true,
            true);/*from   w w w.ja v  a2  s.c o m*/

    SecurityContextHolder.getContext().setAuthentication(authentication);

    for (String beanName : contactServices.keySet()) {
        Object object = this.beanFactory.getBean("&" + beanName);

        try {
            System.out.println("Trying to find setUsername(String) method on: " + object.getClass().getName());

            Method method = object.getClass().getMethod("setUsername", new Class[] { String.class });
            System.out.println("Found; Trying to setUsername(String) to " + authentication.getPrincipal());
            method.invoke(object, authentication.getPrincipal());
        } catch (NoSuchMethodException ignored) {
            System.out.println("This client proxy factory does not have a setUsername(String) method");
        } catch (IllegalAccessException ignored) {
            ignored.printStackTrace();
        } catch (InvocationTargetException ignored) {
            ignored.printStackTrace();
        }

        try {
            System.out.println("Trying to find setPassword(String) method on: " + object.getClass().getName());

            Method method = object.getClass().getMethod("setPassword", new Class[] { String.class });
            method.invoke(object, authentication.getCredentials());
            System.out.println("Found; Trying to setPassword(String) to " + authentication.getCredentials());
        } catch (NoSuchMethodException ignored) {
            System.out.println("This client proxy factory does not have a setPassword(String) method");
        } catch (IllegalAccessException ignored) {
        } catch (InvocationTargetException ignored) {
        }

        ContactService remoteContactService = contactServices.get(beanName);
        System.out.println("Calling ContactService '" + beanName + "'");

        stopWatch.start(beanName);

        List<Contact> contacts = null;

        for (int i = 0; i < nrOfCalls; i++) {
            contacts = remoteContactService.getAll();
        }

        stopWatch.stop();

        if (contacts.size() != 0) {
            for (Contact contact : contacts) {
                System.out.println("Contact: " + contact);
            }
        } else {
            System.out.println("No contacts found which this user has permission to");
        }

        System.out.println();
        System.out.println(stopWatch.prettyPrint());
    }

    SecurityContextHolder.clearContext();
}

From source file:com.jroossien.boxx.util.item.ItemParser.java

public ItemParser(EItem item) {
    this.item = item;

    if (item == null) {
        return;/*from  w  w w. ja  va2s  .  co  m*/
    }

    //Air can't have any meta.
    if (item.getType() == Material.AIR) {
        this.string = Items.getName(Material.AIR, (byte) 0);
        return;
    }

    List<String> sections = new ArrayList<>();

    sections.add(Items.getName(item.getData()).replaceAll(" ", ""));
    if (item.getAmount() > 1) {
        sections.add(Integer.toString(item.getAmount()));
    }

    for (ItemTag tag : ItemTag.getTags(item.getItemMeta())) {
        if (tag.hasCallback()) {
            String result = tag.getCallback().onGet(item);
            if (result == null || result.isEmpty()) {
                continue;
            }
            if (!result.toLowerCase().contains(tag.getTag().toLowerCase() + ":")) {
                result = Str.escapeWords(Str.escapeQuotes(result));
            } else {
                result = Str.escapeQuotes(result);
            }
            sections.add(tag.getTag().toLowerCase() + ":" + result);
        } else {
            if (tag.getMethod() == null || tag.getMethod().isEmpty()
                    || tag.getMethod().equalsIgnoreCase("null")) {
                continue;
            }
            try {
                Object result = MethodUtils.invokeMethod(item, tag.getMethod(), new Class[0]);
                if (result == null) {
                    continue;
                }
                SingleOption option = (SingleOption) tag.getOption().clone();
                if (!option.parse(result)) {
                    Boxx.get().warn("Failed to parse entity data! [tag=" + tag.getTag() + " value="
                            + result.toString() + " error='" + option.getError() + "']");
                    continue;
                }
                if (option.getValue().equals(option.getDefault())) {
                    continue;
                }
                sections.add(tag.getTag().toLowerCase() + ":"
                        + Str.escapeWords(Str.escapeQuotes(option.serialize())));
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }
    }

    this.string = Str.implode(sections, " ");
}

From source file:edu.ku.brc.af.ui.forms.DataGetterForObj.java

@Override
public Object getFieldValue(final Object dataObjArg, final String fieldName) {
    Object dataObj = dataObjArg;//from  w w  w .j  a v  a2  s  .c  o  m
    //System.out.println("["+fieldName+"]["+(dataObj != null ? dataObj.getClass().toString() : "N/A")+"]");
    Object value = null;
    if (dataObj != null) {
        try {
            Iterator<?> iter = null;
            if (dataObj instanceof Set<?>) {
                iter = ((Set<?>) dataObj).iterator();

            } else if (dataObj instanceof org.hibernate.collection.PersistentSet) {
                iter = ((org.hibernate.collection.PersistentSet) dataObj).iterator();
            }

            if (iter != null) {
                while (iter.hasNext()) {
                    Object obj = iter.next();
                    if (obj instanceof AttributeIFace) // Not scalable (needs interface)
                    {
                        AttributeIFace asg = (AttributeIFace) obj;
                        //log.debug("["+asg.getDefinition().getFieldName()+"]["+fieldName+"]");
                        if (asg.getDefinition().getFieldName().equals(fieldName)) {
                            if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.StringType
                                    .getType()) {
                                return asg.getStrValue();

                                //} else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.MemoType.getType())
                                //{
                                //    return asg.getStrValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.IntegerType
                                    .getType()) {
                                return asg.getDblValue().intValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.FloatType
                                    .getType()) {
                                return asg.getDblValue().floatValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.DoubleType
                                    .getType()) {
                                return asg.getDblValue();

                            } else if (asg.getDefinition().getDataType() == AttributeIFace.FieldType.BooleanType
                                    .getType()) {
                                return new Boolean(asg.getDblValue() != 0.0);
                            }
                        }
                    } else if (obj instanceof FormDataObjIFace) {
                        dataObj = obj;
                        break;

                    } else {
                        return null;
                    }
                }
            }
            //log.debug(fieldName);

            if (fieldName.startsWith("@get")) {
                try {
                    String methodName = fieldName.substring(1, fieldName.length()).trim();
                    Method method = dataObj.getClass().getMethod(methodName, new Class<?>[] {});
                    if (method != null) {
                        value = method.invoke(dataObj, new Object[] {});
                    }

                } catch (NoSuchMethodException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);

                } catch (IllegalAccessException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);

                } catch (InvocationTargetException ex) {
                    ex.printStackTrace();
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);
                }

            } else {
                PropertyDescriptor descr = PropertyUtils.getPropertyDescriptor(dataObj, fieldName.trim());
                if (descr != null) {
                    Method getter = PropertyUtils.getReadMethod(descr);

                    if (getter != null) {
                        value = getter.invoke(dataObj, (Object[]) null);
                        if (value instanceof PersistentSet) {
                            PersistentSet vSet = (PersistentSet) value;
                            if (vSet.getSession() != null && !vSet.isDirty()) {
                                int loadCode = dataObj instanceof FormDataObjIFace
                                        ? ((FormDataObjIFace) dataObj).shouldForceLoadChildSet(getter)
                                        : -1;
                                if (loadCode != 0) {
                                    int max = loadCode == -1 ? vSet.size() : loadCode + 1;
                                    int i = 0;
                                    for (Object v : vSet) {
                                        if (v instanceof FormDataObjIFace) {
                                            ((FormDataObjIFace) v).forceLoad();
                                        }
                                        if (++i == max) {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                } else if (showErrors) {
                    log.error("We could not find a field named[" + fieldName.trim() + "] in data object ["
                            + dataObj.getClass().toString() + "]");
                }
            }
        } catch (Exception ex) {
            log.error(ex);
            if (!(ex instanceof org.hibernate.LazyInitializationException)) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(DataGetterForObj.class, ex);
            }
        }
    }
    return value;
}