6

I'm getting a really weird error on my Windows PC when running mvn package (or mvn install/deploy) on a project. This error only happens on this machine, everything works fine on my laptop and other computers. I used to be able to package/install the project without problems, but now even older commits and branches throw this exception.

java.lang.NumberFormatException: For input string: "34m[[["
    at java.lang.NumberFormatException.forInputString(NumberFormatException java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.<init>(Integer.java:867)
    at org.fusesource.jansi.AnsiOutputStream.write(AnsiOutputStream.java:12)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:125)
    at java.io.PrintStream.write(PrintStream.java:480)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
    at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:282)
    at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:125)
    at java.io.OutputStreamWriter.write(OutputStreamWriter.java:207)
    at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:129)
    at java.io.PrintStream.write(PrintStream.java:526)
    at java.io.PrintStream.print(PrintStream.java:669)
    at java.io.PrintStream.println(PrintStream.java:806)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:423)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

Console error screenshot

I'm using Maven 3.5.2 and Java 1.8.0_91. I already tried reinstalling Maven.

I found this SO post that apparently has a similar problem, but there are no solutions posted.
Anybody have an idea what could cause this?

If I run it with mvn clean install -B it produces the following error for the whole console log:
at org.codehaus.plexus.archiver.AbstractArchiver$1.hasNext(AbstractArchiver.java:467)
(screenshot)

Here's my POM file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>****</groupId>
    <artifactId>sniffer</artifactId>
    <version>0.6-SNAPSHOT</version>

    <name>sniffer</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <packaging>pom</packaging>

    <modules>
        <module>sniffergui</module>
        <module>sniffercollector</module>
        <module>snifferapp</module>
        <module>snifferstats</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.0.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
                <version>4.12.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-launcher</artifactId>
                <version>1.0.1</version>
        </dependency>
        <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-runner</artifactId>
                <version>1.0.1</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>PRISE_gruppe_5_releases</id>
            <name>sniffer_releases</name>
            <url>http://prise-runner.aot.tu-berlin.de:8081/repository/PRISE_gruppe_5_releases/</url>
        </repository>
        <repository>
            <id>PRISE_gruppe_5_snapshots</id>
            <name>sniffer_snapshots</name>
            <url>http://prise-runner.aot.tu-berlin.de:8081/repository/PRISE_gruppe_5_snapshots/</url>
        </repository>
    </repositories>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>3.1.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <effort>Max</effort>
                        <threshold>Low</threshold>
                        <xmlOutput>true</xmlOutput>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-pmd-plugin</artifactId>
                    <version>3.8</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.0</version>
                    <executions>
                        <execution>
                            <id>pre-unit-test</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                            <configuration>
                                <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                                <propertyName>surefireArgLine</propertyName>
                            </configuration>
                        </execution>
                        <execution>
                            <id>post-unit-test</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.19.1</version>
                    <configuration>
                        <argLine>${surefireArgLine}</argLine>
                        <skipTests>${skip.unit.tests}</skipTests>
                        <excludes>
                            <exclude>**/IT*.java</exclude>
                        </excludes>
                    </configuration>
                        <dependencies>
                             <dependency>
                                <groupId>org.junit.platform</groupId>
                                <artifactId>junit-platform-surefire-provider</artifactId>
                                <version>1.0.1</version>
                             </dependency>
                             <dependency>
                                <groupId>org.junit.jupiter</groupId>
                                    <artifactId>junit-jupiter-engine</artifactId>
                                <version>5.0.1</version>
                             </dependency>
                        </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.15</version>
                    <executions>
                        <execution>
                            <id>integration-tests</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <argLine>${failsafeArgLine}</argLine>
                                <skipTests>${skip.integration.tests}</skipTests>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <distributionManagement>
        <repository>
            <id>***_releases</id>
            <name>sniffer_releases</name>
            <url>*****</url>
        </repository>
        <snapshotRepository>
            <id>***_snapshots</id>
            <name>sniffer_snapshots</name>
            <url>*****</url>
        </snapshotRepository>
    </distributionManagement>
</project>
cactus
  • 345
  • 4
  • 13
  • 1
    Can you post your `pom.xml` file? – Tom C Feb 10 '18 at 18:02
  • 2
    Looks like some kind of problem with jansi(used by maven to colorize the output) try running maven in batch mode `-B` option (then it won't show colors) – Oleg Feb 10 '18 at 18:53
  • Do you get this when running mvn package on ANY project? –  Feb 10 '18 at 19:13
  • How exactly have you called Maven ? Via plain command line or from inside IDE ? – khmarbaise Feb 10 '18 at 20:13
  • @TomC I added the pom. The error still appears when running with the -B flag, and I can package other projects (such as the example project on the maven website). – cactus Feb 11 '18 at 14:00
  • @khmarbaise I called maven from windows console (cmd), mvn clean install / mvn package – cactus Feb 11 '18 at 14:02
  • Looks to me like a bug in jansi. Maven uses 1.16 (May 2017). There is a newer version available which includes several changes in [`AnsiOutputStream`](https://github.com/fusesource/jansi/blob/master/jansi/src/main/java/org/fusesource/jansi/AnsiOutputStream.java). It should be worth a try to replace jansi 1.16 with 1.17 in maven and see if this fixes the problem. – Robert Feb 11 '18 at 15:02
  • So going off what @Robert and @Oleg are saying it does seem extremely likely that it is Jansi causing the issue. If you look at the bash output colours you can see that `34m` is the code for `Blue` and looking at your screenshot all the `INFO` logs are `Blue` (https://misc.flogisoft.com/bash/tip_colors_and_formatting) and looking at the Maven 3.5.2 pom.xml they surely do use Jansi 1.16. Whereas the latest version of Maven uses Jansi 1.17, which would explain why other computers are executing `mvn package` fine and this one is not. – Tom C Feb 11 '18 at 15:20
  • Are you sure you used `-B` correctly? It doesn't make sense for you to get the same error, do you still see info in blue with `-B`?. Try adding `-Djansi.passthrough=true` , also try renaming jansi-1.16.jar to something else and see what happens. – Oleg Feb 11 '18 at 16:48
  • @Robert How do I update Jansi? I have downloaded the .jar but I'm not sure what to do with it... Simply placing it in Maven's lib folder and removing the old jar doesn't seem to work – cactus Feb 12 '18 at 17:52
  • @Oleg You are right, it is a different error. I added it to the post (above the pom). When I run it with just the Djansi flag the same error (NumberFormatException) happens. Renaming the jansi jar and/or the jansi-native folder doesn't change anything... It seems Maven creates the folder new and redownloads some dlls? – cactus Feb 12 '18 at 18:07
  • @cactus I'm not 100% on this but something you can try is adding the updated version of `Jansi 1.17` to your main projects `pom.xml` and its possible that all other `pom.xml` files downstream will inherit this version. Worth a shot. https://stackoverflow.com/questions/3937195/maven-how-to-override-the-dependency-added-by-a-library – Tom C Feb 12 '18 at 19:37
  • 4
    Now you have a stack overflow caused by pexus archiver, try increasing the stack. Do `set MAVEN_OPTS=-Xss10M` before running `mvn clean install -B` – Oleg Feb 12 '18 at 23:15
  • @cactus Download the `jansi-1.17.jar`, rename it to `jansi-1.16.jar` and replace the file of the same name in the Maven install wir with the downloaded renamed file. With a little bit of luck it works and with more luck it solves the problem. – Robert Feb 13 '18 at 07:35
  • `set MAVEN_OPTS=-Xss10M` apparently fixes the issue (I have to call this every once in a while but that's ok). All other suggestions did not work. @Oleg if you create an answer with the suggestion I will mark it as answered. Thanks! – cactus Apr 17 '18 at 19:15

3 Answers3

11

As @Oleg said in the comments, set MAVEN_OPTS=-Xss10M seems to fix the issue. It sometimes has to be called again if the error returns. All other options did not solve the problem for me.

cactus
  • 345
  • 4
  • 13
0

Are you running mvn with -T option (multi-thread)?

What you describe sounds like this issue: https://issues.apache.org/jira/browse/MNG-6382

Try to upgrade to maven 3.5.3 see if it solves your problem. The fix for the bug above is in 3.5.3

Kane Ho
  • 119
  • 2
  • 8
0

I found another way apart from Olegs solution (which also works for me) to avoid this bug:

Just pipe the output into a file and the build succeeds:

mvn clean install > build.log
Madjosz
  • 509
  • 1
  • 5
  • 13