jboss wildfly 15,undertow 2.0.15空指针异常

wfveoks0  于 2022-11-08  发布在  其他
关注(0)|答案(1)|浏览(174)

我正在尝试加入api servlet localhost:8080/app/api,但我得到一个空指针。我的servletMap如下:

<servlet-mapping>
        <servlet-name>myServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>

例外情况:

java.lang.NullPointerException
        at io.undertow.servlet@2.0.15.Final//io.undertow.servlet.spec.HttpServletRequestImpl.getHttpServletMapping(HttpServletRequestImpl.java:247)
        at javax.servlet.api@1.0.0.Final//javax.servlet.http.HttpServletRequestWrapper.getHttpServletMapping(HttpServletRequestWrapper.java:164)
        at deployment.app.war//org.springframework.web.util.UrlPathHelper$Servlet4Delegate.skipServletPathDetermination(UrlPathHelper.java:780)
        at deployment.app.war//org.springframework.web.util.UrlPathHelper.skipServletPathDetermination(UrlPathHelper.java:272)
        at deployment.app.war//org.springframework.web.util.UrlPathHelper.getLookupPathForRequest(UrlPathHelper.java:251)
        at deployment.app.war//org.springframework.web.cors.UrlBasedCorsConfigurationSource.resolvePath(UrlBasedCorsConfigurationSource.java:260)
        at deployment.app.war//org.springframework.web.cors.UrlBasedCorsConfigurationSource.getCorsConfiguration(UrlBasedCorsConfigurationSource.java:244)
        at deployment.app.war//org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:86)
        at deployment.app.war//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at deployment.app.war//org.springframework.security.web.header.HeaderWriterFilter.doFilterInternal(HeaderWriterFilter.java:66)
        at deployment.app.war//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at deployment.app.war//org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:56)
        at deployment.app.war//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at deployment.app.war//org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
        at deployment.app.war//org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at deployment.app.war//org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:105)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:215)
        at deployment.app.war//org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:178)
        at deployment.app.war//org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:358)
        at deployment.app.war//org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:271)
        at io.undertow.servlet@2.0.15.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
        at io.undertow.servlet@2.0.15.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)

ps我已经尝试将servlet的url模式更改为/api它可以工作,但我想使用带有/api/* 的正确解决方案

k97glaaz

k97glaaz1#

我遇到过和你一样的问题。这个问题似乎是由于WildFly 15(refer to this link)中的一个bug。
作为一种解决方法,您可以按如下方式更改servletMap:

<servlet-mapping>
    <servlet-name>myServlet</servlet-name>
    <url-pattern>/api/*</url-pattern>
    <url-pattern>/api</url-pattern>
</servlet-mapping>

相关问题