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:de.tudarmstadt.lt.n2n.preparsed.annotators.PreParsedLineAnnotator.java

@Override
public void process(JCas aJCas) throws AnalysisEngineProcessException {
    try {//from  w w w.  j a v  a 2  s .  com
        _parser.parse(aJCas, _create_sentences, _create_tokens, _create_dependencies,
                _create_collapsed_dependencies, _create_constituents, _write_penntree);
    } catch (Exception e) {
        LOG.warn("Could not process cas {}, text: '{}' ({}: {})", DocumentMetaData.get(aJCas).getDocumentId(),
                StringUtils.abbreviate(aJCas.getDocumentText(), 50), e.getClass().getSimpleName(),
                e.getMessage());
        if (_fail_early)
            throw new AnalysisEngineProcessException(e);
    }
}

From source file:org.scrutmydocs.webapp.service.settings.rivers.RiverService.java

/**
 * Stop a running river//w ww .j  ava 2s . co  m
 * @param river
 */
public void stop(BasicRiver river) {
    if (logger.isDebugEnabled())
        logger.debug("delete({})", river);
    if (river == null)
        return;

    try {
        client.admin().indices().prepareDeleteMapping("_river").setType(river.getId()).execute().actionGet();
    } catch (Exception e) {
        logger.warn("delete({}) : Exception raised : {}", river, e.getClass());
        if (logger.isDebugEnabled())
            logger.debug("- Exception stacktrace :", e);
    }
    if (logger.isDebugEnabled())
        logger.debug("/delete({})", river);
}

From source file:com.clustercontrol.jmx.session.JmxMasterControllerBean.java

/**
 * JMX ????/*from  w  ww .j ava  2  s .c  o  m*/
 * 
 * @return JMX 
 * @throws HinemosUnknown
 */
public List<JmxMasterInfo> getJmxMasterList() throws HinemosUnknown {
    JpaTransactionManager jtm = null;
    List<JmxMasterInfo> ret = new ArrayList<>();

    try {
        jtm = new JpaTransactionManager();
        HinemosEntityManager em = jtm.getEntityManager();
        List<JmxMasterInfo> entities = em.createNamedQuery("MonitorJmxMstEntity.findAll", JmxMasterInfo.class)
                .getResultList();
        ret.addAll(entities);
    } catch (Exception e) {
        m_log.warn("getJmxMasterList() : " + e.getClass().getSimpleName() + ", " + e.getMessage(), e);
        if (jtm != null)
            jtm.rollback();
        throw new HinemosUnknown(e.getMessage(), e);
    } finally {
        if (jtm != null) {
            jtm.close();
        }
    }
    return ret;
}

From source file:fedora.server.management.UploadServlet.java

/**
 * The servlet entry point. http://host:port/fedora/management/upload
 */// w  ww  . j ava2s.c  o  m
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    Context context = ReadOnlyContext.getContext(Constants.HTTP_REQUEST.REST.uri, request);
    try {
        // Create a new file upload handler
        ServletFileUpload upload = new ServletFileUpload();

        // Parse the request, looking for "file"
        InputStream in = null;
        FileItemIterator iter = upload.getItemIterator(request);
        while (in == null && iter.hasNext()) {
            FileItemStream item = iter.next();
            LOG.info("Got next item: isFormField=" + item.isFormField() + " fieldName=" + item.getFieldName());
            if (!item.isFormField() && item.getFieldName().equals("file")) {
                in = item.openStream();
            }
        }
        if (in == null) {
            sendResponse(HttpServletResponse.SC_BAD_REQUEST, "No data sent.", response);
        } else {
            sendResponse(HttpServletResponse.SC_CREATED, s_management.putTempStream(context, in), response);
        }
    } catch (AuthzException ae) {
        throw RootException.getServletException(ae, request, "Upload", new String[0]);
    } catch (Exception e) {
        e.printStackTrace();
        sendResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                e.getClass().getName() + ": " + e.getMessage(), response);
    }
}

From source file:com.neuron.trafikanten.dataProviders.trafikanten.TrafikantenDevi.java

@Override
public void run() {
    try {/* w w w.  j  av  a  2  s  . c o  m*/
        //String urlString = "http://devi.trafikanten.no/devirest.svc/json/linenames/";
        String urlString = "http://devi.trafikanten.no/devirest.svc/json/lineids/";
        if (lines.length() > 0) {
            urlString = urlString + URLEncoder.encode(lines, "UTF-8");
        } else {
            urlString = urlString + "null";
        }
        urlString = urlString + "/stopids/" + stationId + "/";
        urlString = urlString + "from/" + dateFormater.format(System.currentTimeMillis()) + "/to/2030-12-31";
        Log.i(TAG, "Loading devi data : " + urlString);

        final InputStream stream = HelperFunctions.executeHttpRequest(context, new HttpGet(urlString),
                false).stream;

        /*
         * Parse json
         */
        final JSONArray jsonArray = new JSONArray(HelperFunctions.InputStreamToString(stream));
        final int arraySize = jsonArray.length();
        for (int i = 0; i < arraySize; i++) {
            final JSONObject json = jsonArray.getJSONObject(i);
            DeviData deviData = new DeviData();

            {
                /*
                 * Grab validFrom and check if we should show it or not.
                 */
                deviData.validFrom = HelperFunctions.jsonToDate(json.getString("validFrom"));
                final long dateDiffHours = (deviData.validFrom - Calendar.getInstance().getTimeInMillis())
                        / HelperFunctions.HOUR;
                if (dateDiffHours > 3) {
                    /*
                     * This data starts more than 3 hours into the future, hide it.
                     */
                    continue;
                }
            }
            {
                /*
                 * Grab published, and see if this should be visible yet.
                 */
                final long publishDate = HelperFunctions.jsonToDate(json.getString("published"));
                if (System.currentTimeMillis() < publishDate) {
                    continue;
                }
            }
            {
                /*
                 * Check validto, and see if this should be visible yet.
                 */
                final long validToDate = HelperFunctions.jsonToDate(json.getString("validTo"));
                if (System.currentTimeMillis() > validToDate) {
                    continue;
                }
            }

            /*
             * Grab the easy data
             */
            deviData.title = json.getString("header");
            deviData.description = json.getString("lead");
            deviData.body = json.getString("body");
            deviData.validTo = HelperFunctions.jsonToDate(json.getString("validTo"));
            deviData.important = json.getBoolean("important");
            deviData.id = json.getInt("id");

            {
                /*
                 * Grab lines array
                 */
                final JSONArray jsonLines = json.getJSONArray("lines");
                final int jsonLinesSize = jsonLines.length();
                for (int j = 0; j < jsonLinesSize; j++) {
                    deviData.lines.add(jsonLines.getJSONObject(j).getInt("lineID"));
                }
            }

            {
                /*
                 * Grab stops array
                 */
                final JSONArray jsonLines = json.getJSONArray("stops");
                final int jsonLinesSize = jsonLines.length();
                for (int j = 0; j < jsonLinesSize; j++) {
                    deviData.stops.add(jsonLines.getJSONObject(j).getInt("stopID"));
                }
            }

            ThreadHandlePostData(deviData);
        }

    } catch (Exception e) {
        if (e.getClass() == InterruptedException.class) {
            ThreadHandlePostExecute(null);
            return;
        }
        ThreadHandlePostExecute(e);
        return;
    }
    ThreadHandlePostExecute(null);
}

From source file:nl.mindef.c2sc.nbs.olsr.pud.uplink.server.cluster.impl.RelayClusterReceiverImpl.java

@Override
public void run() {
    byte[] receiveBuffer = new byte[UplinkReceiver.BUFFERSIZE];
    DatagramPacket packet = new DatagramPacket(receiveBuffer, receiveBuffer.length);

    while (this.run.get()) {
        try {/*from w  ww.j  a  v  a 2s  .  com*/
            this.sock.receive(packet);

            InetAddress ip = packet.getAddress();
            int port = packet.getPort();
            if (this.logger.isDebugEnabled()) {
                this.logger.debug("received packet from RelayServer " + ip.getHostAddress() + ":" + port);
            }

            RelayServer me = this.relayServers.getMe();
            if (!(ip.equals(me.getIp()) && (port != this.relayClusterUdpPort))) {
                DatagramPacket msg = RelayClusterMessage.fromWireFormat(packet, this.reportOnce);
                if (msg != null) {
                    RelayServer rs = this.relayServers.getOrAdd(ip, port);
                    boolean packetCausedUpdate = this.packetHandler.processPacket(rs, msg);
                    if (this.relayClusterForwarding && packetCausedUpdate) {
                        if (this.logger.isDebugEnabled()) {
                            this.logger.debug(
                                    "forwarding packet from RelayServer " + ip.getHostAddress() + ":" + port);
                        }
                        this.relayClusterSender.addPacket(rs, msg);
                    }
                } else {
                    this.logger.error("Could not convert RelayClusterMessage from wire format");
                }
            } else {
                if (this.logger.isDebugEnabled()) {
                    this.logger.debug("skipping packet from RelayServer " + ip.getHostAddress() + ":" + port
                            + " since the packet came from me");
                }
            }
        } catch (Exception e) {
            if (!SocketException.class.equals(e.getClass())) {
                e.printStackTrace();
            }
        }
    }

    if (this.sock != null) {
        this.sock.close();
        this.sock = null;
    }
}

From source file:iddb.web.security.service.CommonUserService.java

private void saveLocal(Subject subject) {
    try {/*from   ww w. j a  va 2 s.  c om*/
        getContext().setSubject(subject);
    } catch (Exception e) {
        log.error("{}: {}", e.getClass().getName(), e.getMessage());
    }
}

From source file:no.dusken.common.spring.ExceptionHandler.java

/**
 * sends mail to mailAddress with the exception if the exceptions isn't in the ignoreExcptions
 * @return super.doResolveException//  www.j av  a2 s .  c o m
 */
@Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response,
        Object handler, Exception ex) {
    log.error("Exception thrown", ex);
    if (!ignoreExceptions.containsKey(ex.getClass().getCanonicalName()) && sendMail) {
        try {
            Mail mail = new Mail();
            mail.setFromAddress(fromAddress);
            mail.setFromName(fromName);
            mail.setToAddress(mailAddress);
            mail.setSubject(ex.toString());
            String body = getBody(request, ex);
            mail.setBody(body);
            Map map = new HashMap();
            map.put("exception", ex);
            mailSender.sendEmail(mail, map, exceptionMailTemplate);
        } catch (Exception e) {
            log.error("Sending of exceptionmail failed", e);
            //nevermind the exception, continue with the original exception
        }
    }
    response.setStatus(500);
    return super.doResolveException(request, response, handler, ex);
}

From source file:ru.org.linux.exception.ExceptionResolver.java

/**
 * ?  web-  ?  .//from www.  j a  v  a2s. com
 *
 * @param modelAndView  web-
 * @param request       ?  web-
 * @param exception    ?
 */
private void prepareModelForCommonException(ModelAndView modelAndView, HttpServletRequest request,
        Exception exception) {
    modelAndView.addObject("headTitle", StringUtil.escapeHtml(exception.getClass().getName()));

    String errorMessage = exception.getMessage() == null ? StringUtil.escapeHtml(exception.getClass().getName())
            : StringUtil.escapeHtml(exception.getMessage());
    modelAndView.addObject("errorMessage", errorMessage);

    ExceptionType exceptionType = ExceptionType.OTHER;
    if (exception instanceof UserErrorException) {
        exceptionType = ExceptionType.IGNORED;
    } else if (exception instanceof ScriptErrorException) {
        logger.debug("errors/common.jsp", exception);
        exceptionType = ExceptionType.SCRIPT_ERROR;
    } else {
        logger.warn("Unexcepted exception caught", exception);
        String infoMessage = sendEmailToAdmin(request, exception);
        modelAndView.addObject("infoMessage", infoMessage);
    }
    modelAndView.addObject("exceptionType", exceptionType.name());
}

From source file:eu.peppol.persistence.jdbc.OxalisDataSourceFactoryDbcpImplTest.java

@Test
public void testFailWithStaleConnection() throws Exception {
    ConnectionFactory driverConnectionFactory = createConnectionFactory(false);

    PoolingDataSource poolingDataSource = createPoolingDataSource(driverConnectionFactory);
    try {//from  w  w  w .  j  a v a2  s  .  c o  m
        runTwoSqlStatementsWithTwoConnections(poolingDataSource);
    } catch (Exception e) {
        assertTrue(e.getClass().getName().contains("CommunicationsException"));
    }
}