Error unmappable character for encoding utf8

This technote explains how to resolve an unmappable character for encoding UTF8 error, that can occur when using IBM Rational Team Concert.

Problem

This technote explains how to resolve an unmappable character for encoding UTF8 error, that can occur when using IBM Rational Team Concert.

Symptom

When preforming a build for Rational Team Concert, the following error is seen: «unmappable character for encoding UTF8», which is due to an inconsistency in encoding types. This can be seen on both Microsoft Windows and Linux, as well as in both the command line and client.

    [<code>]/build/RTC/snipped/StringUtils.java:[34,33] unmappable character for encoding UTF8

Resolving The Problem

To resolve this issue, follow the following steps to resolve the issue, depending on where you received the error message:

  1. When using the Client to preform a build:This is because the character encoding does not match what the client is configured to run using. This can be changed by going to the following section in the Rational Team Concert Client, Window > Preferences > General/Workspace page > Text file encoding section

  2. When using Command Line to preform a build:
    If this error is seen when running a build from the command prompt, try adding the following variables into the command:

    -encoding UTF8

    Example: Command line options:

    -d /build/RTC/wdp_bssview/target/classes -classpath … … -g -nowarn -target 1.6 -source 1.6 -encoding UTF8

  3. When interchanging between Windows and Linux Environments
    This error may also be seen if build files are being constantly exchanged between Windows and Linux Systems. Most Windows systems have en_US.ISO-8859-1 configured as the default encoding. Therefore, special characters don’t map from en_US.ISO-8859-1 to en_US.UTF-8 as expected when compiling. The default character encoding scheme of most Linux systems is en_US.UTF-8 as defined in /etc/sysconfig/i18n. Therefore, if you are coding in Windows, and try to run the build in Linux, you may receive the same error. To solve this, perform the above steps, as well as set the LANG environment variable to en_US.ISO-8859-1:

    export LANG=en_US.ISO-8859-1
    echo $LANG
    en_US.ISO-8859-1

Leverage the Jazz Community

Jazz and Rational Team Concert have an active community that can provide you with additional resources. Browse and contribute to the User forums, contribute to the Team Blog and review the Team wiki.
Refer to technote 1319600 for details and links.

[{«Product»:{«code»:»SSUC3U»,»label»:»IBM Engineering Workflow Management»},»Business Unit»:{«code»:»BU059″,»label»:»IBM Software w/o TPS»},»Component»:»Build»,»Platform»:[{«code»:»PF016″,»label»:»Linux»},{«code»:»PF033″,»label»:»Windows»}],»Version»:»1.0;1.0.1;1.0.1.1;2.0″,»Edition»:»»,»Line of Business»:{«code»:»LOB59″,»label»:»Sustainability Software»}}]

Historical Number

29019;004;000

Product Synonym

Rational Team Concert

Configure the maven-compiler-plugin to use the same character encoding that your source files are encoded in (e.g):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <source>1.6</source>
        <target>1.6</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

Many maven plugins will by default use the «project.build.sourceEncoding» property so setting this in your pom will cover most plugins.

<project>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
...

However, I prefer setting the encoding in each plugin’s configuration that supports it as I like to be explicit.

When your source code is compiled by the maven-compiler-plugin your source code files are read in by the compiler plugin using whatever encoding the compiler plugin is configured with. If your source files have a different encoding than the compiler plugin is using then it is possible that some characters may not exist in both encodings.

Many people prefer to set the encoding on their source files to UTF-8 so as to avoid this problem. To do this in Eclipse you can right click on a project and select Properties->Resource->Text File Encoding and change it to UTF-8. This will encode all your source files in UTF-8. (You should also explicitly configure the maven-compiler-plugin as mentioned above to use UTF-8 encoding.) With your source files and the compiler plugin both using the same encoding you shouldn’t have any more unmappable characters during compilation.

Note, You can also set the file encoding globally in eclipse through Window->Preferences->General->Workspace->Text File Encoding. You can also set the encoding per file type through Window->Preferences->General->Content Types.

I came across this problem just now and ended up resolving it like so: I opened up the offending .java file in Notepad++ and from the Encoding menu I selected «Convert to UTF-8 without BOM». Saved. Re-ran maven, all went through ok.

If the offending resource was not encoded in UTF-8 — as you have configured for your maven compiler plugin — you would see in the Encoding menu of Np++ a bullet mark next to the file’s current encoding (in my case I saw it was set to «Encode in ANSI»).

So your maven compiler plugin invoked the Java compiler with the -encoding option set to UTF-8, but the compiler encountered a ANSI-encoded source file and reported this as an error. This used to be a warning previously in Java 5 but is treated as an error in Java 6+

If the above answer does not work, change the encoding to cp1252 or manually remove all occurrences of the special character. For me � special character was causing the prob which was inside a comment block.

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <version>2.3.2</version>
   <configuration>
       <encoding>Cp1252</encoding>
   </configuration> 
</plugin>

PS:I was using GNU/Linux OS(Ubuntu).

Проблема:

В проекте используется jaxws-maven-plugin версии 2.1, генерирующий классы по WSDL. В WSDL и импортируемой в неё схеме есть русские буквы в аннотациях. При сборке проекта при компиляции возникают ошибки «unmappable character for encoding UTF-8» при попытке скомпилировать сгенерированные классы. ОС — Windows, кодировка исходников проекта — UTF-8.

Проект использует кодировку исходников UTF-8. wsimport генерирует исходники в cp1251 (в системной кодировке), причем они содержат русские символы в комментариях, пришедшие туда из аннотаций к XSD-схеме.

В отличие от wsimport`а версии 2.2, опции «encoding», позволяющей задать кодировку целевых файлов, нет. Нет такой опции и у используемого им xjc (эту опцию можно было бы передать ему через опцию -B<xjcoption> wsimport`а).

Как ни странно, помогла установка параметра xnocompile в false:

<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<!— … —>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>false</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>

Также xnocompile можно установить в false не в конфигурации всего плагина, а внутри конфигурации execution`а, эффект тот же:

<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
 <execution>
<goals>
 <goal>wsimport</goal>
</goals>
<configuration>
 <xnocompile>false</xnocompile>
 <!— … —>
</configuration>
<!— … —>
 </execution>
</executions>
<!— … —>
</plugin>

Генерируемые исходники все также в cp1251, но компиляция проходит. Есть идея, что это происходит потому, что сгенерированные файлы компилируются сразу wsimport`ом, и в этом случае компилятор не обращает внимание на кодировку файлов проекта (посколько о ней не знает), а читает исходники в системной кодировке, в какой они и действительно закодированы.

Понравилась статья? Поделить с друзьями:
  • Error unknown worker error перевод
  • Error unknown wim esd file
  • Error windows route add command failed adaptive returned error code
  • Error windows kernel power
  • Error windows 10 0x800f081f windows