简体   繁体   中英

Maven NumberFormatException when packaging

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>

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM