Defect #14656

JRuby: Encoding error when creating issues

Added by Vincent Mathon over 9 years ago. Updated about 9 years ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:-% Done:


Category:Ruby support
Target version:2.3.4
Resolution:Fixed Affected version:2.3.2


I upgraded from Redmine 1.4.4 to Redmine 2.3.2.
Redmine is built as a war using warbler-1.3.8, JRuby 1.7.2 and run on TOMCAT 7.0.37 with a JVM 1.6.31 on a RHEL 64 bit machine.
The database is a Mysql 5.5.28 and redmine tables are using a charset utf8.
We connect Redmine database with the following database.yml:

   adapter: jdbc
   jndi: java:/comp/env/jdbc/Redmine
   driver: com.mysql.jdbc.Driver

We do sometime observe the following issue:

Encoding::CompatibilityError (incompatible character encodings: ASCII-8BIT and UTF-8):
  app/models/issue.rb:159:in `create_or_update'
  app/controllers/issues_controller.rb:141:in `create'

The last database log before the exception is

INFO:   Issue Load (1.0ms)  SELECT `issues`.* FROM `issues` WHERE `issues`.`root_id` IS NULL ORDER BY `rgt` desc LIMIT 1 FOR UPDATE

Note that we can create issues with all kind of strange characters both in subject and detail. But the following case:

Subject=AS400 : fonctionnement autorisation utilisation email à  revoir
Detail=Rendre pré-alimenter à l'utilisation

fails systematically. If the subject becomes "AS400 : fonctionnement autorisation utilisation" and the detail remains unchanged it works !

As a workaround we can create the issue with the subject and update it with the detail in a second step...

Related issues

Related to Redmine - Defect #14883: Update activerecord-jdbc-adapter Closed


#1 Updated by Toshi MARUYAMA over 9 years ago

  • Subject changed from Encoding error when creating issues to JRuby: Encoding error when creating issues
  • Category changed from Issues to Ruby support

#2 Updated by Vincent Mathon about 9 years ago

I have solved the problem by upgrading activerecord-jdbc-adapter to version 1.2.7 (this issue seems to be related to an activerecord-jdbc-adapter encoding defect).
To achieve this I have modified two files:


platforms :jruby do
  # jruby-openssl is bundled with JRuby 1.7.0
  gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0'
  gem "activerecord-jdbc-adapter", "1.2.7" 

and Gemfile.lock

 activerecord (3.2.13)
      activemodel (= 3.2.13)
      activesupport (= 3.2.13)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activerecord-jdbc-adapter (1.2.7)
    activerecord-jdbcmysql-adapter (1.2.7)
      activerecord-jdbc-adapter (~> 1.2.7)
      jdbc-mysql (~> 5.1.0)

  activerecord-jdbc-adapter (= 1.2.7)

Vincent MATHON

#3 Updated by Toshi MARUYAMA about 9 years ago

  • Target version set to 2.3.4

#4 Updated by Toshi MARUYAMA about 9 years ago

  • Related to Defect #14883: Update activerecord-jdbc-adapter added

#5 Updated by Toshi MARUYAMA about 9 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Updated jdbc adapter version above 1.2.6 in Gemfile by trunk r12172 and 2.3-stable r12174.

Also available in: Atom PDF