在“正在更新Maven项目”期间发生内部错误。显示java.lang.NullPointerException

时间:2013-10-22 16:03:16

标签: eclipse maven java-ee m2eclipse

我正在开发一个Java EE Web项目。当我尝试添加依赖项时,会出现此错误消息。我使用Eclipse Kepler。

  

在“正在更新Maven项目”期间发生内部错误。显示java.lang.NullPointerException

你可以帮帮我吗? 谢谢。

enter image description here

20 个答案:

答案 0 :(得分:139)

我通过删除项目中的.settings文件夹和.project文件然后重新导入项目来解决我的问题。

答案 1 :(得分:24)

对我来说,我在CodeRanch上找到了用户 Maneesh Godbole 的答案:

  
      
  1. 关闭日食。
  2.   
  3. 导航到您的"工作区"夹
  4.   
  5. 确保已启用操作系统上的设置以查看隐藏文件
  6.   
  7. 识别并删除.metadata目录
  8.   
  9. 重启eclipse
  10.   
  11. 导入项目
  12.   

答案 2 :(得分:5)

我的一个模块中遇到了同样的问题。

在console / cmd中运行“mvn eclipse:eclipse”为我解决了这个问题。

答案 3 :(得分:3)

在我们这个问题的实例中,我们有System.config({ baseURL: "./", defaultJSExtensions: true, transpiler: "babel", babelOptions: { "optional": [ "runtime", "optimisation.modules.system" ] }, paths: { "github:*": "jspm_packages/github/*", "npm:*": "jspm_packages/npm/*" }, buildCSS: true, separateCSS: true, map: { "AngularStompDK": "github:davinkevin/AngularStompDK@0.3.2", "angular": "github:angular/bower-angular@1.4.7", "angular-animate": "github:angular/bower-angular-animate@1.4.7", "angular-bootstrap": "github:angular-ui/bootstrap-bower@0.14.3", "angular-hotkeys": "github:chieffancypants/angular-hotkeys@1.4.5", "angular-loading-bar": "github:chieffancypants/angular-loading-bar@0.8.0", "angular-mocks": "npm:angular-mocks@1.4.7", "angular-notification": "github:neoziro/angular-notification@1.1.1", "angular-route": "github:angular/bower-angular-route@1.4.7", "angular-sanitize": "github:angular/bower-angular-sanitize@1.4.7", "angular-touch": "github:angular/bower-angular-touch@1.4.7", "angular-truncate": "github:sparkalow/angular-truncate@master", "animate.css": "github:daneden/animate.css@3.4.0", "babel": "npm:babel-core@5.8.25", "babel-runtime": "npm:babel-runtime@5.8.25", "bootstrap-less": "github:distros/bootstrap-less@3.3.9", "clean-css": "npm:clean-css@3.4.6", "core-js": "npm:core-js@1.2.2", "css": "github:systemjs/plugin-css@0.1.19", "font-awesome": "github:components/font-awesome@4.4.0", "highcharts-ng": "github:pablojim/highcharts-ng@0.0.11", "highcharts-release": "github:highslide-software/highcharts-release@4.1.9", "ionicons": "github:driftyco/ionicons@2.0.1", "lodash": "github:lodash/lodash@3.10.1", "ng-file-upload": "github:danialfarid/ng-file-upload@9.1.1", "ng-tags-input": "github:mbenford/ngTagsInput@3.0.0", "ngstorage": "github:gsklee/ngStorage@0.3.9", "pablojim/highcharts-ng": "github:pablojim/highcharts-ng@0.0.11", "restangular": "github:mgonto/restangular@1.5.1", "sockjs-client": "github:sockjs/sockjs-client@0.3.4", "stomp-websocket": "github:jmesnil/stomp-websocket@2.3.4", "systemjs/plugin-text": "github:systemjs/plugin-text@0.0.2", "text": "github:systemjs/plugin-text@0.0.2", "videogular": "github:2fdevs/bower-videogular@1.3.2", "videogular-buffering": "github:2fdevs/bower-videogular-buffering@1.3.2", "videogular-controls": "github:2fdevs/bower-videogular-controls@1.3.2", "videogular-overlay-play": "github:2fdevs/bower-videogular-overlay-play@1.3.2", "videogular-poster": "github:2fdevs/bower-videogular-poster@1.3.2", "videogular-themes-default": "github:2fdevs/bower-videogular-themes-default@1.3.2", "github:angular/bower-angular-animate@1.4.7": { "angular": "github:angular/bower-angular@1.4.7" }, "github:angular/bower-angular-route@1.4.7": { "angular": "github:angular/bower-angular@1.4.7" }, "github:angular/bower-angular-sanitize@1.4.7": { "angular": "github:angular/bower-angular@1.4.7" }, "github:angular/bower-angular-touch@1.4.7": { "angular": "github:angular/bower-angular@1.4.7" }, "github:chieffancypants/angular-hotkeys@1.4.5": { "angular": "github:angular/bower-angular@1.4.7" }, "github:chieffancypants/angular-loading-bar@0.8.0": { "angular": "github:angular/bower-angular@1.4.7", "css": "github:systemjs/plugin-css@0.1.19" }, "github:distros/bootstrap-less@3.3.9": { "jquery": "github:components/jquery@2.1.4" }, "github:jspm/nodelibs-assert@0.1.0": { "assert": "npm:assert@1.3.0" }, "github:jspm/nodelibs-buffer@0.1.0": { "buffer": "npm:buffer@3.5.1" }, "github:jspm/nodelibs-events@0.1.1": { "events": "npm:events@1.0.2" }, "github:jspm/nodelibs-http@1.7.1": { "Base64": "npm:Base64@0.2.1", "events": "github:jspm/nodelibs-events@0.1.1", "inherits": "npm:inherits@2.0.1", "stream": "github:jspm/nodelibs-stream@0.1.0", "url": "github:jspm/nodelibs-url@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, "github:jspm/nodelibs-https@0.1.0": { "https-browserify": "npm:https-browserify@0.0.0" }, "github:jspm/nodelibs-os@0.1.0": { "os-browserify": "npm:os-browserify@0.1.2" }, "github:jspm/nodelibs-path@0.1.0": { "path-browserify": "npm:path-browserify@0.0.0" }, "github:jspm/nodelibs-process@0.1.2": { "process": "npm:process@0.11.2" }, "github:jspm/nodelibs-stream@0.1.0": { "stream-browserify": "npm:stream-browserify@1.0.0" }, "github:jspm/nodelibs-url@0.1.0": { "url": "npm:url@0.10.3" }, "github:jspm/nodelibs-util@0.1.0": { "util": "npm:util@0.10.3" }, "github:mbenford/ngTagsInput@3.0.0": { "angular": "github:angular/bower-angular@1.4.7", "css": "github:systemjs/plugin-css@0.1.19" }, "github:mgonto/restangular@1.5.1": { "angular": "github:angular/bower-angular@1.4.7", "lodash": "npm:lodash@3.10.1" }, "npm:amdefine@1.0.0": { "fs": "github:jspm/nodelibs-fs@0.1.2", "module": "github:jspm/nodelibs-module@0.1.0", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:assert@1.3.0": { "util": "npm:util@0.10.3" }, "npm:babel-runtime@5.8.25": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:buffer@3.5.1": { "base64-js": "npm:base64-js@0.0.8", "ieee754": "npm:ieee754@1.1.6", "is-array": "npm:is-array@1.0.1" }, "npm:clean-css@3.4.6": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "commander": "npm:commander@2.8.1", "fs": "github:jspm/nodelibs-fs@0.1.2", "http": "github:jspm/nodelibs-http@1.7.1", "https": "github:jspm/nodelibs-https@0.1.0", "os": "github:jspm/nodelibs-os@0.1.0", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", "source-map": "npm:source-map@0.4.4", "url": "github:jspm/nodelibs-url@0.1.0", "util": "github:jspm/nodelibs-util@0.1.0" }, "npm:commander@2.8.1": { "child_process": "github:jspm/nodelibs-child_process@0.1.0", "events": "github:jspm/nodelibs-events@0.1.1", "fs": "github:jspm/nodelibs-fs@0.1.2", "graceful-readlink": "npm:graceful-readlink@1.0.1", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:core-js@1.2.2": { "fs": "github:jspm/nodelibs-fs@0.1.2", "path": "github:jspm/nodelibs-path@0.1.0", "process": "github:jspm/nodelibs-process@0.1.2", "systemjs-json": "github:systemjs/plugin-json@0.1.0" }, "npm:core-util-is@1.0.1": { "buffer": "github:jspm/nodelibs-buffer@0.1.0" }, "npm:graceful-readlink@1.0.1": { "fs": "github:jspm/nodelibs-fs@0.1.2" }, "npm:https-browserify@0.0.0": { "http": "github:jspm/nodelibs-http@1.7.1" }, "npm:inherits@2.0.1": { "util": "github:jspm/nodelibs-util@0.1.0" }, "npm:lodash@3.10.1": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:os-browserify@0.1.2": { "os": "github:jspm/nodelibs-os@0.1.0" }, "npm:path-browserify@0.0.0": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:process@0.11.2": { "assert": "github:jspm/nodelibs-assert@0.1.0" }, "npm:punycode@1.3.2": { "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:readable-stream@1.1.13": { "buffer": "github:jspm/nodelibs-buffer@0.1.0", "core-util-is": "npm:core-util-is@1.0.1", "events": "github:jspm/nodelibs-events@0.1.1", "inherits": "npm:inherits@2.0.1", "isarray": "npm:isarray@0.0.1", "process": "github:jspm/nodelibs-process@0.1.2", "stream-browserify": "npm:stream-browserify@1.0.0", "string_decoder": "npm:string_decoder@0.10.31" }, "npm:source-map@0.4.4": { "amdefine": "npm:amdefine@1.0.0", "process": "github:jspm/nodelibs-process@0.1.2" }, "npm:stream-browserify@1.0.0": { "events": "github:jspm/nodelibs-events@0.1.1", "inherits": "npm:inherits@2.0.1", "readable-stream": "npm:readable-stream@1.1.13" }, "npm:string_decoder@0.10.31": { "buffer": "github:jspm/nodelibs-buffer@0.1.0" }, "npm:url@0.10.3": { "assert": "github:jspm/nodelibs-assert@0.1.0", "punycode": "npm:punycode@1.3.2", "querystring": "npm:querystring@0.2.0", "util": "github:jspm/nodelibs-util@0.1.0" }, "npm:util@0.10.3": { "inherits": "npm:inherits@2.0.1", "process": "github:jspm/nodelibs-process@0.1.2" } } }); 个文件,其中m2e特定的生命周期映射配置

pom.xml

没有<pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> ... 部分。在做Maven时 - &gt;更新项目...,这会导致报告的NullPointerException没有堆栈跟踪。使用新鲜的导入时...... - &gt;现有的Maven项目发生了同样的异常,但是有一个堆栈跟踪导致我找到了上面的内容。

(这与Eclipse Luna Service Release 2(4.4.2)中的m2e 1.6.1.20150625-2338有关。)

答案 4 :(得分:2)

如果它对任何人有帮助,除了删除.settings.project之外,我还必须删除.classpath.factorypath才能将项目成功导入Eclipse

答案 5 :(得分:1)

org.eclipse.m2e.core.prefs 文件位于 .settings 文件夹中。如果你遇到

的问题

An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException

从eclipse中删除项目,然后删除 .settings 文件夹&amp;项目中的 .project 文件 - &gt;然后重新导入项目。

答案 6 :(得分:1)

这帮助了我:Project menu -> Clean... -> clean all projects

答案 7 :(得分:1)

删除本地maven存储库帮助我

答案 8 :(得分:1)

Eclipse有一个错误日志。在那里,您将看到完整的堆栈跟踪。在我的情况下,它似乎是由一个坏的jar文件与java.util.zip libs组合引起的,而不是抛出一个正确的异常,只是一个NullPointerException。

答案 9 :(得分:1)

我正在使用:

面向Web开发人员的Eclipse Java EE IDE。

版本:Neon.3发布(4.6.3) 构建ID:20170314-1500

我的修复/技巧是删除〜/ .m2 / repository中的本地存储库,以便删除本地依赖项并重建我的项目,其中新的依赖项被删除。

答案 10 :(得分:0)

上述方法均不适合我。这也可能是由于eclipse工作区中存在循环依赖性而引起的。因此,如果工作区中的任何其他项目中存在任何其他错误,请尝试修复这些错误,然后此问题将消失。这就是我如何消除错误。

答案 11 :(得分:0)

我在多个项目和多个工作空间中遇到了同样的问题,我在网上找到的解决方案都没有为我工作。我使用STS,唯一有用的是进入我的STS目录并添加一个&#34; -clean&#34;到STS.ini文件的顶部。然后,您可以启动工作区并运行maven clean而不会出错。 (您也可以从ini文件中删除-clean标记,以便每次启动时都不会清除它)

希望这有助于某人。

答案 12 :(得分:0)

我的案例中的root问题是.settings文件夹中的文件冲突。因此,删除.settings文件夹会解决Maven错误,但我想保留一些本地配置文件。我解决了冲突,然后再次尝试了Maven更新并且它有效。

答案 13 :(得分:0)

我有同样的问题......最后的解决方案!

这里是日食日志:

java.lang.NullPointerException
    at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.getGaeRuntime(GaeRuntimeManager.java:85)
    at com.google.appengine.eclipse.wtp.maven.GaeRuntimeManager.ensureGaeRuntimeWithSdk(GaeRuntimeManager.java:55)
    at com.google.appengine.eclipse.wtp.maven.GaeFacetManager.addGaeFacet(GaeFacetManager.java:59)
    at com.google.appengine.eclipse.wtp.maven.GaeProjectConfigurator.configure(GaeProjectConfigurator.java:46)

...它来自“appengine maven wtp plugin”试图获取GAE运行时的类型,但在这里似乎是空的(... getRuntimeType() - &gt; NPE):

请参阅课程com.google.appengine.eclipse.wtp.maven/GaeRuntimeManager.java

  private static IRuntime getGaeRuntime(String sdkVersion) {
    IRuntime[] runtimes = ServerCore.getRuntimes();
    for (IRuntime runtime : runtimes) {
      if (runtime != null &&  **runtime.getRuntimeType()**.equals(GAE_RUNTIME_TYPE)) {

因此,如果您检查eclipse,Google App Engine是可见的,但是当您选择它时,您将看到没有关联的SDK ... preference/Server/Runtime environments

<强>解: 屏幕截图中的红色; - )

答案 14 :(得分:0)

我遇到了同样的问题。这里的解决方案都没有奏效。我不得不完全重新安装eclipse并创建一个新的工作区。然后它奏效了!

答案 15 :(得分:0)

我遇到了同样的症状,上述解决方案都没有帮助。我终于通过将ear项目再次导入eclipse得到了问题的堆栈跟踪,并且能够将其追溯到org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement,它试图删除windows中的目录。 temp目录名为&#34; .mavenDeploymentDescriptorManagement&#34;,它从java.io.File.exists()方法中引起了一个无理的NullPointerException,特别是因为代码已经在先前的方法中使用相同的变量成功完成了相同的操作,然后调用file.isFile()没有问题。

在文件系统上检查此信息表明该文件只能以管理员权限访问。显然,我曾经错误地从管理员控制台启动了eclipse。 最后,我只是在Windows资源管理器中显示隐藏文件并手动删除了临时文件,这解决了问题。

答案 16 :(得分:0)

问题的另一个可能来源!

我发现在我的情况下,导致它的是以下resource块:

<project>
    <build>
        <resources>
            <resource>
                <directory>${basedir}/../some-folder</directory>
                <targetPath>outputFolder</targetPath>
            </resource>
        <resources>
    </build>
</project>

它包含项目文件夹中的文件夹( eclipse项目是版本化的项目文件夹的子文件夹)。

在我的情况下,我可以删除阻止并通过调用Build helper Maven插件替换它来删除错误:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.9.1</version>
            <executions>
                <execution>
                    <id>my-own-very-cool-id-for-this-step</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>add-resource</goal>
                    </goals>
                    <configuration>
                        <resources>
                            <resource>
                                <directory>${basedir}/../some-folder</directory>
                                <targetPath>outputFolder</targetPath>
                            </resource>
                        </resources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

答案 17 :(得分:0)

我不得不重新安装eclipse,删除.m2文件夹并重建jar。

答案 18 :(得分:0)

在我的情况下,问题是其他依赖关系使用了派生依赖关系的冲突,并且某些派生依赖关系版本不可用,可能是因为我忘了做一些部署,因为在工作空间分辨率下一切正常,但是当转移到其他环境时,一切突然崩溃了。 而且我也在使用版本范围

行家给我这个错误:

  

无法解决项目的依赖关系   MyProject:MyProject:jar:1.0.0:无法解决版本冲突   依赖关系A:1.0.1->依赖关系B:1.1.0->    Dependency-C:1.0.0 ,Dependency-X:1.0.1-> Dependency-Y:1.1.0-> Dependency-C:1.0.0 ,Dependency- I:1.0.1-> Dependency-J:1.1.0-> Dependency-C:1.0.0

我尝试了以上所有方法,但没有任何效果,所以...

  

解决方案:在所有依赖项中使用LATEST作为版本,因此maven不需要解析范围内的所有依赖项,必须使用   小心,因为如果您错过部署其中一个依赖项,   构建将失败

仅当您使用自己的依赖项时,才建议您使用LATEST,否则在某些第三方将来的版本中,您可能会发现一些编译或运行时错误

答案 19 :(得分:0)

上述解决方案不适用于我,因为开放JDK 13版本存在问题 https://github.com/spotify/dockerfile-maven/issues/163 所以我降级为打开JDK8,它对我有用

相关问题