Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

In this page you can find the example usage for java.lang RuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.languagetool.dev.bigdata.AutomaticProhibitedCompoundRuleEvaluator.java

private void run(List<String> lines, File indexDir) throws IOException {
    Language language = Languages.getLanguageForShortCode(LANGUAGE);
    LanguageModel lm = new LuceneLanguageModel(indexDir);
    ProhibitedCompoundRuleEvaluator evaluator = new ProhibitedCompoundRuleEvaluator(language, lm);
    int lineCount = 0;
    for (String line : lines) {
        lineCount++;/*w w  w  .  j ava  2  s . com*/
        if (line.contains("#")) {
            System.out.println("Ignoring: " + line);
            continue;
        }
        String[] parts = line.split(";\\s*");
        if (parts.length != 2) {
            throw new IOException("Expected semicolon-separated input: " + line);
        }
        try {
            int i = 1;
            for (String part : parts) {
                // compare pair-wise - maybe we should compare every item with every other item?
                if (i < parts.length) {
                    runOnPair(evaluator, line, lineCount, lines.size(), removeComment(part),
                            removeComment(parts[i]));
                }
                i++;
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }
    System.out.println("Done. Ignored items because they are already known: " + ignored);
}

From source file:de.micromata.genome.db.jpa.tabattr.BaseOpTest.java

@Test
public void testOps() {
    try {/*  w  w  w.j  a  v a 2 s .  com*/
        final TestTabAttrJpaDAOImpl dao = new TestTabAttrJpaDAOImpl();
        TestMasterAttrDO master = FirstTest.createMaster(dao, 10, 1);
        dao.insert(master);
        master.setRecvName1("Micromata Headquarter");
        // master.putAttribute("Key No " + 1, "New Value");
        master.putStringAttribute("Key No " + 1, "A value to write");
        // master.putAttribute("Key No 0", "Also new: " + FirstTest.genLongString());
        dao.update(master);

    } catch (RuntimeException ex) { // NOSONAR "Illegal Catch" framework
        ex.printStackTrace();
        throw ex;
    }
}

From source file:com.orchestra.portale.controller.TestController.java

@RequestMapping("/elimina")
public ModelAndView elimina() {
    ModelAndView model = new ModelAndView("testview");
    String msg = "ok";

    try {//from  w ww.j a v  a 2  s. co  m

        poiMongoRepo.deleteAll();

    } catch (RuntimeException e) {
        msg = "error";
        e.printStackTrace();
    }

    model.addObject("msg", msg);

    return model;
}

From source file:org.opencds.vmr.v1_0.mappings.out.MarshalVMR2VMRSchemaPayload.java

public synchronized String mappingOutbound(Map<String, List<?>> results, DSSRequestKMItem dssRequestKMItem)
        throws InvalidDriDataFormatExceptionFault, UnrecognizedLanguageExceptionFault,
        RequiredDataNotProvidedExceptionFault, UnsupportedLanguageExceptionFault,
        UnrecognizedScopedEntityExceptionFault, EvaluationExceptionFault, InvalidTimeZoneOffsetExceptionFault,
        DSSRuntimeExceptionFault {//from   w w w  . j  ava2  s .  c o  m
    String interactionId = dssRequestKMItem.getDssRequestDataItem().getInteractionId();
    String requestedKmId = dssRequestKMItem.getRequestedKmId();
    String streamResultString = "";

    log.debug("II: " + interactionId + " KMId: " + requestedKmId + " begin buildVMRSchemaResultSet");
    BuildVMRSchemaResultSet buildVMRSchemaResultSet = BuildVMRSchemaResultSet.getInstance();
    org.opencds.vmr.v1_0.schema.CDSOutput cdsXMLOutput = buildVMRSchemaResultSet.buildResultSet(results,
            dssRequestKMItem);

    log.debug("II: " + interactionId + " KMId: " + requestedKmId + " finish buildVMRSchemaResultSet");
    dssRequestKMItem.getKmTimingData().setFinishBuildOutputTime(new AtomicLong(System.nanoTime()));

    JAXBElement<org.opencds.vmr.v1_0.schema.CDSOutput> jaxbCDSOutput;

    try {
        log.debug("II: " + interactionId + " KMId: " + requestedKmId + " begin factory.createCdsOutput");

        org.opencds.vmr.v1_0.schema.ObjectFactory factory = new org.opencds.vmr.v1_0.schema.ObjectFactory();
        jaxbCDSOutput = factory.createCdsOutput(cdsXMLOutput);

        log.debug("II: " + interactionId + " KMId: " + requestedKmId + " finish factory.createCdsOutput");
    } catch (RuntimeException e) {
        e.printStackTrace();
        throw new DSSRuntimeExceptionFault("RuntimeException in mappingOutbound ObjectFactory cdsOutput: "
                + e.getMessage() + ", vmrOutput=" + cdsXMLOutput.getVmrOutput().toString(), e);
    }

    if ((null == cdsXMLOutput)
            || ((null == cdsXMLOutput.getSimpleOutput()) && (null == cdsXMLOutput.getVmrOutput()))) {
        // show the tags, but empty payload
        streamResultString = "";
        //FIXME          throw new DSSRuntimeExceptionFault("Marshalled Rules Engine results are empty.");

    } else {
        log.debug("II: " + interactionId + " KMId: " + requestedKmId
                + " begin marshalling results to external VMR: "
                + cdsXMLOutput.getVmrOutput().getTemplateId().toString());

        ByteArrayOutputStream output = new ByteArrayOutputStream();
        StreamResult streamResult = new StreamResult();
        streamResult.setOutputStream(output);

        try {
            JAXBContext jaxbContext = SimpleKnowledgeRepository
                    .getRequiredJAXBContextForMarshallerClassCache(this.getClass().getName());

            Marshaller marshaller = SimpleKnowledgeRepository
                    .getRequiredMarshallerInstanceForMarshallerClassCache(this.getClass().getName(),
                            jaxbContext);

            marshaller.marshal(jaxbCDSOutput, streamResult);

        } catch (JAXBException e) {
            e.printStackTrace();
            throw new EvaluationExceptionFault(
                    "JAXBException in mappingOutbound marshalling cdsOutput: " + e.getMessage(), e);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw new DSSRuntimeExceptionFault(
                    "RuntimeException in mappingOutbound marshalling cdsOutput: " + e.getMessage(), e);
        }

        log.debug("II: " + interactionId + " KMId: " + requestedKmId
                + " finished marshalling results to external VMR: "
                + cdsXMLOutput.getVmrOutput().getTemplateId().toString());

        OutputStream outputStream = streamResult.getOutputStream();
        streamResultString = outputStream.toString();

    }

    dssRequestKMItem.getKmTimingData().setFinishMarshalTime(new AtomicLong(System.nanoTime()));

    return streamResultString;
}

From source file:de.cosmocode.palava.core.Main.java

private void start() {
    try {/* w  w w.j a va 2  s  . c o  m*/
        framework.start();
        persistState();
        /* CHECKSTYLE:OFF */
    } catch (RuntimeException e) {
        /* CHECKSTYLE:ON */
        LOG.error("startup failed", e);
        e.printStackTrace();
        stop();
        System.exit(1);
    }
}

From source file:it.drwolf.ridire.cleaners.ReadabilityCleaner.java

public String getCleanedTextFromString(CrawledResource crawledResource,
        StringWithEncoding rawContentAndEncoding, EntityManager entityManager) {
    String bookmarkJS = entityManager.find(Parameter.class, Parameter.READABILITY_SOURCE.getKey()).getValue();
    String host = entityManager.find(Parameter.class, Parameter.READABILITY_HOSTAPP.getKey()).getValue();
    bookmarkJS = bookmarkJS.replaceAll("@@@HOST@@@", host.trim());
    WebClient webClient = new WebClient();
    webClient = new WebClient(BrowserVersion.FIREFOX_3);
    webClient.setCssEnabled(true);//from w  ww.ja  v a 2 s  .  co m
    webClient.setJavaScriptEnabled(true);
    // vedi FAQ: http://htmlunit.sourceforge.net/faq.html#AJAXDoesNotWork
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    webClient.waitForBackgroundJavaScript(5000);
    webClient.waitForBackgroundJavaScriptStartingBefore(5000);
    // i seguenti 4 set servono per limitare i log
    webClient.setHTMLParserListener(null);
    webClient.setIncorrectnessListener(new NoOpIncorrectnessListener());
    webClient.setCssErrorHandler(new NoOpErrorHandler());
    webClient.setPrintContentOnFailingStatusCode(false);
    // questo serve per avere il tipo di errore HTTP
    webClient.setThrowExceptionOnFailingStatusCode(true);
    webClient.setThrowExceptionOnScriptError(false);
    webClient.setRefreshHandler(new ThreadedRefreshHandler());
    // webClient.setJavaScriptTimeout(4000);
    webClient.setTimeout(4000);
    File tmpFile = null;
    HtmlPage htmlPage = null;
    String ret = new String();
    try {
        tmpFile = File.createTempFile("readability", null);
        FileUtils.writeStringToFile(tmpFile, rawContentAndEncoding.getString());
        htmlPage = webClient.getPage(host.trim() + "/tmp/resource.seam?filename=" + tmpFile.getName());
        FileUtils.deleteQuietly(tmpFile);
        if (htmlPage != null) {
            // webClient.setJavaScriptEnabled(false);
            ScriptResult scriptResult = htmlPage.executeJavaScript(bookmarkJS);
            // System.out.println(htmlPage.asXml());
            for (HtmlElement he : htmlPage.getElementsByName("div")) {
                // System.out.println("-->" + he.getAttribute("id") +
                // "<--");
                // System.out.println(he.asText());
            }
            HtmlElement element = htmlPage.getElementById("readability-content");
            if (element != null) {
                ret = element.asText();
            }
        }
        if (tmpFile != null) {
            FileUtils.deleteQuietly(tmpFile);
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RuntimeException re) {
        // TODO: handle exception
        re.printStackTrace();
    } catch (Throwable t) {
        t.printStackTrace();
    } finally {
        webClient.closeAllWindows();
    }
    return ret.trim();
}

From source file:org.languagetool.dev.bigdata.AutomaticConfusionRuleEvaluator.java

private void run(List<String> lines, File indexDir, Language lang) throws IOException {
    LanguageModel lm = new LuceneLanguageModel(indexDir);
    int lineCount = 0;
    for (String line : lines) {
        lineCount++;//from   w ww .  j  a  v a  2 s .c o  m
        if (line.isEmpty()) {
            continue;
        }
        if (line.contains("#")) {
            System.out.println("Ignoring: " + line);
            continue;
        }
        System.out.printf(Locale.ENGLISH, "Line " + lineCount + " of " + lines.size() + " (%.2f%%)\n",
                ((float) lineCount / lines.size()) * 100.f);
        String[] parts = line.split("\\s*(;|->)\\s*");
        if (parts.length != 2) {
            throw new IOException("Expected input to be separated by '->' or ';': " + line);
        }
        boolean bothDirections = !removeComment(line).contains("->");
        ConfusionRuleEvaluator evaluator = new ConfusionRuleEvaluator(lang, lm, caseInsensitive,
                bothDirections);
        try {
            int i = 1;
            for (String part : parts) {
                // compare pair-wise - maybe we should compare every item with every other item?
                if (i < parts.length) {
                    runOnPair(evaluator, line, lineCount, lines.size(), removeComment(part),
                            removeComment(parts[i]), bothDirections);
                }
                i++;
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
        }
    }
    System.out.println("Done. Ignored items because they are already known: " + ignored);
}

From source file:br.com.railsos.os.bean.LoginBean.java

@PostConstruct
public void listar() {
    try {/*from   w  ww  .j  av  a2 s  . c o m*/
        LoginDAO loginDAO = new LoginDAO();
        logins = loginDAO.listar();
    } catch (RuntimeException erro) {
        Messages.addGlobalError("Ocorreu um erro ao tentar listar os usurio");
        erro.printStackTrace();

    }
}

From source file:br.com.railsos.os.bean.LoginBean.java

public void excluir(ActionEvent evento) {
    try {/*from  ww  w. j ava  2  s.c om*/
        login = (Login) evento.getComponent().getAttributes().get("usuarioSelecionado");

        LoginDAO loginDAO = new LoginDAO();
        loginDAO.excluir(login);

        logins = loginDAO.listar();

        Messages.addGlobalInfo("Usurio removido com sucesso");
    } catch (RuntimeException erro) {
        Messages.addFlashGlobalError("Ocorreu um erro ao tentar remover o usurio");
        erro.printStackTrace();
    }
}

From source file:br.com.railsos.os.bean.LoginBean.java

public void salvar() {
    try {/*from  w  w w.ja v a 2s.  c  o  m*/
        LoginDAO loginDAO = new LoginDAO();
        login.setPassword(DigestUtils.md5Hex(login.getPassword()));
        loginDAO.merge(login);

        login = new Login();

        logins = loginDAO.listar();

        Messages.addGlobalInfo("Usurio salvo com sucesso");
    } catch (RuntimeException erro) {
        Messages.addFlashGlobalError("Ocorreu um erro ao tentar salvar um novo usurio");
        erro.printStackTrace();
    }
}