Adding UTF8 support to JBoss, Hibernate, mysql and Apache mod_jk
Recently I had to convert a system to be fully UTF8 compliant accross all tiers. Folowing are the instructions needed to make your system do the same and support multiple languages. I tested our system with 4 different languages including Hebrew, German, Arabic and Russian.
This file is a standard JPA file: /META-INF/persistence.xml
<property name="hibernate.connection.useUnicode" value="true"/> <property name="hibernate.connection.characterEncoding" value="UTF-8" />
This file is relevant to anyone using seam: page.xhtml
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
This is a custom MYSQL file that must be executed before you attempt inserting UTF8 charecters using mysql client :utfsupport.sql
SET NAMES 'utf8'; ALTER DATABASE xpr_cms DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; SHOW CREATE DATABASE xpr_cms;
This is standard JBoss configuration file : /jboss/default/deploy/jboss-web.deployer/server.xml Add the following property to each Connector component
Add the following property to each AJP Connector component to correctly work with mod_jk
In case you have any regular expression validations on Hibernate entity fields,( such as @Pattern(regex = RegularExpressions.REGEX_NAME) for instance, they must be disabled. If anyone has a solution to this issue, please contact me.