javacharacter-encodingtomcat7cjk

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


I get a FileNotFoundException while reading a Japanese folder structure from a Tomcat 7 web application in CentOS 7. However, it's working in a Docker container and direct Java console execution.

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

We have done the following configurations:

  1. Tomcat Server server.xml - In the Connector tag add 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