title: Jersey MessageBodyWriter not found for media type=text/html
body: <p>I am going to display html using "Thymeleaf", but the following errors are given.
  The server using is tomcat8.
  My code looks like.</p>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
  &lt;groupId&gt;com.abc.def&lt;/groupId&gt;
  &lt;artifactId&gt;jersey_de&lt;/artifactId&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;jersey_de&lt;/name&gt;
  
  &lt;build&gt;
      &lt;finalName&gt;jersey_de&lt;/finalName&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;2.5.1&lt;/version&gt;
              &lt;inherited&gt;true&lt;/inherited&gt;
              &lt;configuration&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  
  &lt;dependencies&gt;
      &lt;!-- my setting --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-container-servlet&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.connectors&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-apache-connector&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-media-moxy&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.ext&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-mvc&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;!-- 
      &lt;dependency&gt;
          &lt;groupId&gt;org.glassfish.jersey.ext&lt;/groupId&gt;
          &lt;artifactId&gt;jersey-mvc-jsp&lt;/artifactId&gt;
          &lt;version&gt;2.21&lt;/version&gt;
      &lt;/dependency&gt;
       --&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.thymeleaf&lt;/groupId&gt;
          &lt;artifactId&gt;thymeleaf&lt;/artifactId&gt;
          &lt;version&gt;2.1.4.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  &lt;properties&gt;
      &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
  &lt;/properties&gt;
  </code></pre>
  
  <p></p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  </code></pre>
  
  <p>http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
      version="3.0">
      
          Jersey Web Application
          org.glassfish.jersey.servlet.ServletContainer
          
              jersey.config.server.provider.packages
              com.abc.def.jersey_de
          
          
              com.abc.def.jersey_de.ThymeleafViewProcessor
              /WEB-INF/view/
          
          1
      
      
          Jersey Web Application
          /webapi/*
      
  </p>
  
  <p>javacode</p>
  
  <pre><code>import javax.ws.rs.GET;
  import javax.ws.rs.Path;
  import javax.ws.rs.Produces;
  import javax.ws.rs.core.MediaType;
  
  import org.glassfish.jersey.server.mvc.Viewable;
  
  import com.abc.def.jersey_de.domain.TestPOJO;
  
  @Path("top")
  @Produces(MediaType.TEXT_PLAIN)
  public class DemoCtrl {
  
  
      @GET
      @Produces(MediaType.TEXT_HTML)
      public Viewable getIt() {
          Viewable vb = new Viewable("test",new TestPOJO());
          System.out.println("top end");
          return vb;
      }
  }
  </code></pre>
  
  <p>ThymeleafViewProcessor </p>
  
  <pre><code>@Provider
  public class ThymeleafViewProcessor implements TemplateProcessor&lt;String&gt; {
  
      @Context
      private HttpServletRequest request;
  
      @Context
      private HttpServletResponse response;
  
      @Context
      private ServletContext servletContext;
  
      private final TemplateEngine templateEngine;
  
      /**
       * コンストラクタ
       */
      public ThymeleafViewProcessor() {
  
          TemplateResolver resolver = new ServletContextTemplateResolver();
          resolver.setPrefix("/WEB-INF/view/");
          resolver.setSuffix(".html");
          resolver.setTemplateMode("HTML5");
          resolver.setCacheTTLMs(3600000L);
  
          templateEngine = new TemplateEngine();
          templateEngine.setTemplateResolver(resolver);
          System.out.println("ThymeleafViewProcessor end");
      }
  
      /**
       * 参照させるファイル名を解決する。
       */
      @Override
      public String resolve(String name, MediaType mediaType) {
  
          return name;
      }
  
      @Override
      public void writeTo(String templateReference, Viewable viewable, MediaType mediaType, MultivaluedMap&lt;String, Object&gt; httpHeaders, OutputStream out) throws IOException {
  
          WebContext context = new WebContext(request, response, servletContext);
  
          //HTML内でモデルオブジェクトを使用できるようにしている。
          //ここはモデル名をそのまま使用できるようにした方が良い。
          context.setVariable("item", viewable.getModel());
  
          Writer writer = new OutputStreamWriter(out);
          templateEngine.process(templateReference, context, writer);
  
          writer.flush();
      }
  }
  </code></pre>
  
  <p>ApplicationSetting</p>
  
  <pre><code>@ApplicationPath("/service")
  public class ApplicationSetting extends ResourceConfig {
  
      public ApplicationSetting() {
  
          packages(this.getClass().getPackage().getName());
  
          register(ThymeleafViewProcessor.class);
          register(MvcFeature.class);
          register(LoggingFilter.class);
          System.out.println("ApplicationSetting ");
      }
  
  }
  </code></pre>