0

次の例外があります。

Servlet.service() for servlet indexpage threw exception java.lang.NullPointerException
at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:675)
at org.apache.catalina.servlets.DefaultServlet.doHead(DefaultServlet.java:351)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at planplatform.cors.CorsFilter.doFilter(CorsFilter.java:61)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698)
at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690)
at java.lang.Thread.run(Unknown Source)

私の唯一のこの例外のコードは CorsFilter です。

HttpServletRequest req = (HttpServletRequest) servletRequest;
    HttpServletResponse resp = (HttpServletResponse) servletResponse;

    String origin = req.getHeader("Origin");

    boolean shouldAllowCorsOnOrigin = allowCorsOnOrigin(origin);

    if (shouldAllowCorsOnOrigin) 
    {
        resp.addHeader("Access-Control-Allow-Origin", origin);
        resp.addHeader("Access-Control-Allow-Credentials", "true");

        resp.setHeader("Allow", "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS");

        String headers = req.getHeader("Access-Control-Request-Headers");
        String method = req.getHeader("Access-Control-Request-Method");
        resp.addHeader("Access-Control-Allow-Methods", method);
        resp.addHeader("Access-Control-Allow-Headers", headers);

        if ("options".equalsIgnoreCase(req.getMethod())) 
        {
            resp.setContentType("text/plain");

            resp.getWriter().flush();
            return;
        }
    }

    // Fix ios6 caching post requests
    if ("post".equalsIgnoreCase(req.getMethod())) {
        resp.addHeader("Cache-Control", "no-cache");
    }

    if (filterChain != null) {
        filterChain.doFilter(req, resp);
    }

shouldAllowCorsOnOrigin が false なので、大きい if にはコードが入りません。

例外が発生する理由はありますか?

4

2 に答える 2