1 2 Previous Next 22 Replies Latest reply on Dec 21, 2011 2:05 PM by 901561 Go to original post
      • 15. Re: [HELP]: Email sent from library running under Tomcat loses French chars
        901561
        Many thanks for your reply,

        I'll try your code one both machines to see what I get and will get back to you soon.

        In the meantime, I have decided to check something else as well....

        I have just noticed that there is a slight difference in the output if I have the following environment variables set to:

        export LC_ALL=en_GB.UTF-8
        export LANG=en_GB.UTF-8

        or

        export LC_ALL=en_GB.US-ASCII
        export LANG=en_GB.US-ASCII

        I'll post my results soon.

        thank you very much again. Your excelent support is highly appreciated!

        Gizmo

        PS: I got JavaMail V1.4.4 from this url below (which was the only version of JavaMail that I was able to find :) ):

        http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-eeplat-419426.html#javamail-1.4.4-oth-JPR
        • 16. Re: [HELP]: Email sent from library running under Tomcat loses French chars
          901561
          Hi again,

          I currently cannot test my scenario, as I need root to do it (change the cluster resource config and tomcat scripts) on the VAL system...

          So I decided to try your test code.

          On the DEV system (where everything runs smoothly), I got what was expected:

          MIME-Version: 1.0
          Content-Type: text/plain; charset=utf-8
          Content-Transfer-Encoding: quoted-printable

          test this utf-8 character: =C3=89

          However on my VAL system (where the problem lies), I got:

          MIME-Version: 1.0
          Content-Type: text/plain; charset=utf-8
          Content-Transfer-Encoding: 7bit

          test this utf-8 character: ?

          could the LANG and LC_ALL variables' values be causing this?

          Cheers again,
          Nuno
          • 17. Re: [HELP]: Email sent from library running under Tomcat loses French chars
            Bill Shannon-Oracle
            could the LANG and LC_ALL variables' values be causing this?
            Honestly, I wouldn't have expected them to, but that's certainly one thing to try.

            Also, make sure you're using the same mail.jar in both cases. Try running with "java -Dmail.debug=true ..."
            and make sure the debug output has the same version number.
            • 18. Re: [HELP]: Email sent from library running under Tomcat loses French chars
              901561
              Hi again,
              Besides the javamail version number, should I look for something else?

              Thanks,
              Giz
              • 19. Re: [HELP]: Email sent from library running under Tomcat loses French chars
                Bill Shannon-Oracle
                I'm just trying to be 100% sure that you're using the same JavaMail version in both cases.
                If that's not the problem, I'm not sure where to look next.

                Oh, and check the JDK version - "java -version".
                • 20. Re: [HELP]: Email sent from library running under Tomcat loses French chars
                  901561
                  Hi, same mail.jar V1.4.4 reported.

                  Slightly different Java version:

                  DEV: 1.6.0_13-b03

                  VAL: 1.6.0_29-b11

                  Also have checked the locale settings...they're the same...:

                  locale -a

                  C
                  POSIX
                  iso_8859_1

                  Hum...when setting the LANG and LC_ALL variables to "en_US.UTF-8", I get an error when re-starting or shutting down tomcat:

                  Couldn't set locale properly
                  Couldn't set locale properly
                  Couldn't set locale properly
                  Couldn't set locale properly

                  OK, I have ran your test code from 2 different manners on my problematic VAL solaris server:

                  1) from the shell directly with "java -jar test.jar" and got the expected:
                  DEBUG: setDebug: JavaMail version 1.4.4
                  ..
                  ..
                  ...
                  Content-Type: text/plain; charset=utf-8
                  Content-Transfer-Encoding: quoted-printable

                  test this utf-8 character: =C3=89

                  2) Running the same exact code, but this time triggered from a jsp (running under tomcat) which just calls the exact same java method as done in 1):

                  DEBUG: setDebug: JavaMail version 1.4.4
                  ..
                  ..
                  ...
                  Content-Type: text/plain; charset=utf-8
                  Content-Transfer-Encoding: 7bit

                  test this utf-8 character: ?


                  Could it be something related with the Tomcat configuration? Or any env variables affecting the JVM under which Tomcat is started?

                  I'll get support from the Server admins next monday...but am still clueless....
                  • 21. Re: [HELP]: Email sent from library running under Tomcat loses French chars
                    Bill Shannon-Oracle
                    It definitely seems to be something related to your Tomcat environment, but I'm at a loss as to what it could be.

                    If you can run your Tomcat server with a different mail.jar file for debugging let me know at javamail_ww@oracle.com
                    and I'll send you a mail.jar file with more debugging output to try to track down the problem.
                    • 22. Re: [HELP]: Email sent from library running under Tomcat loses French chars
                      901561
                      I have just fixed the problem.

                      Looks like it was indeed a mailcap related issue. There must be more mailcap configuration files, which are then read by the Java Activation Framework package to decide how to handle a certain Mime type.

                      On my Tomcat environment, there seems to be multiple ones defined and being ingested, but I could not figure out their locations...

                      So my solution was to simply programatically set my default Maicap settings using the following code (set before doing any call to the JavaMail API):
                      MailcapCommandMap mc = (MailcapCommandMap) new MailcapCommandMap();
                      mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
                      mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
                      mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
                      mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
                      mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
                      CommandMap.setDefaultCommandMap(mc);
                      That finally solved it.

                      Thanks to Bill Shannon for all the hard-work and for his excelent support!!!!

                      PS: It might be worth perhaps highlighting this issue in the JavaMail FAQ?

                      Merry X-mas and happy new year to everyone,
                      Gizmo
                      1 2 Previous Next