Example usage for java.lang IllegalAccessException getStackTrace

List of usage examples for java.lang IllegalAccessException getStackTrace

Introduction

In this page you can find the example usage for java.lang IllegalAccessException getStackTrace.

Prototype

public StackTraceElement[] getStackTrace() 

Source Link

Document

Provides programmatic access to the stack trace information printed by #printStackTrace() .

Usage

From source file:com.zigbee.framework.common.util.BeanCopyUtil.java

/**
 * Apache Copy Properties//from   ww w  . j a va 2s .com
 * @Date        :      2011-8-5
 * @param srcBean source bean instance
 * @param destBean destination bean instance
 * @throws AppException
 */
public static void beanCopyProperties(Object srcBean, Object destBean) throws AppException {
    try {
        org.apache.commons.beanutils.BeanUtils.copyProperties(destBean, srcBean);
    } catch (IllegalAccessException e) {
        e.printStackTrace();
        String errMsg = "BEAN COPY Exception!" + e.getMessage() + e.getStackTrace();
        throw new AppException(CommonErrorConstants.BEAN_COPY_EXCEPTION, errMsg, e.getCause());
    } catch (InvocationTargetException e) {
        e.printStackTrace();
        String errMsg = "BEAN COPY Exception!" + e.getMessage() + e.getStackTrace();
        throw new AppException(CommonErrorConstants.BEAN_COPY_EXCEPTION, errMsg, e.getCause());
    }
}

From source file:hm.binkley.util.XPropsConverter.java

@SuppressWarnings("unchecked")
private static <T, E extends Exception> Conversion<T, E> invokeValueOf(final Class<T> token)
        throws NoSuchMethodError {
    try {//from   w w  w  .ja  va 2  s .  c o m
        final Method method = token.getMethod("valueOf", String.class);
        return value -> {
            try {
                return (T) method.invoke(null, value);
            } catch (final IllegalAccessException e) {
                final IllegalAccessError x = new IllegalAccessError(e.getMessage());
                x.setStackTrace(e.getStackTrace());
                throw x;
            } catch (final InvocationTargetException e) {
                final Throwable root = getRootCause(e);
                final RuntimeException x = new RuntimeException(root);
                x.setStackTrace(root.getStackTrace());
                throw x;
            }
        };
    } catch (final NoSuchMethodException ignored) {
        return null;
    }
}

From source file:hm.binkley.util.XPropsConverter.java

@SuppressWarnings("unchecked")
private static <T, E extends Exception> Conversion<T, E> invokeOf(final Class<T> token)
        throws NoSuchMethodError {
    try {//from  w  ww. j a  va 2s  .  c  om
        final Method method = token.getMethod("of", String.class);
        return value -> {
            try {
                return (T) method.invoke(null, value);
            } catch (final IllegalAccessException e) {
                final IllegalAccessError x = new IllegalAccessError(e.getMessage());
                x.setStackTrace(e.getStackTrace());
                throw x;
            } catch (final InvocationTargetException e) {
                final Throwable root = getRootCause(e);
                final RuntimeException x = new RuntimeException(root);
                x.setStackTrace(root.getStackTrace());
                throw x;
            }
        };
    } catch (final NoSuchMethodException ignored) {
        return null;
    }
}

From source file:hm.binkley.util.XPropsConverter.java

private static <T, E extends Exception> Conversion<T, E> invokeConstructor(final Class<T> token)
        throws NoSuchMethodError {
    try {/*from w  w w  .j  a  v a  2 s  .co m*/
        final Constructor<T> ctor = token.getConstructor(String.class);
        return value -> {
            try {
                return ctor.newInstance(value);
            } catch (final IllegalAccessException e) {
                final IllegalAccessError x = new IllegalAccessError(e.getMessage());
                x.setStackTrace(e.getStackTrace());
                throw x;
            } catch (final InvocationTargetException e) {
                final Throwable root = getRootCause(e);
                final RuntimeException x = new RuntimeException(root);
                x.setStackTrace(root.getStackTrace());
                throw x;
            } catch (final InstantiationException e) {
                final InstantiationError x = new InstantiationError(e.getMessage());
                x.setStackTrace(e.getStackTrace());
                throw x;
            }
        };
    } catch (final NoSuchMethodException ignored) {
        return null;
    }
}

From source file:org.springside.examples.oadata.service.ProjecgtRuleViewService.java

License:asdf

public boolean sysProjectDoc(ProjectData projectData) {
    boolean result = false;
    List<ProjectRuleView> projectRuleViews = projectRuleViewDao
            .queryProjectRuleView(projectData.getProjectId());

    ProjectRuleView projectRuleView = null;
    if (projectRuleViews != null && projectRuleViews.size() > 0) {

        projectRuleView = projectRuleViews.get(0);

        //?/*  www  .j a va2s  .  co m*/
        projectRuleView.setIsPack(projectData.getProjectPkgDatas().size() > 0 ? "1" : "0");
        if (projectData.getProjectPkgDatas().size() > 0) {

            for (ProjectRuleView projRView : projectRuleViews) {
                ProjectRulePkgView projectRulePkgView = new ProjectRulePkgView();
                try {
                    BeanUtils.copyProperties(projectRulePkgView, projRView);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                } catch (InvocationTargetException e) {
                    e.printStackTrace();
                }
                projectRuleView.getPack().add(projectRulePkgView);
            }
        }

        //?
        List<ProjectDocView> projectDocViews = projectDocViewDao.queryProjectDocView(projectData.getProjectId(),
                "2");

        if (projectDocViews != null && projectDocViews.size() > 0) {//?
            List<String> purchaseDocUrls = new ArrayList<String>();
            for (ProjectDocView projectDocView : projectDocViews) {
                purchaseDocUrls
                        .add(projectDocView.getAttachmentPath() + "*" + projectDocView.getAttachmentName());
            }
            //?
            projectRuleView.setPurchaseDocUrl(StringUtils.join(purchaseDocUrls, ","));
        }

        //??
        StringWriter writer = new StringWriter();

        BodyXml<ProjectRuleView> bodyXml = new BodyXml<ProjectRuleView>();
        bodyXml.setProjectInfo(projectRuleView);
        ProjectRuleXml projectXml = new ProjectRuleXml();
        projectXml.setBody(bodyXml);
        HeadXml header = new HeadXml(projectData.getDepartmentId(), projectData.getCreator());
        projectXml.setHeader(header);

        try {
            marshaller.marshal(projectXml, writer);
        } catch (JAXBException e) {
            logger.error("{}|{}XML?:" + e.getStackTrace(),
                    projectData.getId(), projectData.getProjectName());
        }
        try {

            HttpPost httpPost = new HttpPost(propertiesLoader.getProperty("syn.synProjectRuleUrl"));
            // ??/  
            List<NameValuePair> parameters = new ArrayList<NameValuePair>();

            parameters.add(new BasicNameValuePair("xmlContent", writer.toString()));
            // UrlEncodedFormEntity  
            UrlEncodedFormEntity formEntiry = new UrlEncodedFormEntity(parameters, "UTF-8");
            httpPost.setEntity(formEntiry);

            // ?connection poolclient
            CloseableHttpResponse closeableHttpResponse = httpClient.execute(httpPost);
            closeableHttpResponse.getEntity().getContent();
            String xmlContentresp = IOUtils.toString(closeableHttpResponse.getEntity().getContent());
            if (xmlContentresp.contains("operTag")) {
                String operTag = StringUtils.substringBetween(xmlContentresp, "<operTag>", "</operTag>");
                if ("Y".equals(operTag)) {//?   
                    //?? 
                    projectData.setSynStatus(ProjectData.SYNSTATUS_DOC_SUCCESS);
                    projectDataDao.save(projectData);
                    result = true;
                } else {
                    logger.error("?{}|{}??", projectData.getId(),
                            projectData.getProjectName());
                }
            }
            closeableHttpResponse.close();
        } catch (IOException e) {
            e.printStackTrace();
            logger.error("?{}|{}??:" + e.getStackTrace(),
                    projectData.getId(), projectData.getProjectName());
        }
    }
    return result;
}

From source file:org.nuxeo.opensocial.servlet.GuiceContextListener.java

private Module getModuleInstance(String moduleName) throws InstantiationException {
    try {/*from  ww w  . j  a v  a  2 s  . com*/
        return (Module) Class.forName(moduleName).newInstance();
    } catch (IllegalAccessException e) {
        InstantiationException ie = new InstantiationException("IllegalAccessException: " + e.getMessage());
        ie.setStackTrace(e.getStackTrace());
        throw ie;
    } catch (ClassNotFoundException e) {
        InstantiationException ie = new InstantiationException("ClassNotFoundException: " + e.getMessage());
        ie.setStackTrace(e.getStackTrace());
        throw ie;
    }
}