32

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)

Michael Niemand
  • 1,578
  • 3
  • 23
  • 39

14 Answers14

62

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.

Andrewprogram
  • 673
  • 6
  • 8
60

go to your .m2 directory in home directory and for every dependence delete the "resolver-status.properties". You can do that using

find ~/.m2/ -name resolver-status.properties -delete

It will find all "resolver-status.properties" and -delete flag will delete them.

Now reload maven project.

mahipalkeizer
  • 781
  • 4
  • 8
  • 3
    This worked, Thanks for sharing. but can you please explain why this worked ? – Chetan acharekar Jul 06 '22 at 13:30
  • 2
    @Chetanacharekar I got malformed issue in one of my dependency while running install in Intellij, i deleted that one resolver-status.properties file. After that i got issue with same file in another dependency. So i ran this command to delete all such resolver-status.properties files and it worked. – mahipalkeizer Jan 24 '23 at 07:59
  • 1
    No idea why this worked but it did, thanks @mahipalkeizer – bbnt Feb 14 '23 at 17:48
12

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] ------------------------------------------------------------------------
Anand Rockzz
  • 6,072
  • 5
  • 64
  • 71
  • 1
    The currently selected solution (with most upvotes) did not solve the issue for me; Nuking the ~/.m2 directory, as suggested here did though. Must have been a corrupted package or something. – metasoarous Sep 14 '21 at 05:28
  • This is solved the issue for me. – Sree Feb 08 '22 at 23:48
8

You go in .m2 and search resolver-status.properties after then delete all files related and re-build your project. It will build success.

enter image description here

lemon
  • 14,875
  • 6
  • 18
  • 38
5

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

3

grep -lrnw ~/.m2 -e '\u0000' | xargs rm

searches your m2 folder for malformed files and deletes them.

then reload maven project.

Amber Kulkarni
  • 424
  • 8
  • 17
1

deleting all the "resolver-status.properties" files and re-building the project worked

Zann
  • 11
  • 5
1

Open the .m2 folder and search for resolver-status.properties. Then, delete all files related to that search. Finally do a clean install using Maven.

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25
Amit Gore
  • 11
  • 1
0

first you should try running the ant script with the debug flag to determine which file is causing the issue in Eclipse you do this by going to

Run > External Tools > External Tools Configurations... > Main 

and adding "-d" (without the quotes) to "Arguments"

then try editing the file in Eclipse as some editors (e.g. "Wordpad") may mess up the file

Jens Bayer
  • 41
  • 3
0

Actually I found out that the problem is due to the local.cfg file encoding. If we created(edited) the local.cfg file using wordpad or other non code editing software, it changes the file encoding. So when ant tries to load the local configuration file ( due to the line in the dspace-installer/ build.xml file, it expects ASCII character encoded, .cfg file. So when it gets the UTF encoded file the exception raises. Solution: remove the local.cfg file, create it again using a code editing softwares like Visual Studio code or other, and edit/write the necessary configuration settings.

enter image description here

ochs.tobi
  • 3,214
  • 7
  • 31
  • 52
0

Renaming my Repository folder in C:\Users\\{user-name}\\.m2 and running the command again worked for me.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31
0

I found a concrete dependency causing this annoying error. I had

<!-- https://mvnrepository.com/artifact/org.ops4j.pax.exam/pax-exam-junit4 -->
<dependency>
    <groupId>org.ops4j.pax.exam</groupId>
    <artifactId>pax-exam-junit4</artifactId>
    <version>4.13.5</version>
    <scope>test</scope>
</dependency>

After replacing it by:

<!-- https://mvnrepository.com/artifact/org.ops4j.pax.exam/pax-exam-junit4 -->
<dependency>
        <groupId>org.ops4j.pax.exam</groupId>
        <artifactId>pax-exam-junit4</artifactId>
        <version>4.1.0.redhat-1</version>
        <scope>test</scope>
</dependency>

The error disappeared.

Itamar cohen
  • 59
  • 1
  • 5
0

I found that clearing my local maven cache (the "repository" folder inside of ".m2") solved the problem for me.

There are some suggestions here to rename/delete the whole .m2 folder, but that would get rid of your settings.xml file.

Jon Onstott
  • 13,499
  • 16
  • 80
  • 133
0

If this issue is related to maven then we can simply delete "repository folder" in ".m2" directory/path and trigger build for the project again. It should give a build success after it.

Neha
  • 1