Example usage for java.lang InstantiationException getMessage

List of usage examples for java.lang InstantiationException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:edu.duke.cabig.c3pr.web.ajax.UserAjaxFacade.java

@SuppressWarnings("unchecked")
private <T> T buildReduced(T src, List<String> properties) {
    T dst = null;/*from w  ww.  j  av a 2 s.c  om*/
    try {
        // it doesn't seem like this cast should be necessary
        dst = (T) src.getClass().newInstance();
    } catch (InstantiationException e) {
        throw new RuntimeException("Failed to instantiate " + src.getClass().getName(), e);
    } catch (IllegalAccessException e) {
        throw new RuntimeException("Failed to instantiate " + src.getClass().getName(), e);
    }

    BeanWrapper source = new BeanWrapperImpl(src);
    BeanWrapper destination = new BeanWrapperImpl(dst);
    for (String property : properties) {
        // only for nested props
        String[] individualProps = property.split("\\.");
        String temp = "";
        String myTemp = "";
        try {
            for (int i = 0; i < individualProps.length - 1; i++) {
                temp += (i != 0 ? "." : "") + individualProps[i];
                Object o = source.getPropertyValue(temp);
                if (temp.charAt(temp.length() - 1) == ']') {
                    myTemp = temp.substring(0, temp.length() - 3);
                    if (destination.getPropertyValue(myTemp) == null) {
                        destination.setPropertyValue(myTemp,
                                ArrayList.class.newInstance().add(o.getClass().newInstance()));
                    }
                    if (((ArrayList) destination.getPropertyValue(myTemp)).size() == 0) {
                        ((ArrayList) destination.getPropertyValue(myTemp)).add(o.getClass().newInstance());
                    }
                } else {
                    if (destination.getPropertyValue(temp) == null) {
                        destination.setPropertyValue(temp, o.getClass().newInstance());
                    }
                }
            }
        } catch (BeansException e) {
            log.error(e.getMessage());
        } catch (InstantiationException e) {
            log.error(e.getMessage());
        } catch (IllegalAccessException e) {
            log.error(e.getMessage());
        }
        // for single and nested props
        destination.setPropertyValue(property, source.getPropertyValue(property));
    }
    /*for (String property : properties) {
    destination.setPropertyValue(property, source.getPropertyValue(property));
    }*/
    return dst;
}

From source file:com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDocument.java

/**
 * Implementation of the {@link org.w3c.dom.events.DocumentEvent} interface's
 * {@link org.w3c.dom.events.DocumentEvent#createEvent(String)} method. The method creates an
 * uninitialized event of the specified type.
 *
 * @see <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-DocumentEvent">DocumentEvent</a>
 * @param eventType the event type to create
 * @return an event object for the specified type
 * @throws DOMException if the event type is not supported (will have a type of
 *         DOMException.NOT_SUPPORTED_ERR)
 *//*from   w w w  .  ja v  a2  s  .c  o  m*/
@JsxFunction
public Event createEvent(final String eventType) throws DOMException {
    Class<? extends Event> clazz = null;
    clazz = SUPPORTED_DOM2_EVENT_TYPE_MAP.get(eventType);
    if (clazz == null) {
        clazz = SUPPORTED_DOM3_EVENT_TYPE_MAP.get(eventType);
    }
    if (clazz == null) {
        if ("Events".equals(eventType)
                || "KeyEvents".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_KEY_EVENTS)
                || "HashChangeEvent".equals(eventType)
                        && getBrowserVersion().hasFeature(EVENT_TYPE_HASHCHANGEEVENT)
                || "BeforeUnloadEvent".equals(eventType)
                        && getBrowserVersion().hasFeature(EVENT_TYPE_BEFOREUNLOADEVENT)
                || "PointerEvent".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_POINTEREVENT)
                || "PopStateEvent".equals(eventType)
                || "ProgressEvent".equals(eventType) && getBrowserVersion().hasFeature(EVENT_TYPE_PROGRESSEVENT)
                || "XMLHttpRequestProgressEvent".equals(eventType)
                        && getBrowserVersion().hasFeature(EVENT_TYPE_XMLHTTPREQUESTPROGRESSEVENT)) {
            clazz = SUPPORTED_VENDOR_EVENT_TYPE_MAP.get(eventType);
        }
    }
    if (clazz == null) {
        Context.throwAsScriptRuntimeEx(
                new DOMException(DOMException.NOT_SUPPORTED_ERR, "Event Type is not supported: " + eventType));
        return null; // to stop eclipse warning
    }
    try {
        final Event event = clazz.newInstance();
        event.setParentScope(getWindow());
        event.setPrototype(getPrototype(clazz));
        event.eventCreated();
        return event;
    } catch (final InstantiationException e) {
        throw Context.reportRuntimeError("Failed to instantiate event: class ='" + clazz.getName()
                + "' for event type of '" + eventType + "': " + e.getMessage());
    } catch (final IllegalAccessException e) {
        throw Context.reportRuntimeError("Failed to instantiate event: class ='" + clazz.getName()
                + "' for event type of '" + eventType + "': " + e.getMessage());
    }
}

From source file:com.google.gsa.Kerberos.java

/**
 * It invokes the additional non-Kerberos authentication process
 * //from  w  ww .  jav a2 s  . c om
 * @param request HTTP request
 * @param response HTTP response
 * @param nonKrbAuthCookies authentication cookies
 * @param url document url
 * @param creds credentials
 * 
 * @return HTTP error code
 */
private int nonKrbAuthentication(HttpServletRequest request, HttpServletResponse response,
        AuthenticationProcessImpl authenticationProcessCls, Vector<Cookie> nonKrbAuthCookies, String url,
        Credentials creds) {

    int statusCode = HttpServletResponse.SC_UNAUTHORIZED;

    // Instantiate the authentication process class
    try {

        // Instantiate the authorization process class
        authenticationProcessCls = (AuthenticationProcessImpl) Class.forName(authenticationProcessClsName)
                .newInstance();

    } catch (InstantiationException e) {

        // Log error
        logger.error(
                "InstantiationException - Authentication servlet parameter [authenticationProcessImpl] has not been set correctly");

        statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        // Return
        return statusCode;

    } catch (IllegalAccessException e) {

        // Log error
        logger.error(
                "IllegalAccessException - Authentication servlet parameter [authenticationProcessImpl] has not been set correctly");

        statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        // Return
        return statusCode;

    } catch (ClassNotFoundException e) {

        // Log error
        logger.error(
                "ClassNotFoundException - Authentication servlet parameter [authenticationProcessImpl] has not been set correctly");
        logger.error("Cannot find class: " + authenticationProcessClsName);

        statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
        // Return
        return statusCode;

    }

    try {
        logger.debug("Lets authenticate the user");
        // Execute the authentication process in here 
        authenticationProcessCls.setValveConfiguration(valveConf);
        statusCode = authenticationProcessCls.authenticate(request, response, nonKrbAuthCookies, url, creds,
                "root");

        logger.debug("Non Krb Auth - Status code is... " + statusCode);

    } catch (Exception e) {

        // Debug
        logger.error("Authentication process raised exception: " + e.getMessage(), e);

    }

    return statusCode;

}

From source file:de.innovationgate.wgpublisher.WGACore.java

private boolean addEncoderMapping(String name, String theClass, boolean system) {
    try {// w w w .jav a  2s.  com
        name = name.toLowerCase();
        Class formatterClass = getLibraryLoader().loadClass(theClass);
        Object instance = formatterClass.newInstance();
        if (instance instanceof ObjectFormatter) {
            if (system) {
                _systemFormatters.put(name, formatterClass);
            } else {
                if (_systemFormatters.containsKey(name)) {
                    log.warn("Cannot add encoding formatter '" + name
                            + "' because the name is already used by a formatter in WGA configuration");
                    return false;
                }
                _customFormatters.put(name, formatterClass);
            }
            return true;
        } else {
            log.error("Encoding formatter '" + theClass + "' does not implement interface "
                    + ObjectFormatter.class.getName());
        }
    } catch (InstantiationException e) {
        log.error("Error instantiating encoding formatter '" + theClass + "':" + e.getMessage());
    } catch (IllegalAccessException e) {
        log.error("Access error instantiating encoding formatter '" + theClass + "':" + e.getMessage());
    } catch (ClassNotFoundException e) {
        log.error("Encoding formatter class '" + theClass + "' could not be found");
    } catch (NoClassDefFoundError e) {
        log.error("Encoding formatter class '" + theClass + "' could not be loaded", e);
    }

    return false;
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Retrieves the value of the designated column in this
 * <code>CachedRowSetImpl</code> object as an <code>Object</code> in
 * the Java programming language, using the given
 * <code>java.util.Map</code> object to custom map the value if
 * appropriate./*ww w  .  j av  a  2 s .c om*/
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in this rowset
 * @param map a <code>java.util.Map</code> object showing the mapping
 *            from SQL type names to classes in the Java programming
 *            language
 * @return an <code>Object</code> representing the SQL value
 * @throws SQLException if the given column index is out of bounds or
 *            the cursor is not on one of this rowset's rows or its
 *            insert row
 */
public Object getObject(int columnIndex, java.util.Map<String, Class<?>> map) throws SQLException {
    Object value;

    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    setLastValueNull(false);
    value = getCurrentRow().getColumnObject(columnIndex);

    // check for SQL NULL
    if (value == null) {
        setLastValueNull(true);
        return null;
    }
    if (value instanceof Struct) {
        Struct s = (Struct) value;

        // look up the class in the map
        Class<?> c = map.get(s.getSQLTypeName());
        if (c != null) {
            // create new instance of the class
            SQLData obj = null;
            try {
                obj = (SQLData) c.newInstance();
            } catch (java.lang.InstantiationException ex) {
                throw new SQLException(MessageFormat.format(
                        resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), ex.getMessage()));
            } catch (java.lang.IllegalAccessException ex) {
                throw new SQLException(MessageFormat.format(
                        resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), ex.getMessage()));
            }
            // get the attributes from the struct
            Object attribs[] = s.getAttributes(map);
            // create the SQLInput "stream"
            SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
            // read the values...
            obj.readSQL(sqlInput, s.getSQLTypeName());
            return (Object) obj;
        }
    }
    return value;
}

From source file:lasige.steeldb.jdbc.BFTRowSet.java

/**
 * Retrieves the value of the designated column in the current row
 * of this <code>CachedRowSetImpl</code> object as an
 * <code>Object</code> value.
 * <P>//from   www  .  j av a  2 s  . co  m
 * The type of the <code>Object</code> will be the default
 * Java object type corresponding to the column's SQL type,
 * following the mapping for built-in types specified in the JDBC 3.0
 * specification.
 * <P>
 * This method may also be used to read datatabase-specific
 * abstract data types.
 * <P>
 * This implementation of the method <code>getObject</code> extends its
 * behavior so that it gets the attributes of an SQL structured type
 * as an array of <code>Object</code> values.  This method also custom
 * maps SQL user-defined types to classes in the Java programming language.
 * When the specified column contains
 * a structured or distinct value, the behavior of this method is as
 * if it were a call to the method <code>getObject(columnIndex,
 * this.getStatement().getConnection().getTypeMap())</code>.
 *
 * @param columnIndex the first column is <code>1</code>, the second
 *        is <code>2</code>, and so on; must be <code>1</code> or larger
 *        and equal to or less than the number of columns in the rowset
 * @return a <code>java.lang.Object</code> holding the column value;
 *         if the value is SQL <code>NULL</code>, the result is <code>null</code>
 * @throws SQLException if the given column index is out of bounds,
 *            the cursor is not on a valid row, or there is a problem getting
 *            the <code>Class</code> object for a custom mapping
 * @see #getObject(String)
 */
public Object getObject(int columnIndex) throws SQLException {
    Object value;
    java.util.Map<String, Class<?>> map;

    // sanity check.
    checkIndex(columnIndex);
    // make sure the cursor is on a valid row
    checkCursor();

    setLastValueNull(false);
    value = getCurrentRow().getColumnObject(columnIndex);

    // check for SQL NULL
    if (value == null) {
        setLastValueNull(true);
        return null;
    }
    if (value instanceof Struct) {
        Struct s = (Struct) value;
        map = getTypeMap();
        // look up the class in the map
        Class<?> c = map.get(s.getSQLTypeName());
        if (c != null) {
            // create new instance of the class
            SQLData obj = null;
            try {
                obj = (SQLData) c.newInstance();
            } catch (java.lang.InstantiationException ex) {
                throw new SQLException(MessageFormat.format(
                        resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), ex.getMessage()));
            } catch (java.lang.IllegalAccessException ex) {
                throw new SQLException(MessageFormat.format(
                        resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(), ex.getMessage()));
            }
            // get the attributes from the struct
            Object attribs[] = s.getAttributes(map);
            // create the SQLInput "stream"
            SQLInputImpl sqlInput = new SQLInputImpl(attribs, map);
            // read the values...
            obj.readSQL(sqlInput, s.getSQLTypeName());
            return (Object) obj;
        }
    }
    return value;
}