Search code examples
javacharacter-encodingtomcat7cjk

Unable to read and write Japanese folder structure in Tomcat 7, but it works for a Docker container


Getting a FileNotFoundException while reading a Japanese folder structer from a Tomcat 7 web application. But it's working in a Docker container and direct java console execution.

Both Docker and normal tomcat7 setup and configurations are the same.

We have done following configurations:

  1. Tomcat Server server.xml - In Connector tag added URIEncoding attribute as:
    <Connector port="8080"
               protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443"
               URIEncoding="UTF-8"/>
    
  2. catalina.sh - added following:
    export JAVA_OPTS="$JAVA_OPTS -server \
       -XX:-UseGCOverheadLimit \
       -Djava.awt.headless=true \
       -Djavax.servlet.request.encoding=UTF-8 \
       -Dfile.encoding=UTF-8"
    
    export CATALINA_OPTS="$CATALINA_OPTS \
       -Dfile.encoding='UTF-8'"`
    
  3. Executed the following command to change the server language:
    export LC_ALL=en_US.UTF-8
    

Solution

  • Upgrade Tomcat7 to tomcat9 or Tomcat7.0.109. The support is not available in Tomcat7 Early versions