0

I always get a "NoSuchMethodError" in my Spring Boot application when I try to redirect to a html-file and I don't understand where this is coming from. Hope someone can help.

Background: An external server is sending some information to my server by calling a method via url /resolce. This method processed the information and shall deliver the information to a html-file via redirecting. The processing of the information works fine, but when it comes to the redirect I get an NoSuchMethodError. I thought the template engine can't find the view, but the configuration seems fine.

Here is the stacktrace:

Exception Processing ErrorPage[errorCode=0, location=/error]
java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;
        at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:708)
        at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:114)
        at org.apache.catalina.core.ApplicationDispatcher.wrapRequest(ApplicationDispatcher.java:917)
        at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:358)
        at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:312)
        at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:394)
        at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:253)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:175)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
        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:853)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
        at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Thread.java:748)

The method:

@PostMapping ( "response" )
public ModelAndView postResponse ( ...,  UriComponentsBuilder ucb, HttpServletRequest request ) {
byte [ ] samlResponseAsBytes = DatatypeConverter.parseBase64Binary ( samlResponse );
...
return new ModelAndView ( "redirect:" + ucb.path ( "/delivery" ).build ( ).toString ( ) );
}

Application.properties

...
spring.thymeleaf.prefix = classpath:views/
spring.thymeleaf.suffix = .html
spring.thymeleaf.check-template-location = true
spring.thymeleaf.cache = false
spring.resources.static-locations = classpath:resources/
spring.resources.cache.period = 0

I've tried several locations for the delivery.html but as it is configured it should be under resources/views.

I can upload more informations, if neccessary.

Can someone help me please?

5
  • You have a JAR file conflict. Ensure you are not bundling servet-api libraries in the deployed WAR as these should be provided by the runtime. Commented Dec 3, 2019 at 11:57
  • 1
    Does this answer your question? Spring boot: java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping; Commented Dec 3, 2019 at 11:58
  • I've seen this post, but I don't have spring-boot-starter-tomcat-dependency, neither in th parent pom nor in the submodul. So I guessed I can't easily change that Commented Dec 3, 2019 at 12:06
  • Essentially, as advised above, you have a JAR file conflict by some means or other and need to fix it. Commented Dec 3, 2019 at 12:07
  • Thanks, found another solution. I'll upload soon Commented Dec 3, 2019 at 12:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.