title: Spring 5 restful web services using reactor
body: <p>I am building a resful app using spring 5, but getting exception. . .following is my code:</p>
  
  <p>pom.xml</p>
  
  <p>http://maven.apache.org/maven-v4_0_0.xsd">
      4.0.0
      com.spring
      spring5
      war
      0.0.1-SNAPSHOT
      spring5 Maven Webapp
      <a href="http://maven.apache.org" rel="nofollow noreferrer">http://maven.apache.org</a></p>
  
  <pre><code>&lt;properties&gt;
      &lt;spring.version&gt;5.0.0.BUILD-SNAPSHOT&lt;/spring.version&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.reactivestreams&lt;/groupId&gt;
          &lt;artifactId&gt;reactive-streams&lt;/artifactId&gt;
          &lt;version&gt;1.0.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.projectreactor&lt;/groupId&gt;
          &lt;artifactId&gt;reactor-core&lt;/artifactId&gt;
          &lt;version&gt;3.0.3.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;io.projectreactor.ipc&lt;/groupId&gt;
          &lt;artifactId&gt;reactor-netty&lt;/artifactId&gt;
          &lt;version&gt;0.6.0.BUILD-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
          &lt;artifactId&gt;tomcat-embed-core&lt;/artifactId&gt;
          &lt;version&gt;8.5.4&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web-reactive&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;
          &lt;version&gt;2.0.0.BUILD-SNAPSHOT&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;${spring.version}&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- JACKSON --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-core&lt;/artifactId&gt;
          &lt;version&gt;2.8.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
          &lt;version&gt;2.8.6&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
          &lt;artifactId&gt;jackson-annotations&lt;/artifactId&gt;
          &lt;version&gt;2.8.6&lt;/version&gt;
      &lt;/dependency&gt;
  
      &lt;!-- LOG4J --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
          &lt;artifactId&gt;log4j-web&lt;/artifactId&gt;
          &lt;version&gt;2.7&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;repositories&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-milestones&lt;/id&gt;
          &lt;name&gt;Spring Milestones&lt;/name&gt;
          &lt;url&gt;https://repo.spring.io/libs-milestone&lt;/url&gt;
          &lt;snapshots&gt;
              &lt;enabled&gt;false&lt;/enabled&gt;
          &lt;/snapshots&gt;
      &lt;/repository&gt;
      &lt;repository&gt;
          &lt;id&gt;spring-snapshots&lt;/id&gt;
          &lt;name&gt;Spring Snapshots&lt;/name&gt;
          &lt;url&gt;https://repo.spring.io/libs-snapshot&lt;/url&gt;
          &lt;snapshots&gt;
              &lt;enabled&gt;true&lt;/enabled&gt;
          &lt;/snapshots&gt;
      &lt;/repository&gt;
  &lt;/repositories&gt;
  
  &lt;build&gt;
      &lt;finalName&gt;spring5&lt;/finalName&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>
  
  <p>spring-config.xml</p>
  
  <pre><code> &lt;beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:context="http://www.springframework.org/schema/context"
          xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:task="http://www.springframework.org/schema/task"
          xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
          xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context.xsd
          http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
          http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd
          http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
          http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  
          &lt;context:annotation-config /&gt;
          &lt;mvc:default-servlet-handler/&gt;
  
          &lt;context:component-scan base-package="com.spring5"&gt;
              &lt;context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/&gt;
          &lt;/context:component-scan&gt;
  
          &lt;mvc:annotation-driven /&gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>package com.spring5.controller;
  
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.spring5.bean.Message;
  
  import reactor.core.publisher.Mono;
  
  @RestController
  public class Spring5Controller
  {
    @PostMapping(value = "mono-test", consumes = MediaType.APPLICATION_JSON_VALUE, produces = "application/stream+json")
    public Mono&lt;ResponseEntity&lt;Message&gt;&gt; monoTest(@RequestBody Message message)
    {
       return Mono.just(new ResponseEntity(new Message(), HttpStatus.BAD_REQUEST));
    }
  
  }
  </code></pre>
  
  <p>On calling the webservice from postman, I am getting following exception:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: No converter found for return
    value of type: class reactor.core.publisher.MonoMapFuseable   at
    org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor.writeWithMessageConverters(AbstractMessageConverterMethodProcessor.java:187)
      at
    org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.handleReturnValue(RequestResponseBodyMethodProcessor.java:174)
      at
    org.springframework.web.method.support.HandlerMethodReturnValueHandlerComposite.handleReturnValue(HandlerMethodReturnValueHandlerComposite.java:81)
      at
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:132)
      at
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:826)
      at
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737)
      at
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
      at
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
      at
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
      at
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:964)
      at
    org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:867)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)     at
    org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:841)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)     at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
      at
    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
      at
    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
      at
    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
      at
    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
      at
    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
      at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
      at
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
      at
    org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
      at
    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
      at
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
      at
    org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
      at
    org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
      at
    org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)</p>
  </blockquote>
  
  <p>According to my understanding this is an issue with the negotiation manager, so is the negotiation manager configuration changed or or I need to add another message-converters for reactive classes. . .any help is very much appreciated.</p>