5

I am having a Maven-Project which is configured using the following properties:

<properties>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>

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

On my machine everything works fine with these settings. However, on another machine, when I check it out and try to build it using mvn install the compiler errors unmappable character for encoding ASCII:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project scuttle: Compilation failure: Compilation failure:
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/handlers/sakai/SakaiVV.java:[99,39] error: unmappable character for encoding ASCII
[ERROR] 
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/handlers/sakai/SakaiVV.java:[99,40] error: unmappable character for encoding ASCII
[ERROR] 
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/domain/sakai/SakvvTermin.java:[66,30] error: unmappable character for encoding ASCII
[ERROR] 
[ERROR] /export/local-1/julian-downloads/scuttle/src/main/java/de/fu/mi/scuttle/domain/sakai/SakvvTermin.java:[66,31] error: unmappable character for encoding ASCII

I've already tried running mvn with -Dfile.encoding=UTF-8 but that did not help. $LC_CTYPE reports UTF-8.

What can I do?

You can see the complete pom file here: https://github.com/scravy/scuttle/blob/master/pom.xml

3
  • Are you 100% sure that your sources are UTF-8 encoded? Possibly, they are not, but it works in your environment for some reason (maybe your IDE interferes)
    – sola
    Commented Oct 21, 2013 at 13:41
  • 3
    Please update your maven-compiler-version cause 2.0.2 is really old. Currently we have 3.1..
    – khmarbaise
    Commented Oct 21, 2013 at 16:59
  • Have same issue with default maven-compiler plug-in v2.0.2. Increasing version solve issue.
    – gavenkoa
    Commented Mar 12, 2015 at 17:12

3 Answers 3

10

In the end the comment by khmarbaise helped me find a solution:

I configured the compiler plugin and specified the source encoding there, now everything works everywhere:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.3.2</version>
      <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <encoding>UTF-8</encoding>
      </configuration>
    </plugin>
  </plugins>
</build>
1
  • 1
    Great that you found the solution to your problem yourself !
    – Saif Asif
    Commented Dec 17, 2013 at 9:17
2

You have all the right settings in your pom, so that's good. Verify your IDE (and the others used by your team if applicable) is configured for UTF-8.

Next, clean out your local .m2 repository and run your build again. It might be possible one of your transitive dependencies wasn't compiled with the right encoding. But you may have the "right" version in your .m2 that makes everything OK while the same version doesn't exist on the other machine.

Good luck! I know how annoying this stuff can be.

1

Instead of setting maven opts, set new environmental variable - JAVA_TOOL_OPTIONS = -Dfile.encoding=UTF8

Not the answer you're looking for? Browse other questions tagged or ask your own question.