Spring Boot + Botdetect Captcha: Inputstream cannot be null

1.1k Views Asked by At

I've tried using the botdetetect captcha with Spring boot. It all works well, the captcha is showing it can detect if it's human or not. But whenever I'm going to my login screen with the captcha I keep getting this error stack:

2018-08-02 12:09:01.074 ERROR 25196 --- [nio-8080-exec-2] .c.SimpleCaptchaFileConfigurationFactory : SimpleXmlConfigurationLoader.load() java.lang.IllegalArgumentException: InputStream cannot be null

Here is my folder structure: enter image description here

I'm wondering if it's not detecting the botdetect.xml that's why it's having that error. How can I add it without putting a new WEB-INF folder?

1

There are 1 best solutions below

0
On BEST ANSWER

Found an answer at their tutorial https://captcha.com/doc/java/captcha-options.html#simple-api

added this to the config class:

@Bean
public ServletContextInitializer initializer() {
  return new ServletContextInitializer() {

    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
      servletContext.setInitParameter("BDC_configFileLocation", "/resources/botdetect.xml");
    }
  };
}