title: Grails, Tomcat 7, REST Client and UTF-8 Encoding of Characters
body: <p>I am trying post the following string "`.4.13 - 30613 £ ₤ © ™" to a Grails Server once Deployed as a WAR and I'm having no luck when communicating between two instances of Tomcat7</p>
  
  <p>Our server works as an API, and the web layer entirely seperately. Data is saved to the DB by POST request to Web App, then the Web App sends a POST (or PUT for updates) request to the server to save the data.</p>
  
  <p>This works fine locally when I start the Web App and Server with "Run-App" but not when we move to non-local enviroments with Tomcat7 and deployed WAR files.</p>
  
  <p>Initally I thought this may be related to a reported bug <a href="http://jira.grails.org/browse/GRAILS-8873" rel="nofollow">http://jira.grails.org/browse/GRAILS-8873</a> but upon closer inspection, it appears that UTF-8 is the default anyway, and is currently in use</p>
  
  <p>The non-local enviroments use the following structure (Deployed WAR in Tomcat7)</p>
  
  <pre><code>Entry Point -&gt; Apache 2.2 &lt; - &gt; Web App &lt; - &gt; Server
  </code></pre>
  
  <p>The local environments use the following structure (Run App)</p>
  
  <pre><code>Entry Point -&gt; Web Abb &lt; - &gt; Server
  </code></pre>
  
  <p>I have output the value at the time of marshalling to string to ensure that before it is sent to the server, it is of the correct encoding</p>
  
  <pre><code>DEBUG MarshallService  - Marshalling Property : name of value [ `.4.13 - 30613 £ ? © ™]
  </code></pre>
  
  <p>This is directly from the log for the outgoing request from the Web App to the Server
  Ignore the fact that the content length is wrong, i've truncated the body for the purposes of readability.</p>
  
  <pre><code>DEBUG org.apache.http.headers  - &gt;&gt; PUT /baseline-server/baseline/pwqi9tzyTRWX5oZogfKjJw HTTP/1.1
  DEBUG org.apache.http.headers  - &gt;&gt; Accept: application/json; charset=utf-8
  DEBUG org.apache.http.headers  - &gt;&gt; Content-Length: 349
  DEBUG org.apache.http.headers  - &gt;&gt; Content-Type: application/json
  DEBUG org.apache.http.headers  - &gt;&gt; Host: localhost:9001
  DEBUG org.apache.http.headers  - &gt;&gt; Connection: Keep-Alive
  DEBUG org.apache.http.headers  - &gt;&gt; Accept-Encoding: gzip,deflate
  DEBUG org.apache.http.wire  - &gt;&gt; "{"name":"`.4.13 - 30613 [0xa3] ? [0xa9] [0x99]"}
  </code></pre>
  
  <p>I have read several answers across several other locations and done the following</p>
  
  <p>In Apache 2.2 HTTPD.conf before ANY VirtualHost</p>
  
  <pre><code>AddDefaultCharset utf-8
  </code></pre>
  
  <p>In both Tomcat Instances (Web.xml)</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;setCharacterEncodingFilter&lt;/filter-name&gt;
      &lt;filter-class&gt;org.apache.catalina.filters.SetCharacterEncodingFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;encoding&lt;/param-name&gt;
          &lt;param-value&gt;UTF-8&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;async-supported&gt;true&lt;/async-supported&gt;
  &lt;/filter&gt;
  </code></pre>
  
  <p>Additionally, as per other answers, I ahve ensured we are using webxml 1.4.1</p>
  
  <p>And yet, when the value reaches the Server side, the values are all ???</p>
  
  <p>What I find particularly strange is the outgoing JSON doesn't appear to show UTF-8 characters at all</p>
  
  <p>Any assistance would be greatly appreciated</p>