Example usage for java.lang ClassNotFoundException toString

List of usage examples for java.lang ClassNotFoundException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.ireland.jnetty.dispatch.servlet.ServletConfigImpl.java

/**
 * ?ServletClass?,?javax.servlet.Servlet?
 * //from w  w  w .j a v  a 2s  . co m
 * @param requireClass
 * @throws ServletException
 */
protected void validateClass(boolean requireClass) throws ServletException {

    if (_loadOnStartup >= 0)
        requireClass = true;

    if (_servletClassName == null) {
    } else {
        if (_servletClass == null) {
            try {
                _servletClass = (Class<? extends Servlet>) Class.forName(_servletClassName, false,
                        _webApp.getClassLoader());
            } catch (ClassNotFoundException e) {
                log.debug(e.toString(), e);
            }
        }

        if (_servletClass != null) {
        } else if (requireClass) {
            throw error(_servletClassName
                    + " | is not a known servlet class.  Servlets belong in the classpath, for example WEB-INF/classes.");
        } else {
            String location = _location != null ? _location : "";

            log.warn(location + _servletClassName
                    + " | is not a known servlet.  Servlets belong in the classpath, often in WEB-INF/classes.");
            return;
        }

        if (!Servlet.class.isAssignableFrom(_servletClass)) {
            throw error(_servletClassName
                    + " | must implement javax.servlet.Servlet  All servlets must implement the Servlet interface.");
        }

    }
}

From source file:org.powertac.common.config.Configurator.java

/**
 * Analyzes a class by mapping its configurable properties.
 *///from   w w  w .  j a  v  a2 s.c  o m
private Map<String, ConfigurableProperty> getAnalysis(Class<? extends Object> clazz) {
    HashMap<String, ConfigurableProperty> result = annotationMap.get(clazz);
    if (result == null) {
        result = new HashMap<String, ConfigurableProperty>();
        annotationMap.put(clazz, result);
        // here's where we do the analysis
        log.debug("Analyzing class " + clazz.getName());

        // extract configurable fields
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            ConfigurableValue cv = field.getAnnotation(ConfigurableValue.class);
            if (cv != null) {
                // found an annotated field
                log.debug("ConfigurableValue field " + field.getName());
                String propertyName = cv.name();
                if ("".equals(propertyName)) {
                    // property name not in annotation, use field name
                    propertyName = field.getName();
                }
                result.put(propertyName, new ConfigurableProperty(field, cv));
            }
        }

        // then extract configurable methods
        Method[] methods = clazz.getMethods();
        Method getter = null;
        for (Method method : methods) {
            ConfigurableValue cv = method.getAnnotation(ConfigurableValue.class);
            if (cv != null) {
                // This method is annotated
                log.debug("ConfigurableValue method found on " + method.getName());
                String propertyName = cv.name();
                if ("".equals(propertyName)) {
                    // property name not in annotation, extract from method name
                    propertyName = extractPropertyName(method);
                }
                // locate the getter
                String getterName = cv.getter();
                if ("".equals(getterName)) {
                    // compose getter name from property name
                    StringBuilder sb = new StringBuilder();
                    sb.append("get").append(capitalize(propertyName));
                    getterName = sb.toString();
                    log.debug("getter name " + getterName);
                    try {
                        getter = clazz.getMethod(getterName);
                        if (getter != null) {
                            // check for type compatibility
                            Class<?> valueClass = findNamedClass(cv.valueType());
                            if (!getter.getReturnType().isPrimitive()
                                    && !valueClass.isAssignableFrom(getter.getReturnType())) {
                                log.warn("Type mismatch: cannot use default value ("
                                        + getter.getReturnType().getName() + ") for " + cv.name() + " ("
                                        + valueClass.getName() + ")");
                                getter = null;
                            }
                        }
                    } catch (NoSuchMethodException nsm) {
                        log.error("No getter method " + getterName + " for " + clazz.getName());
                    } catch (ClassNotFoundException e) {
                        log.error("Could not find value class: " + e.toString());
                    }
                }
                result.put(propertyName, new ConfigurableProperty(method, getter, cv));
            }
        }
    }
    return result;
}

From source file:org.nuxeo.ecm.core.storage.sql.jdbc.dialect.DialectOracle.java

private void initArrayReflection() throws StorageException {
    try {/*from  ww  w .  j  av  a 2 s  . c  om*/
        Class<?> arrayDescriptorClass = Class.forName("oracle.sql.ArrayDescriptor");
        arrayDescriptorConstructor = arrayDescriptorClass.getConstructor(String.class, Connection.class);
        Class<?> arrayClass = Class.forName("oracle.sql.ARRAY");
        arrayConstructor = arrayClass.getConstructor(arrayDescriptorClass, Connection.class, Object.class);
        arrayGetLongArrayMethod = arrayClass.getDeclaredMethod("getLongArray");
    } catch (ClassNotFoundException e) {
        // query syntax unit test run without Oracle JDBC driver
        return;
    } catch (Exception e) {
        throw new StorageException(e.toString(), e);
    }
}

From source file:org.hyperic.lather.server.LatherServlet.java

public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    ByteArrayInputStream bIs;/*from  w w  w.  ja  v a2  s.c  o m*/
    DataInputStream dIs;
    LatherXCoder xCoder;
    LatherValue val;
    String[] method, args, argsClass;
    LatherContext ctx;
    byte[] decodedArgs;
    Class<?> valClass;

    ctx = new LatherContext();
    ctx.setCallerIP(req.getRemoteAddr());
    ctx.setRequestTime(System.currentTimeMillis());

    xCoder = new LatherXCoder();

    method = req.getParameterValues("method");
    args = req.getParameterValues("args");
    argsClass = req.getParameterValues("argsClass");

    if (method == null || args == null || argsClass == null || method.length != 1 || args.length != 1
            || argsClass.length != 1) {
        String msg = "Invalid Lather request made from " + req.getRemoteAddr();
        log.error(msg);
        resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, msg);
        return;
    }

    if (log.isDebugEnabled()) {
        log.debug("Invoking method '" + method[0] + "' for connID=" + req.getAttribute(PROP_CONNID));
    }

    try {
        valClass = Class.forName(argsClass[0], true, xCoder.getClass().getClassLoader());
    } catch (ClassNotFoundException exc) {
        String msg = "Lather request from " + req.getRemoteAddr() + " required an argument object of class '"
                + argsClass[0] + "' which could not be found";
        log.error(msg);
        resp.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, msg);
        return;
    }

    decodedArgs = Base64.decode(args[0]);
    bIs = new ByteArrayInputStream(decodedArgs);
    dIs = new DataInputStream(bIs);

    try {
        val = xCoder.decode(dIs, valClass);
    } catch (LatherRemoteException exc) {
        LatherServlet.issueErrorResponse(resp, exc.toString());
        return;
    }

    this.doServiceCall(req, resp, method[0], val, xCoder, ctx);
}

From source file:com.chinamobile.bcbsp.util.BSPJob.java

/**
 * If the job ready, submit the job, and start monitor.
 * @param verbose//  w w w . jav  a 2 s  .  c  om
 *        User has set true if the job ready.
 * @return job state.
 */
public boolean waitForCompletion(boolean verbose) {
    try {
        /** To set the params for aggregators. */
        completeAggregatorRegister();
        if (state == JobState.DEFINE) {
            submit();
        }
        if (verbose) {
            jobClient.monitorAndPrintJob(this, info);
        } else {
            info.waitForCompletion();
        }
        return isSuccessful();
    } catch (ClassNotFoundException lnfE) {
        LOG.error("Exception has been catched in BSPJob--waitForCompletion !", lnfE);
        Fault f = new Fault(Fault.Type.DISK, Fault.Level.WARNING, "null", lnfE.toString());
        jobClient.getJobSubmitClient().recordFault(f);
        jobClient.getJobSubmitClient().recovery(new BSPJobID("before have an BSPJobId !", -1));
        return false;
    } catch (InterruptedException iE) {
        LOG.error("Exception has been catched in BSPJob--waitForCompletion !", iE);
        Fault f = new Fault(Fault.Type.SYSTEMSERVICE, Fault.Level.INDETERMINATE, "null", iE.toString());
        jobClient.getJobSubmitClient().recordFault(f);
        jobClient.getJobSubmitClient().recovery(new BSPJobID("before have an BSPJobId !", -1));
        return false;
    } catch (IOException ioE) {
        LOG.error("Exception has been catched in BSPJob--waitForCompletion !", ioE);
        Fault f = new Fault(Fault.Type.SYSTEMSERVICE, Fault.Level.INDETERMINATE, "null", ioE.toString());
        jobClient.getJobSubmitClient().recordFault(f);
        jobClient.getJobSubmitClient().recovery(new BSPJobID("before have an BSPJobId !", -1));
        return false;
    }
}

From source file:com.chinamobile.bcbsp.client.BSPJobClient.java

/**
 * Submit a new job to run.//from   ww  w . j  a v a 2s  .co m
 * @param job BSPJob
 * @return Review comments: (1)The content of submitJobDir is decided by the
 *         client. I think it is dangerous because two different clients maybe
 *         generate the same submitJobDir. Review time: 2011-11-30; Reviewer:
 *         Hongxu Zhang. Fix log: (1)In order to avoid the conflict, I use the
 *         jobId to generate the submitJobDir. Because the jobId is unique so
 *         this problem can be solved. Fix time: 2011-12-04; Programmer:
 *         Zhigang Wang. Review comments: (2)There, the client must submit
 *         relative information about the job. There maybe some exceptions
 *         during this process. When exceptions occur, this job should not be
 *         executed and the relative submitJobDir must be cleanup. Review
 *         time: 2011-12-04; Reviewer: Hongxu Zhang. Fix log: (2)The process
 *         of submiting files has been surrounded by try-catch. The
 *         submitJobDir will be cleanup in the catch process. Fix time:
 *         2011-12-04; Programmer: Zhigang Wang.
 */
public RunningJob submitJobInternal(BSPJob job) {
    BSPJobID jobId = null;
    Path submitJobDir = null;
    try {
        jobId = jobSubmitClient.getNewJobId();
        submitJobDir = new Path(getSystemDir(), "submit_" + jobId.toString());
        Path submitJarFile = null;
        LOG.info("debug: job type is " + job.getJobType());
        if (Constants.USER_BC_BSP_JOB_TYPE_C.equals(job.getJobType())) {
            submitJarFile = new Path(submitJobDir, "jobC");
            LOG.info("debug:" + submitJarFile.toString());
        } else {
            LOG.info("debug: before  submitJarFile = new " + "Path(submitJobDir,job.jar);");
            submitJarFile = new Path(submitJobDir, "job.jar");
            LOG.info("debug:" + submitJarFile.toString());
        }
        Path submitJobFile = new Path(submitJobDir, "job.xml");
        Path submitSplitFile = new Path(submitJobDir, "job.split");
        // set this user's id in job configuration, so later job files can
        // be accessed using this user's id
        UnixUserGroupInformation ugi = getUGI(job.getConf());
        // Create a number of filenames in the BSPController's fs namespace
        FileSystem files = getFs();
        files.delete(submitJobDir, true);
        submitJobDir = files.makeQualified(submitJobDir);
        submitJobDir = new Path(submitJobDir.toUri().getPath());
        BSPFsPermission bspSysPerms = new BSPFspermissionImpl(2);
        FileSystem.mkdirs(files, submitJobDir, bspSysPerms.getFp());
        files.mkdirs(submitJobDir);
        short replication = (short) job.getInt("bsp.submit.replication", 10);
        String originalJarPath = null;
        LOG.info("debug: job type is " + job.getJobType());
        if (Constants.USER_BC_BSP_JOB_TYPE_C.equals(job.getJobType())) {
            LOG.info("debug: originalJarPath = job.getJobExe();" + job.getJobExe());
            originalJarPath = job.getJobExe();
            LOG.info("debug:" + submitJarFile.toString());
            job.setJobExe(submitJarFile.toString());
        } else {
            LOG.info("debug: jar");
            originalJarPath = job.getJar();
            job.setJar(submitJarFile.toString());
        }
        if (originalJarPath != null) {
            // copy jar to BSPController's fs
            // use jar name if job is not named.
            if ("".equals(job.getJobName())) {
                job.setJobName(new Path(originalJarPath).getName());
            }
            // job.setJar(submitJarFile.toString());
            fs.copyFromLocalFile(new Path(originalJarPath), submitJarFile);
            fs.setReplication(submitJarFile, replication);
            fs.setPermission(submitJarFile, new BSPFspermissionImpl(0).getFp());
        } else {
            LOG.warn("No job jar file set.  User classes may not be found. "
                    + "See BSPJob#setJar(String) or check Your jar file.");
        }
        // Set the user's name and working directory
        job.setUser(ugi.getUserName());
        if (ugi.getGroupNames().length > 0) {
            job.set("group.name", ugi.getGroupNames()[0]);
        }
        if (new BSPHdfsImpl().getWorkingDirectory() == null) {
            job.setWorkingDirectory(fs.getWorkingDirectory());
        }
        int maxClusterStaffs = jobSubmitClient.getClusterStatus(false).getMaxClusterStaffs();
        if (job.getNumPartition() == 0) {
            job.setNumPartition(maxClusterStaffs);
        }
        if (job.getNumPartition() > maxClusterStaffs) {
            job.setNumPartition(maxClusterStaffs);
        }
        job.setNumBspStaff(job.getNumPartition());
        int splitNum = 0;
        splitNum = writeSplits(job, submitSplitFile);
        if (splitNum > job.getNumPartition() && splitNum <= maxClusterStaffs) {
            job.setNumPartition(splitNum);
            job.setNumBspStaff(job.getNumPartition());
        }
        if (splitNum > maxClusterStaffs) {
            LOG.error("Sorry, the number of files is more than maxClusterStaffs:" + maxClusterStaffs);
            throw new IOException("Could not launch job");
        }
        job.set(Constants.USER_BC_BSP_JOB_SPLIT_FILE, submitSplitFile.toString());
        LOG.info("[Max Staff Number] " + maxClusterStaffs);
        LOG.info("The number of splits for the job is: " + splitNum);
        LOG.info("The number of staffs for the job is: " + job.getNumBspStaff());
        BSPFSDataOutputStream bspout = new BSPFSDataOutputStreamImpl(fs, submitJobFile,
                new BSPFspermissionImpl(0).getFp());
        try {
            job.writeXml(bspout.getOut());
        } finally {
            bspout.close();
        }
        // Now, actually submit the job (using the submit name)
        JobStatus status = jobSubmitClient.submitJob(jobId, submitJobFile.toString());
        if (status != null) {
            return new NetworkedJob(status);
        } else {
            throw new IOException("Could not launch job");
        }
    } catch (FileNotFoundException fnfE) {
        LOG.error("Exception has been catched in BSPJobClient--submitJobInternal !", fnfE);
        Fault f = new Fault(Fault.Type.SYSTEMSERVICE, Fault.Level.INDETERMINATE, "null", fnfE.toString());
        jobSubmitClient.recordFault(f);
        jobSubmitClient.recovery(jobId);
        try {
            FileSystem files = getFs();
            files.delete(submitJobDir, true);
        } catch (IOException e) {
            //LOG.error("Failed to cleanup the submitJobDir:" + submitJobDir);
            throw new RuntimeException("Failed to cleanup the submitJobDir", e);
        }
        return null;
    } catch (ClassNotFoundException cnfE) {
        LOG.error("Exception has been catched in BSPJobClient--submitJobInternal !", cnfE);
        Fault f = new Fault(Fault.Type.SYSTEMSERVICE, Fault.Level.WARNING, "null", cnfE.toString());
        jobSubmitClient.recordFault(f);
        jobSubmitClient.recovery(jobId);
        try {
            FileSystem files = getFs();
            files.delete(submitJobDir, true);
        } catch (IOException e) {
            //LOG.error("Failed to cleanup the submitJobDir:" + submitJobDir);
            throw new RuntimeException("Failed to cleanup the submitJobDir", e);
        }
        return null;
    } catch (InterruptedException iE) {
        LOG.error("Exception has been catched in BSPJobClient--submitJobInternal !", iE);
        Fault f = new Fault(Fault.Type.SYSTEMSERVICE, Fault.Level.CRITICAL, "null", iE.toString());
        jobSubmitClient.recordFault(f);
        jobSubmitClient.recovery(jobId);
        try {
            FileSystem files = getFs();
            files.delete(submitJobDir, true);
        } catch (IOException e) {
            //LOG.error("Failed to cleanup the submitJobDir:" + submitJobDir);
            throw new RuntimeException("Failed to cleanup the submitJobDir", e);
        }
        return null;
    } catch (Exception ioE) {
        LOG.error("Exception has been catched in BSPJobClient--submitJobInternal !", ioE);
        Fault f = new Fault(Fault.Type.DISK, Fault.Level.CRITICAL, "null", ioE.toString());
        jobSubmitClient.recordFault(f);
        jobSubmitClient.recovery(jobId);
        try {
            FileSystem files = getFs();
            files.delete(submitJobDir, true);
        } catch (IOException e) {
            //LOG.error("Failed to cleanup the submitJobDir:" + submitJobDir);
            throw new RuntimeException("Failed to cleanup the submitJobDir", e);
        }
        return null;
    }
}

From source file:edu.ku.brc.af.auth.specify.SpecifySecurityMgr.java

@Override
public boolean authenticateDB(final String user, final String pass, final String driverClass, final String url,
        final String dbUserName, final String dbPwd) throws Exception {
    Connection conn = null;/* w ww. j a  v  a2s.c  o  m*/
    Statement stmt = null;
    boolean passwordMatch = false;

    try {
        Class.forName(driverClass);

        conn = DriverManager.getConnection(url, dbUserName, dbPwd);

        String query = "SELECT * FROM specifyuser where name='" + user + "'"; //$NON-NLS-1$ //$NON-NLS-2$
        stmt = conn.createStatement();
        ResultSet result = stmt.executeQuery(query);
        String dbPassword = null;

        while (result.next()) {
            if (!result.isFirst()) {
                throw new LoginException("authenticateDB - Ambiguous user (located more than once): " + user); //$NON-NLS-1$
            }
            dbPassword = result.getString(result.findColumn("Password")); //$NON-NLS-1$

            if (StringUtils.isNotEmpty(dbPassword) && StringUtils.isAlphanumeric(dbPassword)
                    && UIHelper.isAllCaps(dbPassword) && dbPassword.length() > 20) {
                dbPassword = Encryption.decrypt(dbPassword, pass);
            }
            break;
        }

        /*if (dbPassword == null)
        {
        throw new LoginException("authenticateDB - Password for User " + user + " undefined."); //$NON-NLS-1$ //$NON-NLS-2$
        }*/
        if (pass != null && dbPassword != null && pass.equals(dbPassword)) {
            passwordMatch = true;
        }

        // else: passwords do NOT match, user will not be authenticated
    } catch (java.lang.ClassNotFoundException e) {
        e.printStackTrace();
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifySecurityMgr.class, e);
        log.error("authenticateDB - Could not connect to database, driverclass - ClassNotFoundException: "); //$NON-NLS-1$
        log.error(e.getMessage());
        throw new LoginException("authenticateDB -  Database driver class not found: " + driverClass); //$NON-NLS-1$
    } catch (SQLException ex) {
        if (debug)
            log.error("authenticateDB - SQLException: " + ex.toString()); //$NON-NLS-1$
        if (debug)
            log.error("authenticateDB - " + ex.getMessage()); //$NON-NLS-1$
        throw new LoginException("authenticateDB - SQLException: " + ex.getMessage()); //$NON-NLS-1$
    } finally {
        try {
            if (conn != null)
                conn.close();
            if (stmt != null)
                stmt.close();
        } catch (SQLException e) {
            edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpecifySecurityMgr.class, e);
            log.error("Exception caught: " + e.toString()); //$NON-NLS-1$
            e.printStackTrace();
        }
    }
    return passwordMatch;
}

From source file:com.freedomotic.jfrontend.MainWindow.java

private void setWindowedMode() {
    this.setVisible(false);
    this.dispose();
    this.setUndecorated(false);
    this.setResizable(true);

    try {//  w ww .  jav a 2s  .  c o  m
        this.getContentPane().removeAll();
    } catch (Exception e) {
        LOG.error("Set window mode exception {}", e.getMessage());
    }

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (ClassNotFoundException ex) {
        LOG.error("Cannot find system look&feel\n", ex.toString());
    } catch (InstantiationException ex) {
        LOG.error("Cannot instantiate system look&feel\n", ex.toString());
    } catch (IllegalAccessException ex) {
        LOG.error("Illegal access to system look&feel\n", ex.toString());
    } catch (UnsupportedLookAndFeelException ex) {
        LOG.error("Unsupported system look&feel\n", ex.toString());
    }

    setDefaultLookAndFeelDecorated(true);
    initComponents();
    this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setLayout(new BorderLayout());
    desktopPane = new JDesktopPane();
    lstClients = new PluginJList(this);
    frameClient = new JInternalFrame();
    frameClient.setLayout(new BorderLayout());

    JScrollPane clientScroll = new JScrollPane(lstClients);
    frameClient.add(clientScroll, BorderLayout.CENTER);
    frameClient.setTitle(i18n.msg("loaded_plugins"));
    frameClient.setResizable(true);
    frameClient.setMaximizable(true);
    frameMap = new JInternalFrame();
    setMapTitle("");
    frameMap.setMaximizable(true);
    frameMap.setResizable(true);
    desktopPane.add(frameMap);
    desktopPane.add(frameClient);
    frameClient.moveToFront();
    frameClient.setVisible(auth.isPermitted("plugins:read"));
    desktopPane.moveToFront(this);
    this.getContentPane().add(desktopPane);

    try {
        frameClient.setSelected(true);
    } catch (PropertyVetoException ex) {
        LOG.error(Freedomotic.getStackTraceInfo(ex));
    }

    EnvironmentLogic previousEnv = api.environments().findAll().get(0);

    if (drawer != null) {
        previousEnv = drawer.getCurrEnv();
    }

    initializeRenderer(previousEnv);
    drawer = master.createRenderer(previousEnv);

    if (drawer != null) {
        setDrawer(drawer);
        ResourcesManager.clear();
    } else {
        LOG.error("Unable to create a drawer to render the environment on the desktop frontend");
    }

    this.setTitle("Freedomotic " + Info.getLicense() + " - www.freedomotic.com");
    this.setSize(1100, 700);
    centerFrame(this);
    frameClient.moveToFront();
    frameMap.moveToFront();
    optimizeFramesDimension();
    drawer.repaint();
    lstClients.update();
    frameClient.setVisible(auth.isPermitted("plugins:read"));
    frameMap.setVisible(auth.isPermitted("environments:read"));
    setEditMode(false);
    this.setVisible(true);
    isFullscreen = false;

}

From source file:org.omegat.core.data.RealProject.java

/**
 * Create tokenizer class. Classes are prioritized:
 * <ol><li>Class specified on command line via <code>--ITokenizer</code>
 * and <code>--ITokenizerTarget</code></li>
 * <li>Class specified in project settings</li>
 * <li>{@link DefaultTokenizer}</li>
 * </ol>/*from  w  ww .  j  av  a2 s. com*/
 * 
 * @param cmdLine Tokenizer class specified on command line
 * @return Tokenizer implementation
 */
protected ITokenizer createTokenizer(String cmdLine, Class<?> projectPref) {
    if (!StringUtil.isEmpty(cmdLine)) {
        try {
            return (ITokenizer) this.getClass().getClassLoader().loadClass(cmdLine).newInstance();
        } catch (ClassNotFoundException e) {
            Log.log(e.toString());
        } catch (Throwable e) {
            throw new RuntimeException(e);
        }
    }
    try {
        return (ITokenizer) projectPref.newInstance();
    } catch (Throwable e) {
        Log.log(e);
    }

    return new DefaultTokenizer();
}