Example usage for java.lang ClassNotFoundException getMessage

List of usage examples for java.lang ClassNotFoundException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.gisgraphy.webapp.taglib.ConstantsTag.java

/**
 * Main method that does processing and exposes Constants in specified scope
 * /*from   ww w .  ja  v  a  2s .  c o  m*/
 * @return int
 * @throws JspException
 *                 if processing fails
 */
@Override
public int doStartTag() throws JspException {
    // Using reflection, get the available field names in the class
    Class<?> c = null;
    int toScope = PageContext.PAGE_SCOPE;

    if (scope != null) {
        toScope = getScope(scope);
    }

    try {
        c = Class.forName(clazz);
    } catch (ClassNotFoundException cnf) {
        log.error("ClassNotFound - maybe a typo?");
        throw new JspException(cnf.getMessage());
    }

    try {
        // if var is null, expose all variables
        if (var == null) {
            Field[] fields = c.getDeclaredFields();

            AccessibleObject.setAccessible(fields, true);

            for (Field field : fields) {
                pageContext.setAttribute(field.getName(), field.get(this), toScope);
            }
        } else {
            try {
                Object value = c.getField(var).get(this);
                pageContext.setAttribute(c.getField(var).getName(), value, toScope);
            } catch (NoSuchFieldException nsf) {
                log.error(nsf.getMessage());
                throw new JspException(nsf);
            }
        }
    } catch (IllegalAccessException iae) {
        log.error("Illegal Access Exception - maybe a classloader issue?");
        throw new JspException(iae);
    }

    // Continue processing this page
    return (SKIP_BODY);
}

From source file:com.microsoft.azure.keyvault.extensions.test.KeyVaultKeyResolverBCProviderTest.java

@Before
public void setUp() throws Exception {
    try {//from  w w  w .ja  v  a2  s.  co  m
        _provider = (Provider) Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider")
                .newInstance();
    } catch (ClassNotFoundException ex) {
        throw new RuntimeException(ex.getMessage());
    } catch (IllegalAccessException ex) {
        throw new RuntimeException(ex.getMessage());
    } catch (InstantiationException ex) {
        throw new RuntimeException(ex.getMessage());
    }
}

From source file:com.thinkbiganalytics.metadata.modeshape.support.JcrPropertyUtil.java

private static <T> T readJsonValue(String name, Class<T> type, String json) {
    try {//  ww w . j  a  v  a  2  s  . c  o  m
        return reader.forType(type).readValue(json);
    } catch (IOException e) {
        if (ExceptionUtils.getRootCause(e) instanceof ClassNotFoundException) {
            //attempt to find the old class name and replace it with the new one
            ClassNotFoundException classNotFoundException = (ClassNotFoundException) ExceptionUtils
                    .getRootCause(e);
            String msg = classNotFoundException.getMessage();
            msg = StringUtils.remove(msg, "java.lang.ClassNotFound:");
            String oldName = StringUtils.trim(msg);
            try {
                Class newName = ClassNameChangeRegistry.findClass(oldName);
                String newNameString = newName.getName();
                if (StringUtils.contains(json, oldName)) {
                    //replace and try again
                    json = StringUtils.replace(json, oldName, newNameString);
                    return readJsonValue(name, type, json);
                }
            } catch (ClassNotFoundException c) {

            }

        }
        throw new MetadataRepositoryException("Failed to deserialize JSON property: " + name, e);
    }
}

From source file:eu.optimis.ip.gui.client.resources.Accounting.java

/**
 * If DB server is not running, runs it.
 * If Database tables are not created, it creates them.
 * Also prepares all the SQL statements.
 *//* w  w w  . j  a v a2s.c  om*/
private void start() {
    serverThread.startServer();
    try {
        Class.forName(dbconfig.getString("driver"));
    } catch (ClassNotFoundException ex) {
        ex.printStackTrace();
        throw new RuntimeException(ex.getMessage(), ex);
    }

    // If SA user has no password (because the DB does not exist), it creates the SA user and a read-only-user
    try {
        Connection saConnection = DriverManager.getConnection(dbconfig.getString("url"),
                dbconfig.getString("sa.username"), "");
        PreparedStatement ps = saConnection
                .prepareStatement("SET PASSWORD '" + dbconfig.getProperty("sa.password") + "';");
        ps.executeUpdate();
        ps.close();
        saConnection.close();
    } catch (SQLInvalidAuthorizationSpecException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.INFO,
                "SA user has already a password. Neither new users are creater nor permissions are re-assigned");
    } catch (SQLException ex) {
        ex.printStackTrace();
    }

    try {
        connection = DriverManager.getConnection(dbconfig.getString("url"), dbconfig.getString("sa.username"),
                dbconfig.getString("sa.password"));
        createDB();

    } catch (SQLException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.SEVERE, null, ex);
    }

    // Drops already defined RO (read-only) user, and creates a new with the password specified in scheduler.properties
    try {
        PreparedStatement ps = connection
                .prepareStatement("DROP USER " + dbconfig.getProperty("ro.username") + ";");
        ps.executeUpdate();
        ps.close();
    } catch (SQLInvalidAuthorizationSpecException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.INFO,
                "Don't dropping read-only user because does not exist. Creating...");
    } catch (SQLException ex) {
        Logger.getLogger(Accounting.class.getName()).log(Level.SEVERE, ex.getMessage(), ex);
    }
}

From source file:no.uka.findmyapp.android.rest.client.RestProcessor.java

/**
 * Execute and parse.//  w w w  . ja  v a 2  s . c  o m
 *
 * @param serviceModel the service model
 * @return the serializable
 * @throws HTTPStatusException 
 * @throws Exception 
 */
private Serializable executeAndParse(ServiceModel serviceModel, String userToken) throws HTTPStatusException {
    mRestMethod.setUri(createURI(serviceModel, userToken));
    String response = httpRequest(serviceModel);

    Log.v(debug, "executeAndParse: Response " + response);
    Serializable s = null;

    if (serviceModel.getReturnType() != null) {
        String returnType = serviceModel.getReturnType();
        if (returnType.indexOf(".") == -1) {
            returnType = sModelPackage + returnType;
        }
        //no.uka.findmyapp.android.rest.datamodels.models
        Class theClass;
        try {
            theClass = Class.forName(returnType);
        } catch (ClassNotFoundException e) {
            Log.e(debug, e.getMessage() + " Returning data in String format!");
            return response;
        }
        new TypeToken<Object>() {
        };
        Type t1 = TypeToken.get(theClass).getType();
        ;
        try {
            s = parseFromJson(response, t1);
        } catch (JSONException e) {
            Log.e(debug, e.getMessage() + " Returning data in String format!");
            return response;
        }
    } else {
        return response;
    }

    return s;
}

From source file:nonjsp.application.XmlXulRuleSet.java

public Object createObject(Attributes attributes) {
    Class cClass = null;/*from w w  w  .j  ava  2  s .c  o  m*/
    UIComponent c = null;

    // Identify the name of the class to instantiate
    String className = attributes.getValue("class");
    String id = attributes.getValue("id");
    String value = attributes.getValue("value");

    // Instantiate the new object and return it
    try {
        cClass = Util.loadClass(className);
        c = (UIComponent) cClass.newInstance();
    } catch (ClassNotFoundException cnf) {
        throw new RuntimeException("Class Not Found:" + cnf.getMessage());
    } catch (InstantiationException ie) {
        throw new RuntimeException("Class Instantiation Exception:" + ie.getMessage());
    } catch (IllegalAccessException ia) {
        throw new RuntimeException("Illegal Access Exception:" + ia.getMessage());
    }

    c.setId(id);
    if (c instanceof UIOutput) {
        ((UIOutput) c).setValue(value);
    }
    return c;
}

From source file:gaffer.store.schema.TypeDefinition.java

public void setSerialiserClass(final String clazz) {
    if (null == clazz) {
        this.serialiser = DEFAULT_SERIALISER;
    } else {/*from   w  w w  .j  a  v  a  2 s. com*/
        final Class<? extends Serialisation> serialiserClass;
        try {
            serialiserClass = Class.forName(clazz).asSubclass(Serialisation.class);
        } catch (ClassNotFoundException e) {
            throw new SchemaException(e.getMessage(), e);
        }
        try {
            this.serialiser = serialiserClass.newInstance();
        } catch (IllegalAccessException | IllegalArgumentException | SecurityException
                | InstantiationException e) {
            throw new SchemaException(e.getMessage(), e);
        }
    }
}

From source file:com.sixt.service.framework.AbstractService.java

@SuppressWarnings("unchecked")
public void registerMethodHandlers(List<String> rpcHandlers) {
    for (String className : rpcHandlers) {
        try {//from   ww w.  j a  v  a 2s  . c om
            Class clazz = Class.forName(className);

            if ((clazz != ServiceMethodHandler.class) && ServiceMethodHandler.class.isAssignableFrom(clazz)) {
                registerMethodHandlerFor(((RpcHandler) clazz.getAnnotation(RpcHandler.class)).value(), clazz);
            } else {
                throw new IllegalArgumentException(String.format(
                        "RpcHandler annotation applied to class %s that does not implement ServiceMethodHandler",
                        clazz.getName()));
            }
        } catch (ClassNotFoundException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

From source file:cn.vlabs.duckling.vwb.service.auth.policy.AuthorizationFileParser.java

private Permission parsePermission() throws AuthorizationSyntaxParseException, IOException {
    String perm = ats.nextUsefulToken();
    if (perm == null) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", permission syntax error");
    } else if (!perm.toLowerCase().equals("permission")) {
        String rightBracket = perm;
        if (rightBracket == null || !rightBracket.contains("}")) {
            throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", no right bracket");
        } else if (!rightBracket.contains(";")) {
            throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", no \";\" sign finded");
        }//from   w w w. ja v  a2  s.  com
        return null;
    }
    String className = ats.nextUsefulToken();
    String isEnd = ats.nextUsefulToken();
    if (className == null) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", className is null");
    }
    if (isEnd == null) {
        throw new AuthorizationSyntaxParseException("Line " + ats.getLineNum() + ", no operate object defined");
    } else {
        try {
            if (!isEnd.contains(";")) {
                String oper = isEnd;
                oper = oper.replace("\"", "");
                oper = oper.replace(",", "");
                isEnd = ats.nextUsefulToken();
                if (isEnd != null && isEnd.contains(";")) {
                    String actions = isEnd.replace(";", "");
                    actions = actions.replace("\"", "");
                    Class<?> clazz = Class.forName(className, false, VWBPermission.class.getClassLoader());
                    return ((Permission) clazz
                            .getDeclaredConstructor(new Class[] { String.class, String.class })
                            .newInstance(oper, actions));
                } else {
                    throw new AuthorizationSyntaxParseException(
                            "Line " + ats.getLineNum() + ", no \";\" sign finded");
                }
            } else {
                String oper = isEnd.replace(";", "");
                oper = oper.replace("\"", "");
                Class<?> clazz = Class.forName(className);
                return ((Permission) clazz.getDeclaredConstructor(String.class).newInstance(oper));
            }
        } catch (ClassNotFoundException e) {
            throw new AuthorizationSyntaxParseException(
                    "Line " + ats.getLineNum() + ", ClassNotFoundException, " + e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            throw new AuthorizationSyntaxParseException(
                    "Line " + ats.getLineNum() + ", Exception happens, " + e.getMessage());
        }
    }
}

From source file:org.deegree.tools.crs.EPSGDBSynchronizer.java

protected void connectToEPSGdatabase() {
    try {//from   ww  w.jav a 2  s  .c o  m
        Class.forName(JDBC_DRIVER);
        EPSGdbConn = DriverManager.getConnection(epsgPath);
    } catch (ClassNotFoundException e) {
        LOG.error(e.getMessage(), e);
    } catch (SQLException e) {
        LOG.error(e.getMessage(), e);
    }
}