“负时间"指的是“负时间".使用Maven进行构建时出错(在Netbeans中) [英] "Negative time" error when building with Maven (in Netbeans)

查看:93
本文介绍了“负时间"指的是“负时间".使用Maven进行构建时出错(在Netbeans中)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Netbeans 8.0.2(3.0.5)中使用Maven时,出现以下(奇怪)错误:

Using Maven inside Netbeans 8.0.2 (3.0.5) I get the following (strange) error:

Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project JConnect4Server: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Negative time -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:war (default-war) on project JConnect4Server: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Negative time
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-war of goal org.apache.maven.plugins:maven-war-plugin:2.3:war failed: Negative time
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:110)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
    ... 19 more
Caused by: java.lang.IllegalArgumentException: Negative time
    at java.io.File.setLastModified(File.java:1427)
    at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:306)
    at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask$1.registered(AbstractWarPackagingTask.java:152)
    at org.apache.maven.plugin.war.util.WebappStructure.registerFile(WebappStructure.java:211)
    at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFile(AbstractWarPackagingTask.java:147)
    at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFiles(AbstractWarPackagingTask.java:105)
    at org.apache.maven.plugin.war.packaging.AbstractWarPackagingTask.copyFiles(AbstractWarPackagingTask.java:127)
    at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.handeWebAppSourceDirectory(WarProjectPackagingTask.java:174)
    at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.performPackaging(WarProjectPackagingTask.java:92)
    at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:479)
    at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:412)
    at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:213)
    at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:175)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
    ... 20 more

首先,错误消息对我来说毫无意义-但真正奇怪的是,在命令行上构建和打包应用程序工作正常,只有在Netbeans 8.0.2中调用Maven时才会出现问题.

First of all the error message makes no sense to me - but what is really strange is that building and packaging the application on commandline just works out fine, the problem occurs only when Maven gets called within Netbeans 8.0.2.

pom本身看起来像这样:

The pom itself looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<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>de.dhbw.mbfl</groupId>
    <artifactId>JConnect4Server</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>JConnect4Server</name>

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

    <repositories>
        <repository>
            <id>sa_viergewinnt_core-mvn-repo</id>
            <url>https://raw.github.com/FlorianLoch/sa_viergewinnt_core/gh-pages/</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </snapshots>
        </repository>
    </repositories>    

    <dependencies>
        <dependency>
            <groupId>de.dhbw.mbfl</groupId>
            <artifactId>JConnect4Lib</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>        
        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

还有更多经验丰富的Maven用户可以帮助我吗?

Is there any more experienced Maven user who can help me?

谢谢.

更新:Netbeans和Maven使用的JDK是:1.8.0_25,在VM外部使用的JDK(在这种情况下,打包工作很好)是1.8.0_31(我读了一些有关这是否可能是JDK错误的信息...)

Update: JDK used by Netbeans and Maven is: 1.8.0_25, JDK used outside the VM (where packaging works just fine) is 1.8.0_31 (I read some stuff on whether this might be a JDK bug...).

更新:我更新了VM中的JDK,错误保持不变.

Update: I updated the JDK in the VM, the error stays the same.

推荐答案

好的,看来我发现了错误.它是由JDK错误/问题导致的,导致FileNotFound-Exception.这也可以解释为什么只是使用Windows会发生错误.

Ok, it seems I found the error. It is caused by a JDK bug/problem resulting in a FileNotFound-Exception. This would also explain why the error just occurs using Windows.

简单地说,它只是行不通,因为文件路径中只有一个空格...因此移动项目可以解决此问题.在Mac OS上使用时,不会发生此问题.

To put it simply, it just didn't work because there is a single space in the path of the files... So moving the project solves the problem. Working with Mac OS the problem doesn't occur.

这篇关于“负时间"指的是“负时间".使用Maven进行构建时出错(在Netbeans中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆