11

Whenever I start our Apache Felix (OSGi) based application under SUN Java ( build 1.6.0_10-rc2-b32 and other 1.6.x builds) I see the following message output on the console (usually under Ubuntu 8.4):

Warning: The encoding 'UTF-8' is not supported by the Java runtime.

I've seen this message display occasionally when running both Tomcat and Resin as well. If java supports unicode and UTF-8, what causes this message? I've yet to find any reference, or answer to this anywhere else.

Mark Derricutt
  • 959
  • 1
  • 10
  • 20
  • Strange. UTF-8 is a required encoding. No one should release a Java runtime that doesn't include UTF-8 and US-ASCII. – erickson Oct 07 '08 at 06:17
  • Could it be something lacking in the underlying OS? – skaffman Oct 07 '08 at 07:26
  • No one should be using an RC build on a production system either :) – Michael Borgwardt Jul 28 '09 at 10:31
  • whose implementation of java is this ? which version of java ? which java apps (did you write them or are they an open source app we know of) ? – anjanb Oct 07 '08 at 04:47
  • I got the same message. Different environment. I found that it was coming from the transform method of Transformer when the implementation of Transformer is com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl. – John Snyders Dec 03 '08 at 19:23
  • I just got the same error message when starting PyCharm 3.1.3. Not sure it has any negative consequences while running the IDE though. – user1603472 May 12 '14 at 14:41

6 Answers6

12

According the documentation "Every implementation of the Java platform is required to support the following standard charsets... US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, UTF-16." So I doubt that Sun have released a build without UTF-8 support.

The actual error message appears to be from here, which is part of the Xerces XML parser. I imagine it is the XML parser where the problem is occurring.

Dan Dyer
  • 51,823
  • 16
  • 125
  • 165
  • 3
    The problem in my instance arose from the usage of OSGi and class-loader visibility. Multiple bundles instantiated the Xerces XML parser, but failed to find character set definitions as those resources were not visible. – Mark Derricutt Mar 02 '09 at 03:23
  • Please give the packages that were not visible. Which packages did you have to make visible? – Mike Pone Sep 09 '11 at 19:33
  • 2
    If this is solution, how it solved the problem? Could you please specify what you have done? The problem occures in Fuse ESB 4.4 in logging system. – Danubian Sailor Sep 28 '11 at 08:21
  • Yep, I can attest this comes from Xerces... but I can't find any real fix or workaround. – Chucky Dec 15 '11 at 17:30
7

Try the following program:

import java.nio.charset.Charset;

public class TestCharset {
    public static void main(String[] args) {
        System.out.println(Charset.forName("UTF-8"));
    }
}

If this throws an exception, then there is something wrong with your JDK. If it prints "UTF-8" then your JDK is OK, and your application is doing something odd.

If that's the case, run your app under the debugger, and put a breakpoint in http://www.java2s.com/Open-Source/Java-Document/XML/xalan/org/apache/xml/serializer/ToStream.java.htm --that's the place this warning is produced, and step to see why Xalan can't find the encoding.

tgdavies
  • 5,328
  • 3
  • 28
  • 34
2

Most probably someone put a catch() expecting to have only unsupported encoding exceptions, so he used the appropriate message. But he has used too wide exception specification (e.g. catch( Exception ex ) ), so when at runtime he's got something else (non-valid XML, NPE, ... ) the message became misleading.

Vladimir Dyuzhev
  • 17,603
  • 9
  • 45
  • 61
0

Try a different (stable release) JVM. I had this problem once and it turned out that the machine was running a beta version JVM that indeed did not support UTF-8, contrary to the requirement in the API docs.

Michael Borgwardt
  • 327,225
  • 74
  • 458
  • 699
0

If you are getting this message when using a Transformer, try to specify the TransformerFactory:

link

Community
  • 1
  • 1
Andrew
  • 1
0

It should be "UTF8", without the dash.

Michael Myers
  • 178,094
  • 41
  • 278
  • 290
Pavel
  • 9
  • 1