Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-5040

ejb-jar.xml files read based on server file.encoding instead of encoding indicated with the xml header

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • TBD EAP 5
    • EAP 5.0.1
    • EJB
    • None
    • Hide

      The attached example (EncodeTest.zip) demonstrates this. To run the example

      1.) Edit the java.home property in the build.xml to match the location of your EAP 5 distribution
      2.) run "ant deploy" to deploy the ear to the default server profile
      3.) edit your $JBOSS_HOME/bin/run.conf to include the file.encoding by adding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8"
      4.) Start the default profile: $JBOSS_HOME/bin/run.sh
      5.) From the example project run "ant run" With UTF-8 the result is:

      08:01:14,992 INFO [STDOUT] File Encoding: UTF-8
      08:01:14,992 INFO [STDOUT] Expect true: true
      08:01:14,992 INFO [STDOUT] Expect false: false

      6.) Stop EAP, and edit run.conf to use the Cp1252 encoding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=Cp1252"
      7.) Start the default profile and, from the example project, run "ant run". The output will be

      08:02:31,584 INFO [STDOUT] File Encoding: Cp1252
      08:02:31,584 INFO [STDOUT] Expect true: false
      08:02:31,584 INFO [STDOUT] Expect false: true

      The relevant test code used in the above is:

      accent = (String)(new InitialContext().lookup("java:comp/env/utf8Character"));

      System.out.println("File Encoding: " + System.getProperty("file.encoding"));
      System.out.println("Expect true: " + accent.equals("é"));
      System.out.println("Expect false: " + accent.equals("é"));

      So, we see that when the file encoding is set to Cp1252, the file is read with the Cp1252 encoding instead of UTF-8, resulting in the incorrect translation of the accented character.

      Show
      The attached example (EncodeTest.zip) demonstrates this. To run the example 1.) Edit the java.home property in the build.xml to match the location of your EAP 5 distribution 2.) run "ant deploy" to deploy the ear to the default server profile 3.) edit your $JBOSS_HOME/bin/run.conf to include the file.encoding by adding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" 4.) Start the default profile: $JBOSS_HOME/bin/run.sh 5.) From the example project run "ant run" With UTF-8 the result is: 08:01:14,992 INFO [STDOUT] File Encoding: UTF-8 08:01:14,992 INFO [STDOUT] Expect true: true 08:01:14,992 INFO [STDOUT] Expect false: false 6.) Stop EAP, and edit run.conf to use the Cp1252 encoding: JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=Cp1252" 7.) Start the default profile and, from the example project, run "ant run". The output will be 08:02:31,584 INFO [STDOUT] File Encoding: Cp1252 08:02:31,584 INFO [STDOUT] Expect true: false 08:02:31,584 INFO [STDOUT] Expect false: true The relevant test code used in the above is: accent = (String)(new InitialContext().lookup("java:comp/env/utf8Character")); System.out.println("File Encoding: " + System.getProperty("file.encoding")); System.out.println("Expect true: " + accent.equals("é")); System.out.println("Expect false: " + accent.equals("é")); So, we see that when the file encoding is set to Cp1252, the file is read with the Cp1252 encoding instead of UTF-8, resulting in the incorrect translation of the accented character.
    • Workaround Exists
    • Hide

      If all deployment descriptors are using the same encoding, explicitly set the file.encoding to match.

      Show
      If all deployment descriptors are using the same encoding, explicitly set the file.encoding to match.
    • Not Required

      When the ejb-jar is processed, it is processed according to the file encoding set by the file.encoding system property. This occurs even if the ejb-jar.xml indicates the file encoding in the header:

      <?xml version="1.0" encoding="UTF-8"?>

      So, for example if a env-entry value is set to é and the file.encoding is set to Cp1252 (default on Windows) it will be rendered incorrectly as 'é'

      The expected, correct behavior is seen in EAP 4.x.

              rhn-engineering-cdewolf Carlo de Wolf
              rhn-support-miclark Mike Clark
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: