无法收到该值

时间:2019-05-31 10:07:37

标签: java tomcat owl owl-api

我从here处获取了此代码,并尝试在我的Web应用程序中使用它。问题是当我将字符串传递给此代码时,它给了我空指针异常,但是当我这样指定它时(字符串路径=“ C:\ folder \ file”)。它开始执行。我不知道是什么问题。任何帮助将不胜感激。

public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
    {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
    //  String filePath = "C:\\Users\\Desktop\\pizza.owl";

         HttpSession session = req.getSession();
         String st = (String) session.getAttribute("fileName");
OWLOntology mainOntology = null;
        Set<OWLOntology> ontologies = null;
        try {
            mainOntology = OntologyLoader.loadOntology(filePath, false).iterator().next();
            ontologies = OntologyLoader.loadOntology(filePath, true);
        } catch (OWLOntologyCreationException e) {
            e.printStackTrace();
        }
        out.println();


        ExpressivityChecker expChecker = new ExpressivityChecker(ontologies);
        String expressivity = expChecker.getDescriptionLogicName();
        out.println("Ontology Expressivity: " + expressivity + "\n");


        ExpressivityChecker.AxiomClassificationResult result = expChecker.getAxiomClassifications();
        HashMap<String, ArrayList<OWLAxiom>> axiomClassifications = result.classifications;
        out.println("Axiom Classifications:");
        for (String letter : axiomClassifications.keySet()) {
            out.println("=== " + letter + " ===");
            for (OWLAxiom axiom : axiomClassifications.get(letter)) 
            {
                out.println(axiom);
            }
            out.println();
            out.println("\n");
            out.println("\n");
        }
        out.println("Axiom Classifications Explanations:\n" + result.explanation);

        HashMap<String, OWLProfileReport> ontologyProfileReports = OWL2ProfileChecker.calculateOntologyProfileReports(mainOntology);
        for (String profileName : OWL2ProfileChecker.PROFILE_NAMES) 
        {
            out.println("Violations for profile " + profileName + ":");
            OWLProfileReport profileReport = ontologyProfileReports.get(profileName);
            out.println(profileReport.isInProfile());
            for (OWLProfileViolation violation : profileReport.getViolations()) 
            {
                out.println(violation.toString());
            }
            out.println();  
        }  
    }

Attempting to load null without imports
May 31, 2019 12:19:37 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [ghi] in context with path [/DemoApp1] threw exception
java.lang.NullPointerException
    at java.io.File.<init>(Unknown Source)
    at com.oe.OntologyLoader.loadOntology(OntologyLoader.java:41)
    at org.haya.OWLProfiles.profiles(OWLProfiles.java:49)
    at org.haya.OWLProfiles.service(OWLProfiles.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)

0 个答案:

没有答案