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:eu.emi.security.canl.axis2.test.EchoServiceClientTest.java

@Test
public void testFactory() throws Exception {
    Axis2JettyServer.run();//  www .  ja  v a2 s . c  o m
    CANLAXIS2SocketFactory.clearCurrentProperties();
    StoreUpdateListener listener = new StoreUpdateListener() {
        public void loadingNotification(String location, String type, Severity level, Exception cause) {
            if (level != Severity.NOTIFICATION) {
                System.out.println("Error when creating or using SSL socket. Type " + type + " level: " + level
                        + " cause: " + cause.getClass() + ":" + cause.getMessage());
            } else {
                // log successful (re)loading
            }
        }
    };

    ArrayList<StoreUpdateListener> listenerList = new ArrayList<StoreUpdateListener>();
    listenerList.add(listener);
    RevocationParameters revParam = new RevocationParameters(CrlCheckingMode.REQUIRE, new OCSPParametes(),
            false, RevocationCheckingOrder.CRL_OCSP);
    ProxySupport proxySupport = ProxySupport.ALLOW;
    ValidatorParams validatorParams = new ValidatorParams(revParam, proxySupport, listenerList);
    NamespaceCheckingMode namespaceMode = NamespaceCheckingMode.EUGRIDPMA_AND_GLOBUS;
    long intervalMS = 3600000; // update ever hour
    OpensslCertChainValidator validator = new OpensslCertChainValidator("src/test/certificates", namespaceMode,
            intervalMS, validatorParams);
    X509Credential credentials = new PEMCredential("src/test/cert/trusted_client.proxy.grid_proxy",
            (char[]) null);
    SSLSocketFactory newFactory = SocketFactoryCreator.getSocketFactory(credentials, validator);

    CANLAXIS2SocketFactory factory = new CANLAXIS2SocketFactory(newFactory);
    try {
        Protocol.registerProtocol("https", new Protocol("https", factory, 8443));
        EchoServiceStub stub = new EchoServiceStub("https://localhost:8888/services/EchoService");
        GetAttributesResponseDocument doc = stub.getAttributes();

        System.out.println(doc.getGetAttributesResponse().getReturn());
        stub.cleanup();
        System.out.println("end of output");
    } catch (Exception e) {
        Axis2JettyServer.stop();
        e.printStackTrace();
        throw e;
    }
    System.out.println("end");
    Axis2JettyServer.stop();

}

From source file:io.cloudex.framework.cloud.entities.VmMetaData.java

/**
 * Sets the exception class name// w w w . jav a2 s.  c  o m
 * @param exp - the exception
 */
public void setException(Exception exp) {
    this.attributes.put(CLOUDEX_EXCEPTION, exp.getClass().getName());
}

From source file:net.pandoragames.far.ui.swing.FindAndReplace.java

/**
 * User preferences.//w  ww  . j a  v a  2s  .co m
 */
private void configure() {
    logger.debug("Configuration...");
    try {
        config = new SwingConfig();
        configFactory = new FARConfigurationFactory();
        configFactory.loadConfig(config);
        // localizer
        File localizerProperties = new File(
                this.getClass().getClassLoader().getResource("fartext.properties").toURI());
        Localizer loco = new DefaultLocalizer(localizerProperties, Locale.ENGLISH);
        JComponent.setDefaultLocale(loco.getLocale());
        config.setLocalizer(loco);
    } catch (Exception x) {
        logger.error(x.getClass().getName() + ": " + x.getMessage(), x);
        throw new ConfigurationException(x.getClass().getName() + ": " + x.getMessage());
    }

    // standard component hight
    JButton testButton = new JButton("TEST");
    config.setStandardComponentHight(testButton.getPreferredSize().height);

    // screen center
    Rectangle screen = getGraphicsConfiguration().getBounds();
    config.setScreenCenter(new Point((screen.width - screen.x) / 2, (screen.height - screen.y) / 2));

}

From source file:com.github.davidcarboni.encryptedfileupload.SizesTest.java

@Test
public void testMaxSizeLimitUnknownContentLength() throws IOException, FileUploadException {
    final String request = "-----1234\r\n"
            + "Content-Disposition: form-data; name=\"file1\"; filename=\"foo1.tab\"\r\n"
            + "Content-Type: text/whatever\r\n" + "Content-Length: 10\r\n" + "\r\n"
            + "This is the content of the file\n" + "\r\n" + "-----1234\r\n"
            + "Content-Disposition: form-data; name=\"file2\"; filename=\"foo2.tab\"\r\n"
            + "Content-Type: text/whatever\r\n" + "\r\n" + "This is the content of the file\n" + "\r\n"
            + "-----1234--\r\n";

    ServletFileUpload upload = new ServletFileUpload(new EncryptedFileItemFactory());
    upload.setFileSizeMax(-1);//from  w  w w .j a  v a  2s  .  c o  m
    upload.setSizeMax(300);

    // the first item should be within the max size limit
    // set the read limit to 10 to simulate a "real" stream
    // otherwise the buffer would be immediately filled

    MockHttpServletRequest req = new MockHttpServletRequest(request.getBytes("US-ASCII"), CONTENT_TYPE);
    req.setContentLength(-1);
    req.setReadLimit(10);

    FileItemIterator it = upload.getItemIterator(req);
    assertTrue(it.hasNext());

    FileItemStream item = it.next();
    assertFalse(item.isFormField());
    assertEquals("file1", item.getFieldName());
    assertEquals("foo1.tab", item.getName());

    {
        @SuppressWarnings("resource") // Streams.copy closes the input file
        InputStream stream = item.openStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Streams.copy(stream, baos, true);
    }

    // the second item is over the size max, thus we expect an error
    try {
        // the header is still within size max -> this shall still succeed
        assertTrue(it.hasNext());
    } catch (Exception e) {
        // FileUploadBase.SizeException has protected access:
        if (e.getClass().getSimpleName().equals("SizeException")) {
            fail();
        } else {
            throw e;
        }
    }

    item = it.next();

    try {
        @SuppressWarnings("resource") // Streams.copy closes the input file
        InputStream stream = item.openStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Streams.copy(stream, baos, true);
        fail();
    } catch (FileUploadIOException e) {
        // expected
    }

}

From source file:com.clustercontrol.jobmanagement.dialog.ManagerDistributionDialog.java

private int getScriptContentMaxSize() {
    int maxsize = 8192;

    JobEndpointWrapper wrapper = JobEndpointWrapper.getWrapper(m_manager);
    try {/*from www .j  a v  a 2  s .co m*/
        maxsize = wrapper.getScriptContentMaxSize();
    } catch (Exception e) {
        m_log.warn("getScriptContentMaxSize() getHinemosProperty, " + e.getClass().getSimpleName() + ", "
                + e.getMessage());
    }
    return maxsize;
}

From source file:com.wiiyaya.consumer.web.main.controller.ExceptionController.java

/**
 * /*from www. j a  va  2s .c om*/
 * @param request ?
 * @param exception 
 * @return ExceptionDto JSON
 */
@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ModelAndView springErrorHand(HttpServletRequest request, Exception exception) {
    String simpleMsg = (String) request.getAttribute(WebUtils.ERROR_MESSAGE_ATTRIBUTE);
    String errorCode = exception == null ? simpleMsg : exception.getClass().getSimpleName();
    String errorMessage = exception == null ? simpleMsg : exception.getMessage();

    LOGGER.error("Error catch: statusCode[{}], errorMessage[{}], errorUrl[{}]",
            HttpStatus.INTERNAL_SERVER_ERROR.value(), errorMessage, request.getRequestURI(), exception);

    return prepareExceptionInfo(request, HttpStatus.INTERNAL_SERVER_ERROR, errorCode, errorMessage);
}

From source file:de.tudarmstadt.lt.lm.app.PerpDoc.java

/**
 * /*from   w  w w  .ja  v  a2 s.c  o  m*/
 */
@SuppressWarnings("static-access")
public PerpDoc(String args[]) {
    Options opts = new Options();

    opts.addOption(new Option("?", "help", false, "display this message"));
    opts.addOption(OptionBuilder.withLongOpt("port").withArgName("port-number").hasArg()
            .withDescription(
                    String.format("Specifies the port on which the rmi registry listens (default: %d).",
                            Registry.REGISTRY_PORT))
            .create("p"));
    opts.addOption(OptionBuilder.withLongOpt("selftest")
            .withDescription("Run a selftest, compute perplexity of ngrams in specified LM.").create("s"));
    opts.addOption(OptionBuilder.withLongOpt("quiet").withDescription("Run with minimum outout on stdout.")
            .create("q"));
    opts.addOption(OptionBuilder.withLongOpt("noov").hasOptionalArg().withArgName("{true|false}")
            .withDescription("Do not consider oov terms, i.e. ngrams that end in an oov term. (default: false)")
            .create());
    opts.addOption(OptionBuilder.withLongOpt("oovreflm").withArgName("identifier").hasArg().withDescription(
            "Do not consider oov terms with respect to the provided lm, i.e. ngrams that end in an oov term in the referenced lm. (default use current lm)")
            .create());
    opts.addOption(OptionBuilder.withLongOpt("host").withArgName("hostname").hasArg()
            .withDescription("Specifies the hostname on which the rmi registry listens (default: localhost).")
            .create("h"));
    opts.addOption(OptionBuilder.withLongOpt("file").withArgName("name").hasArg().withDescription(
            "Specify the file or directory that contains '.txt' files that are used as source for testing perplexity with the specified language model. Specify '-' to pipe from stdin. (default: '-').")
            .create("f"));
    opts.addOption(OptionBuilder.withLongOpt("out").withArgName("name").hasArg()
            .withDescription("Specify the output file. Specify '-' to use stdout. (default: '-').")
            .create("o"));
    opts.addOption(OptionBuilder.withLongOpt("name").withArgName("identifier").isRequired().hasArg()
            .withDescription("Specify the name of the language model provider that you want to connect to.")
            .create("i"));

    try {
        CommandLine cmd = new ExtendedGnuParser(true).parse(opts, args);
        if (cmd.hasOption("help"))
            CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER, null, 0);

        _host = cmd.getOptionValue("host", "localhost");
        _rmiport = Integer.parseInt(cmd.getOptionValue("port", String.valueOf(Registry.REGISTRY_PORT)));
        _file = cmd.getOptionValue("file", "-");
        _out = cmd.getOptionValue("out", "-");
        _name = cmd.getOptionValue("name");
        _host = cmd.getOptionValue("host", "localhost");
        _selftest = cmd.hasOption("selftest");
        _quiet = cmd.hasOption("quiet");
        _no_oov = cmd.hasOption("noov");
        if (_no_oov && cmd.getOptionValue("noov") != null)
            _no_oov = Boolean.parseBoolean(cmd.getOptionValue("noov"));
        _oovreflm_name = cmd.getOptionValue("oovreflm");

    } catch (Exception e) {
        LOG.error("{}: {}- {}", _rmi_string, e.getClass().getSimpleName(), e.getMessage());
        CliUtils.print_usage_quit(System.err, StartLM.class.getSimpleName(), opts, USAGE_HEADER,
                String.format("%s: %s%n", e.getClass().getSimpleName(), e.getMessage()), 1);
    }
    _rmi_string = String.format("rmi://%s:%d/%s", _host, _rmiport, _name);
}

From source file:rashjz.info.com.az.config.AdviceController.java

@ExceptionHandler(value = Exception.class)
public ModelAndView defaultErrorHandler(HttpServletRequest req, Exception e) throws Exception {
    // If the exception is annotated with @ResponseStatus rethrow it and let
    // the framework handle it - like the OrderNotFoundException example
    // at the start of this post.
    // AnnotationUtils is a Spring Framework utility class.
    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;//  w  w w .jav  a2  s  .c  o m
    }

    // Otherwise setup and send the user to a default error-view.
    ModelAndView mav = new ModelAndView();
    mav.addObject("exception", e);
    mav.addObject("url", req.getRequestURL());
    mav.setViewName(DEFAULT_ERROR_VIEW);
    return mav;

}

From source file:org.fornax.cartridges.sculptor.framework.errorhandling.HibernateErrorHandlingAdvice.java

protected void handleDatabaseAccessException(Object target, Exception e) {
    Logger log = LoggerFactory.getLogger(target.getClass());

    // often the wrapped SQLException contains the interesting piece of
    // information
    StringBuilder message = new StringBuilder();
    message.append(e.getClass().getName()).append(": ");
    message.append(excMessage(e));//from   w  w  w.  j a  v a2  s. co m
    SQLException sqlExc = ExceptionHelper.unwrapSQLException(e);
    if (sqlExc != null) {
        message.append(", Caused by: ");
        message.append(sqlExc.getClass().getName()).append(": ");
        message.append(excMessage(sqlExc));
    }

    if (isJmsContext() && !isJmsRedelivered()) {
        LogMessage logMessage = new LogMessage(mapLogCode(DatabaseAccessException.ERROR_CODE),
                message.toString());
        log.info("{}", logMessage);
    } else {
        LogMessage logMmessage = new LogMessage(mapLogCode(DatabaseAccessException.ERROR_CODE),
                message.toString());
        log.error(logMmessage.toString(), e);
    }

    DatabaseAccessException newException = new DatabaseAccessException(message.toString());
    newException.setLogged(true);
    throw newException;
}