Quantcast
Channel: Active questions tagged servlets - Stack Overflow
Viewing all articles
Browse latest Browse all 714

`Cannot invoke "String.startsWith(String)" because "className" is null` starting servlet filter [closed]

$
0
0

I am new to using java servlet and I want to implement a filter for users to authenticate with SAML protocol. The java code of the functions init() and doFilter is as follows

 public void init(FilterConfig filterConfig) throws ServletException {    JavaCryptoValidationInitializer javaCryptoValidationInitializer = new JavaCryptoValidationInitializer();    try {      javaCryptoValidationInitializer.init();      for (Provider jceProvider : Security.getProviders()) {        logger.info(jceProvider.getInfo());      }      //inicializamos openSAML (mirar docu para explicar mejor)      XMLObjectProviderRegistry registry = new XMLObjectProviderRegistry();      ConfigurationService.register(XMLObjectProviderRegistry.class, registry);      registry.setParserPool(OpenSAMLUtils.getParserPool());      logger.info("Initializing");      InitializationService.initialize();    } catch (InitializationException e) {      throw new RuntimeException("Initialization failed");    }public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)    throws IOException, ServletException {    HttpServletRequest httpServletRequest = (HttpServletRequest) request;    HttpServletResponse httpServletResponse = (HttpServletResponse) response;    if (httpServletRequest.getSession().getAttribute(SPConstants.AUTHENTICATED_SESSION_ATTRIBUTE) != null) {      chain.doFilter(request, response);    } else {      setGotoURLOnSession(httpServletRequest);      redirectUserForAuthentication(httpServletResponse);    }  }

My definition of the filter in the web.xml file is as follows:

filter><filter-name>AccessFilter</filter-name><servlet-class>sp.example.AccessFilter</servlet-class></filter><filter-mapping><filter-name>AccessFilter</filter-name><url-pattern>/servlet/*</url-pattern><dispatcher>REQUEST</dispatcher></filter-mapping>

I am using the intellIJ community IDE with the Smart Plugin. My tomcat version is 10.1.20. My problem is that the server does not work, it displays but does not return any web page. The error I get in the IDE is as follows:

SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more Filters failed to start. Full details will be found in the appropriate container log fileSEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [/servlet-sp] startup failed due to previous errors

The error I get in the tomcat logs is as follows:

SEVERE [main] org.apache.catalina.core.StandardContext.filterStart Exception starting filter [AccessFilter]        java.lang.NullPointerException: Cannot invoke "String.startsWith(String)" because "className" is null                at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:480)                at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:473)                at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:143)                at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:243)                at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)                at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4301)                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4916...

Does anyone know what is happening and where is the error?


Viewing all articles
Browse latest Browse all 714

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>