Example usage for java.lang Exception getClass

List of usage examples for java.lang Exception getClass

Introduction

In this page you can find the example usage for java.lang Exception getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.aurel.track.util.emailHandling.MailReader.java

public synchronized static String verifyMailSetting(String protocol, String server, int securityConnection,
        int port, String user, String password) {
    LOGGER.debug(" Verify mail setting: " + protocol + ":" + server + ":" + port + "," + user + "...");
    try {/*w  w w.  j a  v a  2s .c om*/
        // create session instance
        Properties props = System.getProperties();
        updateSecurityProps(protocol, server, securityConnection, props);
        Session session = Session.getDefaultInstance(props, null);

        // instantiate POP3-store and connect to server
        store = session.getStore(protocol);
        store.connect(server, port, user, password);
        store.close();
    } catch (Exception ex) {
        LOGGER.warn("Incoming e-mail settings don't work: " + protocol + ":" + server + ":" + port + ", user "
                + user + " - " + ex.getMessage());
        if (LOGGER.isDebugEnabled()) {
            LOGGER.error(ExceptionUtils.getStackTrace(ex));
        }
        return ex.getLocalizedMessage() == null ? ex.getClass().getName() : ex.getLocalizedMessage();
    }
    LOGGER.debug("Mail setting: " + protocol + ":" + server + ":" + port + "," + user + " valid!");
    return null;
}

From source file:com.clustercontrol.plugin.impl.SchedulerPlugin.java

/**
 * <pre>/* w  w w  . j  a v a2 s . c  om*/
 * ??????????<br/>
 * ???????cron?????????<br/>
 * </pre>
 *
 * @param type ???
 * @param name ????
 * @param group ???
 * @param startTime 
 * @param intervalSec [sec]
 * @param rstOnRestart JVM?????true(Misfire?????????????????
 * @param className ?????
 * @param methodName ?????
 * @param argsType ??
 * @param args ??
 * @throws HinemosUnknown
 */
public static void scheduleSimpleJob(SchedulerType type, String name, String group, long startTimeMillis,
        int intervalSec, boolean rstOnRestart, String className, String methodName,
        Class<? extends Serializable>[] argsType, Serializable[] args) throws HinemosUnknown {

    log.debug("scheduleSimpleJob() name=" + name + ", group=" + group + ", startTime=" + startTimeMillis
            + ", rstOnRestart=" + rstOnRestart + ", className=" + className + ", methodName=" + methodName);

    // ??
    JobDetail job = JobBuilder.newJob(ReflectionInvokerJob.class).withIdentity(name, group).storeDurably(true) // ??????
            //            .requestRecovery(false)   // ??????????(JVM?????????)
            .usingJobData(ReflectionInvokerJob.KEY_CLASS_NAME, className) // ???????
            .usingJobData(ReflectionInvokerJob.KEY_METHOD_NAME, methodName) // ?????
            .usingJobData(ReflectionInvokerJob.KEY_RESET_ON_RESTART, rstOnRestart) // ??trigger()???????
            .build();

    // [WARNING] job.getJobDataMap()??????"trigger".getJobDataMap()??????????
    // Quartz (JBoss EAP 5.1 Bundle) Bug??java.lang.StackOverflowError?????

    // ???0-length????)
    if (args == null) {
        throw new NullPointerException("args must not be null. if not args, set 0-length list.");
    }
    if (argsType == null) {
        throw new NullPointerException("argsType must not be null. if not args, set 0-length list.");
    }
    if (args.length != argsType.length) {
        throw new IndexOutOfBoundsException("list's length is not same between args and argsType.");
    }
    if (args.length > 15) {
        throw new IndexOutOfBoundsException("list's length is out of bounds.");
    }
    job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS_TYPE, argsType);
    job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS, args);

    // ??trigger?
    SimpleTriggerBuilder triggerBuilder = SimpleTriggerBuilder.newTrigger().withIdentity(name, group);
    if (rstOnRestart) {
        log.debug("scheduleSimpleJob() name=" + name + ", misfireHandlingInstruction=DoNothing");
        triggerBuilder.setPeriod(intervalSec * 1000).withMisfireHandlingInstructionDoNothing();
    } else {
        log.debug("scheduleSimpleJob() name=" + name + ", misfireHandlingInstruction=IgnoreMisfires");
        triggerBuilder.setPeriod(intervalSec * 1000).withMisfireHandlingInstructionIgnoreMisfires();
    }

    Trigger trigger = triggerBuilder.startAt(startTimeMillis)
            //            .withSchedule(scheduleBuilder)
            .build();

    if (type == SchedulerPlugin.SchedulerType.DBMS) {
        // DBMS??????DB??????
        // ????/?1????????
        try {
            ModifyDbmsScheduler dbms = new ModifyDbmsScheduler();
            if (_scheduler.get(type).checkExists(new JobKey(name, group))) {
                // ?????DB????
                log.trace("scheduleSimpleJob() : modifyDbmsScheduler() call.");
                dbms.modifyDbmsScheduler(job, trigger);

                synchronized (_schedulerLock) {
                    // rescheduleJob()??Trigger??????????RAM??????
                    _scheduler.get(type).deleteJob(new JobKey(name, group));
                    log.debug("scheduleJob() name=" + name + ", group=" + group);
                    _scheduler.get(type).scheduleJob(job, trigger);
                }
            } else {
                // ????DB??
                log.trace("scheduleSimpleJob() : addDbmsScheduler() call.");
                dbms.addDbmsScheduler(job, trigger);

                synchronized (_schedulerLock) {
                    log.debug("scheduleJob() name=" + name + ", group=" + group);
                    _scheduler.get(type).scheduleJob(job, trigger);
                }
            }
        } catch (Exception e) {
            log.error("scheduleSimpleJob() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            throw new HinemosUnknown("failed scheduling DBMS job. (name = " + name + ", group = " + group + ")",
                    e);
        }
    } else {
        // RAM?????????
        deleteJob(type, name, group);
        // ?
        try {
            synchronized (_schedulerLock) {
                log.debug("scheduleJob() name=" + name + ", group=" + group);
                _scheduler.get(type).scheduleJob(job, trigger);
            }
        } catch (SchedulerException e) {
            throw new HinemosUnknown("failed scheduling job. (name = " + name + ", group = " + group + ")", e);
        }
    }
}

From source file:com.clustercontrol.plugin.impl.SchedulerPlugin.java

public static void scheduleCronJob(SchedulerType type, String name, String group, long startTime,
        String cronExpression, boolean rstOnRestart, String className, String methodName,
        Class<? extends Serializable>[] argsType, Serializable[] args) throws HinemosUnknown {

    log.debug("scheduleCronJob() name=" + name + ", group=" + group + ", startTime=" + startTime
            + ", cronExpression=" + cronExpression + ", rstOnRestart=" + rstOnRestart + ", className="
            + className + ", methodName=" + methodName);

    // ??/*ww  w .ja v  a  2s . c  om*/
    JobDetail job = JobBuilder.newJob(ReflectionInvokerJob.class).withIdentity(name, group).storeDurably(true) // ??????
            //            .requestRecovery(false)   // ??????????(JVM?????????)
            .usingJobData(ReflectionInvokerJob.KEY_CLASS_NAME, className) // ???????
            .usingJobData(ReflectionInvokerJob.KEY_METHOD_NAME, methodName) // ?????
            .usingJobData(ReflectionInvokerJob.KEY_RESET_ON_RESTART, rstOnRestart) // ??trigger()???????
            .build();

    // [WARNING] job.getJobDataMap()??????"trigger".getJobDataMap()??????????
    // Quartz (JBoss EAP 5.1 Bundle) Bug??java.lang.StackOverflowError?????

    // ???0-length????)
    if (args == null) {
        throw new NullPointerException("args must not be null. if not args, set 0-length list.");
    }
    if (argsType == null) {
        throw new NullPointerException("argsType must not be null. if not args, set 0-length list.");
    }
    if (args.length != argsType.length) {
        throw new IndexOutOfBoundsException("list's length is not same between args and argsType.");
    }
    if (args.length > 15) {
        throw new IndexOutOfBoundsException("list's length is out of bounds.");
    }

    job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS_TYPE, argsType);
    job.getJobDataMap().put(ReflectionInvokerJob.KEY_ARGS, args);

    // ??trigger?
    CronTriggerBuilder triggerBuilder = CronTriggerBuilder.newTrigger();
    if (rstOnRestart) {
        log.debug("scheduleCronJob() name=" + name + ", misfireHandlingInstruction=DoNothing");
        triggerBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionDoNothing();
    } else {
        log.debug("scheduleCronJob() name=" + name + ", misfireHandlingInstruction=IgnoreMisfires");
        triggerBuilder.cronSchedule(cronExpression).withMisfireHandlingInstructionIgnoreMisfires();
    }

    Trigger trigger = triggerBuilder.withIdentity(name, group).startAt(startTime)
            //            .withSchedule(schedulerBuilder)
            .build();

    if (type == SchedulerPlugin.SchedulerType.DBMS) {
        // DBMS??????DB??????
        // ????/?1???????
        try {
            ModifyDbmsScheduler dbms = new ModifyDbmsScheduler();
            if (_scheduler.get(type).checkExists(new JobKey(name, group))) {
                // ?????DB????
                log.trace("scheduleCronJob() : modifyDbmsScheduler() call.");
                dbms.modifyDbmsScheduler(job, trigger);

                synchronized (_schedulerLock) {
                    // rescheduleJob()??Trigger??????????RAM??????
                    _scheduler.get(type).deleteJob(new JobKey(name, group));
                    log.debug("scheduleJob() name=" + name + ", group=" + group);
                    _scheduler.get(type).scheduleJob(job, trigger);
                }
            } else {
                // ????DB??
                log.trace("scheduleCronJob() : addDbmsScheduler() call.");
                dbms.addDbmsScheduler(job, trigger);

                synchronized (_schedulerLock) {
                    log.debug("scheduleJob() name=" + name + ", group=" + group);
                    _scheduler.get(type).scheduleJob(job, trigger);
                }
            }
        } catch (Exception e) {
            log.error("scheduleCronJob() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
            throw new HinemosUnknown("failed scheduling DBMS job. (name = " + name + ", group = " + group + ")",
                    e);
        }
    } else {
        // RAM?????????
        deleteJob(type, name, group);

        // ?
        try {
            synchronized (_schedulerLock) {
                log.debug("scheduleJob() name=" + name + ", group=" + group);
                _scheduler.get(type).scheduleJob(job, trigger);
            }
        } catch (SchedulerException e) {
            throw new HinemosUnknown("failed scheduling job. (name = " + name + ", group = " + group + ")", e);
        }
    }
}

From source file:csns.web.resolver.ExceptionResolver.java

@Override
public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
        Exception exception) {
    if (!exception.getClass().getName().endsWith("AccessDeniedException")) {
        String username = SecurityUtils.isAnonymous() ? "guest" : SecurityUtils.getUser().getUsername();
        logger.error("Exception caused by " + username, exception);
    }//  w w  w  .j  av a2s  .  co m

    return super.resolveException(request, response, handler, exception);
}

From source file:com.boundlessgeo.geoserver.api.exceptions.AppExceptionHandler.java

HttpStatus status(Exception e) {
    ResponseStatus status = e.getClass().getAnnotation(ResponseStatus.class);
    return status != null ? status.value() : HttpStatus.INTERNAL_SERVER_ERROR;
}

From source file:br.com.authentication.business.handler.GlobalRestExceptionHandler.java

@ExceptionHandler(Exception.class)
@ResponseBody/*from   w  w w .  java2 s . c  o m*/
public ResponseEntity<Object> handleException(Exception e) {
    LOGGER.info("handleException {} {}", e.getClass(), e.getMessage());
    return new ResponseEntity<Object>(e.getMessage(), HttpStatus.NOT_FOUND);
}

From source file:org.jasig.cas.web.NoSuchFlowExecutionExceptionResolver.java

public ModelAndView resolveException(final HttpServletRequest request, final HttpServletResponse response,
        final Object handler, final Exception exception) {

    if (!exception.getClass().equals(NoSuchFlowExecutionException.class)) {
        return null;
    }/*from   w  ww . ja  va  2s.com*/

    final String urlToRedirectTo = request.getRequestURI()
            + (request.getQueryString() != null ? "?" + request.getQueryString() : "");

    if (log.isDebugEnabled()) {
        log.debug("Error getting flow information for URL:" + urlToRedirectTo, exception);
    }

    return new ModelAndView(new RedirectView(urlToRedirectTo));
}

From source file:org.jasig.ssp.util.importer.job.listener.RawItemValidateProcessorListener.java

@Override
public void onProcessError(RawItem item, Exception e) {
    if (!e.getClass().equals(TableViolationException.class) && !e.getClass().equals(ViolationException.class)
            || hasTableViolation == false) {
        logger.error(e.getMessage());//from   w  ww. j  av a  2s .c  o m
    }

    if (e.getClass().equals(ViolationException.class)) {
        ViolationException violation = (ViolationException) e;
        String EOL = System.getProperty("line.separator");
        logger.error("error on line:" + violation.getLineNumber() + EOL + e.getMessage());
    }

    if (e.getClass().equals(TableViolationException.class) && hasTableViolation == false) {
        hasTableViolation = true;
        ViolationException violation = (TableViolationException) e;
        String EOL = System.getProperty("line.separator");
        logger.error("error on line:" + violation.getLineNumber() + EOL + e.getMessage());
    }
}

From source file:org.craftercms.social.util.web.RestMappingExceptionResolver.java

@Override
protected String determineViewName(Exception ex, HttpServletRequest request) {
    return ex.getClass().getCanonicalName();
}

From source file:com.asual.summer.core.ErrorController.java

@ExceptionHandler(Exception.class)
public ModelAndView handleException(Exception ex) {
    logger.info("Catching: " + ex.getClass().getSimpleName());
    logger.error(ex.getMessage(), ex);//from  w  w w .  j a v a 2  s . c om
    return error(ex);
}