Announcement Announcement Module
Collapse
No announcement yet.
Roo 1.1.0 release - Problem with UTF8 (german and cyrillic) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo 1.1.0 release - Problem with UTF8 (german and cyrillic)

    Hello,

    I use the roo-1.1.0 release and have same problem with

    a) german special characters (ö,ä,ß,ü)
    b) cyrillic characters (щвды...)

    See attached screenshots.

    Here are the commands for setup of roo project

    project --topLevelPackage test.test
    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

    What can I change? Thanks.


    See also https://jira.springsource.org/browse...2#action_60102

  • #2
    This is a database setup issue. I would guess HSQLDB does not use UTF-8 encoding out of the box. Can you try with a persistent database like MySQL which has character encoding of UTF-8?

    HTH,
    Stefan

    Comment


    • #3
      I changed the persistence from memory hsqldb to file hsqldb
      Code:
      persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT
      in order to see what is in the db file, because I have same application in Grails and in Roo.
      There is no problems in Grails with the german or cyrillic charachters, see attached file.

      Here are the results:

      Grails:
      Entered value Привет München,
      value in the file db INSERT INTO GUETER_EINHEIT VALUES(17,0,'\u041f\u0440\u0438\u0432\u0435\u0442 M\u00fcnchen')


      Roo:
      Entered value привет münchen,
      value in the file db INSERT INTO GUETER_EINHEIT VALUES(2,'\u00d0\u009f\u00d1\u0080\u00d0\u00b8\u00d0\u00b2\ u00d0\u00b5\u00d1\u0082 m\u00c3\u00bcnchen',0)


      Very strange, I see in Roo for one "special character" two unicode characters and the unicode is different?


      Same db settings in Grails and Roo

      Code:
      hsqldb.script_format=0
      runtime.gc_interval=0
      sql.enforce_strict_size=false
      hsqldb.cache_size_scale=8
      readonly=false
      hsqldb.nio_data_file=true
      hsqldb.cache_scale=14
      version=1.8.0
      hsqldb.default_table_type=memory
      hsqldb.cache_file_scale=1
      hsqldb.log_size=200
      modified=yes
      hsqldb.cache_version=1.7.0
      hsqldb.original_version=1.8.0
      hsqldb.compatible_version=1.8.0

      Some ideas? Thanks

      Comment


      • #4
        I copied the correct enty from grails hsqldb to roo hsqldb and started the roo aap. again and the entry is showed correctly.

        So the db settings should be ok.

        Comment


        • #5
          I opened a issue
          https://jira.springsource.org/browse/ROO-1684

          Comment


          • #6
            I committed a fix that works in my test environment. It would be great if someone could confirm this by using a source build.

            Comment


            • #7
              Hello,
              I had the same problem. Thanks to Stefan Schmidt. I have solved this problem by make CharacterEncodingFilter to the first of filters:
              Code:
              ...
              <context-param>
                      <param-name>contextConfigLocation</param-name>
                      <param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
                  </context-param>
                  
                  <filter>
                      <filter-name>CharacterEncodingFilter</filter-name>
                      <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                      <init-param>
                          <param-name>encoding</param-name>
                          <param-value>UTF-8</param-value>
                      </init-param>
                      <init-param>
                          <param-name>forceEncoding</param-name>
                          <param-value>true</param-value>
                      </init-param>
                  </filter>
                  
                  <filter>
                      <filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
                      <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
                  </filter>
              ... (other filters)
              But I'm also have similar problem with encoding values, that comes from @ModelAttribute method in controller.

              The code below.
              In controller:
              Code:
                  @ModelAttribute("russianWord")
                  public String populateRussianWord() {
                      return "Привет";
                  }
              In the view:
              Code:
              <spring:eval expression="russianWord" />
              The result is "Привет", but must be "Привет".

              I'm use Roo 1.1.0 RELEASE, Tomcat 6, Windows XP. All file encoding is UTF-8.

              Comment


              • #8
                I create issue https://jira.springsource.org/browse/ROO-1712

                Comment


                • #9
                  I resolve this problem by adding "<encoding>UTF-8</encoding>" to pom.xml file in the "maven-compiler-plugin" group.

                  Now my pom.xml look's like this:
                  ...
                  <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-compiler-plugin</artifactId>
                  <version>2.1</version>
                  <configuration>
                  <source>1.6</source>
                  <target>1.6</target>
                  <encoding>UTF-8</encoding>
                  </configuration>
                  </plugin>

                  I think that Roo must add this line by default.

                  Comment


                  • #10
                    I've also modified my pom.xml according to your advice but that didn't fix the issue with non-WesternEuropean characters.
                    Did you roll back all the other changes mentioned in your previous posts (e.g. CharacterEncodingFilter) and left with changed pom only?

                    Regards

                    Comment


                    • #11
                      Originally posted by berto View Post
                      I've also modified my pom.xml according to your advice but that didn't fix the issue with non-WesternEuropean characters.
                      Did you roll back all the other changes mentioned in your previous posts (e.g. CharacterEncodingFilter) and left with changed pom only?
                      Try to clean up and rebuild your project.
                      I had compile time encoding problem, which have been resolved by modifying pom.xml file and adding UTF-8 compile encoding. I found it by debugging my application (string in watch window was incorrect). Also you can log your string.

                      Comment


                      • #12
                        Originally posted by berto View Post
                        I've also modified my pom.xml according to your advice but that didn't fix the issue with non-WesternEuropean characters.
                        Did you roll back all the other changes mentioned in your previous posts (e.g. CharacterEncodingFilter) and left with changed pom only?

                        Regards

                        I've resolved this by fix pom.xml like this (see the line red, hope this helps):

                        Code:
                        <plugin>  
                            <groupId>org.codehaus.mojo</groupId>  
                            <artifactId>aspectj-maven-plugin</artifactId>  
                            <version>1.0</version>  
                            <dependencies>  
                                <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->  
                                <dependency>  
                                    <groupId>org.aspectj</groupId>  
                                    <artifactId>aspectjrt</artifactId>  
                                    <version>${aspectj.version}</version>  
                                </dependency>  
                                <dependency>  
                                    <groupId>org.aspectj</groupId>  
                                    <artifactId>aspectjtools</artifactId>  
                                    <version>${aspectj.version}</version>  
                                </dependency>  
                            </dependencies>  
                            <executions>  
                                <execution>  
                                    <goals>  
                                        <goal>compile</goal>  
                                        <goal>test-compile</goal>  
                                    </goals>  
                                </execution>  
                            </executions>  
                            <configuration>  
                                <outxml>true</outxml>  
                                <aspectLibraries>  
                                    <aspectLibrary>  
                                        <groupId>org.springframework</groupId>  
                                        <artifactId>spring-aspects</artifactId>  
                                    </aspectLibrary>  
                                </aspectLibraries>  
                                <source>1.6</source>  
                                <target>1.6</target>  
                                <encoding>UTF-8</encoding>
                            </configuration>  
                        </plugin>

                        Comment


                        • #13
                          UTF-8 with Roo

                          Hi, I resolved this issue by disable escaping of form submission contents, move the filter and filter-mapping for CharacterEncoding to the first, and add encoding tags to maven-compile-plugin in my pom.xml.
                          That's it.

                          Code:
                              <context-param>
                                  <param-name>defaultHtmlEscape</param-name>
                                  <param-value>false</param-value>
                              </context-param>
                          .....
                              <filter>
                                  <filter-name>CharacterEncodingFilter</filter-name>
                                  <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
                                  <init-param>
                                      <param-name>encoding</param-name>
                                      <param-value>UTF-8</param-value>
                                  </init-param>
                                  <init-param>
                                      <param-name>forceEncoding</param-name>
                                      <param-value>true</param-value>
                                  </init-param>
                              </filter>

                          Comment


                          • #14
                            Many thanks - it works fine now. The only thing I had to do was to add <encoding>UTF-8</encoding> to my pom file.

                            Comment


                            • #15
                              Also, if you want to load message files with UTF-8, change messageSource bean in webmvc-config.xml to:
                              <bean id="messageSource" p:defaultEncoding="UTF-8"/>

                              Comment

                              Working...
                              X