Ant: Malformed \uxxxx encoding in propertyfile task

50,694

Solution 1

i know that this question was asked a while ago but i stumbled on it without an answer, on another site i found (http://www.coderanch.com/t/107014/tools/Malformed-uxxxx-encoding-error) i found that this could happen when instead of "\" for file destinations you should be using "/" because of how parsing works/ Hope this helps.

Solution 2

In my case it was maven throwing this error.

[INFO] Building some-prj 1.0.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.508 s
[INFO] Finished at: 2021-08-31T08:00:30-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Malformed \uxxxx encoding.
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

I had to rename the .m2 dir

mv ~/.m2 ~/m2_20210831

and restart maven build

mvn clean package

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  48.927 s
[INFO] Finished at: 2021-08-31T08:04:56-07:00
[INFO] ------------------------------------------------------------------------

Solution 3

Use the double backslash ("\\") like "abc\\user" which is equivalent to "abc\user" and will solve the issue.

Share:
50,694
Michael Niemand
Author by

Michael Niemand

blah

Updated on September 01, 2021

Comments

  • Michael Niemand
    Michael Niemand over 2 years

    I get the error below with an Ant skript I wrote.

    I already did some googling and found out, that the problem lies with strings containing \u, which happens under Windows because of the directory separator. I changed all those to / but the error remains.

    There are definitely no remaining \u strings in my script.

    java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
    

    The error occurs when executing the propertyfile task, so I examined the file I want to change. This on the other hand contains multiple \u strings. The file has no relation to ant though, it's a borland project file (xml) which contains one line like [someParameter]=[someValue].

    I just want to increase [someValue] by 1.

    So my question is:

    Can the property file I want to change cause the error mentioned

    and if the answer is "yes",

    What can I do, other than doing it with a regex task (like finding the line, propertyregex-ing the value, math+1 the value and regex-replacing the value)