Example usage for java.lang IllegalAccessException getMessage

List of usage examples for java.lang IllegalAccessException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.ankang.report.main.Report.java

@RequestMapping(value = "{resolverAlias}/{serviceAlias}/{methodAlias}")
public void report(HttpServletRequest request, HttpServletResponse response,

        @PathVariable(value = "resolverAlias") String resolverAlias,
        @PathVariable(value = "serviceAlias") String serviceAlias,
        @PathVariable(value = "methodAlias") String methodAlias) throws IOException {

    ReportResolver resolver = null;//from  ww  w . jav a2  s .co  m
    ReportResponse reportResponse = new ReportResponse();
    try {

        resolver = match(resolverAlias);

        reportResponse = handler(serviceAlias, methodAlias, resolver, request);

    } catch (IllegalAccessException e) {
        logger.error("??", e);
        reportResponse.setCode(ReportStatus.FAIL_CODE);
        reportResponse.setMessage(e.getMessage() != null ? e.getMessage() : "??");
    } catch (IllegalArgumentException e) {
        logger.error("?", e);
        reportResponse.setCode(ReportStatus.FAIL_CODE);
        reportResponse.setMessage(e.getMessage() != null ? e.getMessage() : "?");
    } catch (InvocationTargetException e) {
        logger.error("?", e);
        reportResponse.setCode(ReportStatus.FAIL_CODE);
        reportResponse.setMessage(e.getMessage() != null ? e.getMessage() : "?");
    } catch (ReportException e) {
        logger.error(e.getMessage(), e);
        reportResponse.setCode(ReportStatus.FAIL_CODE);
        reportResponse.setMessage(e.getMessage());
    } catch (Exception e) {
        logger.error("", e);
        reportResponse.setCode(ReportStatus.FAIL_CODE);
        reportResponse.setMessage(e.getMessage() != null ? e.getMessage() : "");
    }

    response.setCharacterEncoding("utf-8");
    response.setContentType(resolver.getContextType());
    response.getWriter().print(resolver.out(reportResponse));
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private T getInstance() {
    try {//w  ww  .  j a va 2 s .co m
        return type.newInstance();
    } catch (InstantiationException ie) {
        LOG.error(ie.getMessage());
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    }
    return null;
}

From source file:de.hackerspacebremen.format.JSONFormatter.java

@Override
public String format(final T entity, final String... levels) throws FormatException {
    final JSONObject json = new JSONObject();
    boolean allAttributes = (levels == null || levels.length == 0);
    final List<String> levelList;
    if (levels == null || levels.length == 0) {
        levelList = new ArrayList<String>();
    } else {//w  w w  .  ja  v a2s.com
        levelList = Arrays.asList(levels);
    }
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        final Field[] fields = entity.getClass().getDeclaredFields();
        for (final Field field : fields) {
            if (field.isAnnotationPresent(FormatPart.class)
                    && (allAttributes || levelList.contains(field.getAnnotation(FormatPart.class).level()))) {
                try {
                    final Method method = entity.getClass()
                            .getMethod(this.getGetter(field.getName(), field.getType()), (Class<?>[]) null);
                    final Object methodResult = method.invoke(entity);
                    if (methodResult != null) {
                        final String type = field.getType().toString();
                        if (type.equals("class com.google.appengine.api.datastore.Key")) {
                            json.put(field.getAnnotation(FormatPart.class).key(),
                                    KeyFactory.keyToString((Key) methodResult));
                        } else if (type.equals("class com.google.appengine.api.datastore.Text")) {
                            json.put(field.getAnnotation(FormatPart.class).key(),
                                    ((Text) methodResult).getValue());
                        } else {
                            json.put(field.getAnnotation(FormatPart.class).key(), methodResult.toString());
                        }
                    }
                } catch (IllegalAccessException e) {
                    logger.warning("IllegalAccessException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (NoSuchMethodException e) {
                    logger.warning("NoSuchMethodException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (SecurityException e) {
                    logger.warning("SecurityException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (IllegalArgumentException e) {
                    logger.warning("IllegalArgumentException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (InvocationTargetException e) {
                    logger.warning("InvocationTargetException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (JSONException e) {
                    logger.warning("JSONException occured: " + e.getMessage());
                    throw new FormatException();
                }
            }
        }
    }

    return json.toString();
}

From source file:com.madrobot.di.wizard.json.JSONDeserializer.java

/**
 * Deserializes the JSON data from the input to the corresponding entity type <br/>
 * If there is an error while parsing, if possible it will try to ignore it, otherwise returns a null value.
 * /*from   w  w  w .ja  va  2 s. c  o m*/
 * @param parser
 *            Parser to read XML from
 * @param objType
 *            Type of the entity to deserialize data to
 * 
 * @return Deserialized object, if successful, null otherwise
 * @see #deserialize(InputStream, Class)
 */
public <T> T deserialize(final Class<T> objType, final JSONObject jsonObject) throws JSONException {

    try {

        Stack<Class<?>> stack = new Stack<Class<?>>();
        stack.push(objType);

        T resultObject = objType.newInstance();

        deserialize(resultObject, jsonObject, stack);

        return resultObject;
    } catch (IllegalAccessException e) {
        Log.e(TAG, e.getMessage());
    } catch (InstantiationException e) {
        Log.e(TAG, e.getMessage());
    }

    return null;
}

From source file:org.fao.fenix.wds.web.rest.faostat.FAOSTAT2NotesRESTService.java

@GET
@Produces(MediaType.TEXT_HTML)/*from w w  w  .j  a  va2 s .c  o  m*/
@Path("/{datasource}/{groupCode}/{lang}")
public Response createCPITable(@PathParam("datasource") final String datasource,
        @PathParam("groupCode") final String groupCode, @PathParam("lang") final String language) {

    // Initiate the stream
    StreamingOutput stream = new StreamingOutput() {

        @Override
        public void write(OutputStream os) throws IOException, WebApplicationException {

            // Initiate utilities
            Writer writer = new BufferedWriter(new OutputStreamWriter(os));

            // create HTML
            DATASOURCE ds = DATASOURCE.valueOf(datasource.toUpperCase());
            DBBean db = new DBBean(ds);

            String in = map.get(groupCode);
            String script = "SELECT H.HTMLText" + language
                    + " FROM Metadata_DomainHTML H WHERE H.DomainCode IN (" + in
                    + ") ORDER BY H.DomainCode ASC ";
            SQLBean sql = new SQLBean(script);

            WrapperConfigurations wc = new WrapperConfigurations();
            wc.setCssName("default");
            List<List<String>> table = null;

            try {

                // Query SQLServer
                table = JDBCConnector.query(db, sql, false);

            } catch (IllegalAccessException e) {
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'createCPITable' thrown an error: " + e.getMessage()));
            } catch (InstantiationException e) {
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'createCPITable' thrown an error: " + e.getMessage()));
            } catch (SQLException e) {
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'createCPITable' thrown an error: " + e.getMessage()));
            } catch (ClassNotFoundException e) {
                WDSExceptionStreamWriter.streamException(os,
                        ("Method 'createCPITable' thrown an error: " + e.getMessage()));
            }

            StringBuilder html = wrapper.wrapAsHTML(table, false, wc);

            // Convert and write the output on the stream
            writer.write(html.toString());
            writer.flush();
        }

    };

    /* Stream result */
    return Response.status(200).entity(stream).build();

}

From source file:org.jenkinsci.plugins.tokenmacro.DataBoundTokenMacro.java

/**
 * Builds up the {@link #setters} map that encapsulates where/how to set the value.
 *//*w w w  .j  a  v a  2 s .c  o m*/
private synchronized void buildMap() {
    if (setters != null)
        return;

    setters = new HashMap<String, Setter>();
    for (final Field f : getClass().getFields()) {
        final Parameter p = f.getAnnotation(Parameter.class);
        if (p != null) {
            setters.put(f.getName(), new Setter() {
                public Class getType() {
                    return f.getType();
                }

                public void set(Object target, Object value) {
                    try {
                        f.set(target, value);
                    } catch (IllegalAccessException e) {
                        throw (IllegalAccessError) new IllegalAccessError(e.getMessage()).initCause(e);
                    }
                }

                public boolean required() {
                    return p.required();
                }
            });
        }
    }

    for (final Method m : getClass().getMethods()) {
        final Parameter p = m.getAnnotation(Parameter.class);
        if (p != null) {
            final Class<?>[] pt = m.getParameterTypes();
            if (pt.length != 1)
                throw new IllegalArgumentException(
                        "Expecting one-arg method for @Parameter but found " + m + " instead");

            String name = m.getName();
            if (name.startsWith("set")) {
                name = Introspector.decapitalize(name.substring(3));
            }

            setters.put(name, new Setter() {
                public Class getType() {
                    return pt[0];
                }

                public void set(Object target, Object value) {
                    try {
                        m.invoke(target, value);
                    } catch (IllegalAccessException e) {
                        throw (IllegalAccessError) new IllegalAccessError(e.getMessage()).initCause(e);
                    } catch (InvocationTargetException e) {
                        throw new Error(e);
                    }
                }

                public boolean required() {
                    return p.required();
                }
            });
        }
    }
}

From source file:de.liedtke.format.JSONFormatter.java

@Override
public <T extends BasicEntity> String format(final T entity, final String... levels) throws FormatException {
    final JSONObject json = new JSONObject();
    boolean allAttributes = (levels == null || levels.length == 0);
    final List<String> levelList;
    if (levels == null || levels.length == 0) {
        levelList = new ArrayList<String>();
    } else {//  www  . java2  s. c  om
        levelList = Arrays.asList(levels);
    }
    if (entity.getClass().isAnnotationPresent(Entity.class)) {
        final Field[] fields = entity.getClass().getDeclaredFields();
        for (final Field field : fields) {
            if (field.isAnnotationPresent(FormatPart.class)
                    && (allAttributes || levelList.contains(field.getAnnotation(FormatPart.class).level()))) {
                try {
                    final Method method = entity.getClass()
                            .getMethod(this.getGetter(field.getName(), field.getType()), (Class<?>[]) null);
                    final Object methodResult = method.invoke(entity);
                    if (methodResult != null) {
                        final String type = field.getType().toString();
                        if (type.equals("class com.google.appengine.api.datastore.Key")) {
                            json.put(field.getAnnotation(FormatPart.class).key(),
                                    KeyFactory.keyToString((Key) methodResult));
                        } else if (type.equals("class com.google.appengine.api.datastore.Text")) {
                            json.put(field.getAnnotation(FormatPart.class).key(),
                                    ((Text) methodResult).getValue());
                        } else {
                            json.put(field.getAnnotation(FormatPart.class).key(), methodResult.toString());
                        }
                    }
                } catch (IllegalAccessException e) {
                    logger.warning("IllegalAccessException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (NoSuchMethodException e) {
                    logger.warning("NoSuchMethodException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (SecurityException e) {
                    logger.warning("SecurityException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (IllegalArgumentException e) {
                    logger.warning("IllegalArgumentException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (InvocationTargetException e) {
                    logger.warning("InvocationTargetException occured: " + e.getMessage());
                    throw new FormatException();
                } catch (JSONException e) {
                    logger.warning("JSONException occured: " + e.getMessage());
                    throw new FormatException();
                }
            }
        }
    }

    return json.toString();
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private void assignValue(Object targetObj, String cellReference, String value) {
    if (null == targetObj || StringUtils.isEmpty(cellReference) || StringUtils.isEmpty(value)) {
        return;//  ww  w.  j av  a  2  s .co  m
    }

    try {
        String propertyName = this.cellMapping.get(cellReference);
        if (null == propertyName) {
            LOG.error("Cell mapping doesn't exists!");
        } else {
            PropertyUtils.setSimpleProperty(targetObj, propertyName, value);
        }
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (InvocationTargetException ite) {
        LOG.error(ite.getMessage());
    } catch (NoSuchMethodException nsme) {
        LOG.error(nsme.getMessage());
    }
}

From source file:org.tynamo.descriptor.PropertyDescriptorTest.java

@Test
public void testCloneWidthExtensions2() throws Exception {
    String testExtension = "testExtension";
    DescriptorExtension descriptorExtension = new DescriptorExtension() {
        private final Logger logger = LoggerFactory.getLogger(DescriptorExtension.class);

        private String name;

        private Class propertyType;

        private Class beanType;

        private TynamoPropertyDescriptor propertyDescriptor = null;

        private boolean hidden = true;

        private boolean searchable = true;

        @Override/*from www  .j  a v a  2s  . c om*/
        public Object clone() {
            return new Object();
        }

        public void copyFrom(Descriptor descriptor) {

            try {
                BeanUtils.copyProperties(this, (ObjectReferenceDescriptor) descriptor);
            } catch (IllegalAccessException e) {
                logger.error(e.getMessage());
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                logger.error(e.getMessage());
                e.printStackTrace();
            } catch (Exception e) {
                logger.error(e.toString());
                e.printStackTrace();
            }
        }

        /**
         * Interface Implementation
         */

        public String findAddExpression() {
            return getExpression("");
        }

        public String findRemoveExpression() {
            return getExpression("");
        }

        public String getExpression(String method) {
            return getName();
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public Class getBeanType() {
            return beanType;
        }

        public void setBeanType(Class beanType) {
            this.beanType = beanType;
        }

        public Class getPropertyType() {
            return propertyType;
        }

        public void setPropertyType(Class propertyType) {
            this.propertyType = propertyType;
        }

        public boolean isSearchable() {
            return searchable;
        }

        public void setSearchable(boolean searchable) {
            this.searchable = searchable;
        }

        public boolean isHidden() {
            return hidden;
        }

        public void setHidden(boolean hidden) {
            this.hidden = hidden;
        }

        public TynamoPropertyDescriptor getPropertyDescriptor() {
            return propertyDescriptor;
        }

        public void setPropertyDescriptor(TynamoPropertyDescriptor propertyDescriptor) {
            this.propertyDescriptor = propertyDescriptor;
        }
    };

    TynamoPropertyDescriptorImpl descriptor1 = new TynamoPropertyDescriptorImpl(Foo.class, "foo", String.class);
    descriptor1.addExtension(testExtension, descriptorExtension);

    TynamoPropertyDescriptorImpl descriptor2 = (TynamoPropertyDescriptorImpl) descriptor1.clone();

    assertTrue(descriptor2.supportsExtension(testExtension));
    assertEquals(descriptorExtension, descriptor2.getExtension(testExtension));
}

From source file:com.myjeeva.poi.ExcelWorkSheetHandler.java

private String getPropertyValue(Object targetObj, String propertyName) {
    String value = "";
    if (null == targetObj || StringUtils.isBlank(propertyName)) {
        LOG.error("targetObj or propertyName is null, both require to retrieve a value");
        return value;
    }/*from w ww .  j av a2s  . c  om*/

    try {
        if (PropertyUtils.isReadable(targetObj, propertyName)) {
            Object v = PropertyUtils.getSimpleProperty(targetObj, propertyName);
            if (null != v && StringUtils.isNotBlank(v.toString())) {
                value = v.toString();
            }
        } else {
            LOG.error("Given property (" + propertyName + ") is not readable!");
        }
    } catch (IllegalAccessException iae) {
        LOG.error(iae.getMessage());
    } catch (InvocationTargetException ite) {
        LOG.error(ite.getMessage());
    } catch (NoSuchMethodException nsme) {
        LOG.error(nsme.getMessage());
    }
    return value;
}