JavaEar 专注于收集分享传播有价值的技术资料

在" 正在更新Maven项目" 期间发生内部错误。显示java.lang.NullPointerException (An internal error occurred during: "Updating Maven Project". java.lang.NullPointerException)

问题描述


英文原文

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.

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

Could you help me? Thank you.

enter image description here


中文翻译

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.

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

Could you help me? Thank you.

enter image description here

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.

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

Could you help me? Thank you.

enter image description here

I'm developing a Java EE web project. When I try to add a dependency, this error message appears. I use Eclipse Kepler.

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

Could you help me? Thank you.

enter image description here

17个回答

    最佳答案

  1. 英文原文

    I've had the same problem in one of my modules.

    Running "mvn eclipse:eclipse" in the console/cmd solved the problem for me.


    中文翻译

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

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

    I've had the same problem in one of my modules.

    Running "mvn eclipse:eclipse" in the console/cmd solved the problem for me.

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

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

  2. 参考答案2

  3. 英文原文

    In our instance of this problem, we had pom.xml files where the m2e-specific life cycle mapping configuration

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
    ...
    

    did not have the <version>1.0.0</version> part. When doing a Maven -> Update Project..., this causes the reported NullPointerException without a stack trace. When using a fresh Import... -> Existing Maven Projects, the same exception occurred, but with a stack trace that led me to find the above.

    (This is with m2e 1.6.1.20150625-2338 in Eclipse Luna Service Release 2 (4.4.2).)


    中文翻译

    In our instance of this problem, we had pom.xml files where the m2e-specific life cycle mapping configuration

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
    ...
    

    did not have the <version>1.0.0</version> part. When doing a Maven -> Update Project..., this causes the reported NullPointerException without a stack trace. When using a fresh Import... -> Existing Maven Projects, the same exception occurred, but with a stack trace that led me to find the above.

    (This is with m2e 1.6.1.20150625-2338 in Eclipse Luna Service Release 2 (4.4.2).)

  4. 参考答案3

  5. 英文原文

    For me worked the answer I found on CodeRanch, by user Maneesh Godbole:

    1. Close eclipse.
    2. Navigate to your "workspace" folder
    3. Ensure the setting on your OS to view hidden files is turned on
    4. Identify and delete the .metadata directory
    5. Restart eclipse
    6. Import project

    中文翻译

    For me worked the answer I found on CodeRanch, by user Maneesh Godbole:

    1. Close eclipse.
    2. Navigate to your "workspace" folder
    3. Ensure the setting on your OS to view hidden files is turned on
    4. Identify and delete the .metadata directory
    5. Restart eclipse
    6. Import project
  6. 参考答案4

  7. 英文原文

    In case it helps anyone, in addition to deleting .settings and .project, I had to delete .classpath and .factorypath before being able to import the project successfully into Eclipse.


    中文翻译

    In case it helps anyone, in addition to deleting .settings and .project, I had to delete .classpath and .factorypath before being able to import the project successfully into Eclipse.

  8. 参考答案5

  9. 英文原文

    I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.


    中文翻译

    I solved mine by deleting the .settings folder and .project file in the project and then reimporting the project.

  10. 参考答案6

  11. 英文原文

    org.eclipse.m2e.core.prefs file is in .settings folder. If you face the problem of

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

    Delete the project from eclipse then by deleting the .settings folder & .project file in the project -> then re-import the project.


    中文翻译

    org.eclipse.m2e.core.prefs file is in .settings folder. If you face the problem of

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

    Delete the project from eclipse then by deleting the .settings folder & .project file in the project -> then re-import the project.

  12. 参考答案7

  13. 英文原文

    I had the same problem. None of the solutions here worked. I had to completely reinstall eclipse and make a new workspace. Then it worked!


    中文翻译

    I had the same problem. None of the solutions here worked. I had to completely reinstall eclipse and make a new workspace. Then it worked!

  14. 参考答案8

  15. 英文原文

    None of the above methods worked for me. This might also arise due to the presence of circular dependency in your eclipse workspace. So if there are any other errors present in any of the other projects in your workspace, try to fix those and then this issue will be gone. This is how i eliminated the error.


    中文翻译

    None of the above methods worked for me. This might also arise due to the presence of circular dependency in your eclipse workspace. So if there are any other errors present in any of the other projects in your workspace, try to fix those and then this issue will be gone. This is how i eliminated the error.

  16. 参考答案9

  17. 英文原文

    I had this same issue across multiple projects and multiple workspaces, none of the solutions I found online worked for me. I'm using STS and the only thing that worked was to go into my STS directory and add a "-clean" to the top of the STS.ini file. You can then start up your workspace and run maven clean without errors. (you can also remove the -clean tag from the ini file so it doesn't clean everytime you start it)

    Hope this helps someone.


    中文翻译

    I had this same issue across multiple projects and multiple workspaces, none of the solutions I found online worked for me. I'm using STS and the only thing that worked was to go into my STS directory and add a "-clean" to the top of the STS.ini file. You can then start up your workspace and run maven clean without errors. (you can also remove the -clean tag from the ini file so it doesn't clean everytime you start it)

    Hope this helps someone.

  18. 参考答案10

  19. 英文原文

    The root issue in my case was a file conflict in the .settings folder. So, deleting the .settings folder would have resolved the Maven error, but I wanted to keep some of my local configuration files. I resolved the conflict, then tried a Maven update again and it worked.


    中文翻译

    The root issue in my case was a file conflict in the .settings folder. So, deleting the .settings folder would have resolved the Maven error, but I wanted to keep some of my local configuration files. I resolved the conflict, then tried a Maven update again and it worked.

  20. 参考答案11

  21. 英文原文

    I had the same issue ... solution at the end !

    here the eclipse log:

    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)
    

    ... it comes from "appengine maven wtp plugin" that try to get the type of GAE runtime, but seems to be null here (... getRuntimeType() --> NPE):

    see class 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)) {
    

    So, if you check in eclipse, Google App Engine is visible , but when you select it you'll see that no SDK is associated ... preference/Server/Runtime environments

    SOLUTION: in red on the screenshot ;-)


    中文翻译

    I had the same issue ... solution at the end !

    here the eclipse log:

    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)
    

    ... it comes from "appengine maven wtp plugin" that try to get the type of GAE runtime, but seems to be null here (... getRuntimeType() --> NPE):

    see class 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)) {
    

    So, if you check in eclipse, Google App Engine is visible , but when you select it you'll see that no SDK is associated ... preference/Server/Runtime environments

    SOLUTION: in red on the screenshot ;-)

  22. 参考答案12

  23. 英文原文

    This helped me: Project menu -> Clean... -> clean all projects


    中文翻译

    This helped me: Project menu -> Clean... -> clean all projects

  24. 参考答案13

  25. 英文原文

    I encountered this same symptom and none of the solutions above were helpful. I finally got a stack trace of the problem by importing the ear project again to eclipse, and was able to trace this down to the org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement which was trying to delete a directory in windows' temp directory called ".mavenDeploymentDescriptorManagement", which caused an irrational NullPointerException from the java.io.File.exists() method, particularly because the code already had successfully done the same thing in a previous method with the same variable, then called file.isFile() without problem.

    Checking this out on the file system revealed that the file could only be accessed with administrator privileges. Apparently I had at some point launched eclipse from an administrator console by mistake. In the end I just made hidden files visible in windows explorer and deleted the temporary file manually, which solved the problem.


    中文翻译

    I encountered this same symptom and none of the solutions above were helpful. I finally got a stack trace of the problem by importing the ear project again to eclipse, and was able to trace this down to the org.eclipse.m2e.wtp.MavenDeploymentDescriptorManagement which was trying to delete a directory in windows' temp directory called ".mavenDeploymentDescriptorManagement", which caused an irrational NullPointerException from the java.io.File.exists() method, particularly because the code already had successfully done the same thing in a previous method with the same variable, then called file.isFile() without problem.

    Checking this out on the file system revealed that the file could only be accessed with administrator privileges. Apparently I had at some point launched eclipse from an administrator console by mistake. In the end I just made hidden files visible in windows explorer and deleted the temporary file manually, which solved the problem.

  26. 参考答案14

  27. 英文原文

    Just another possible source of the problem!

    I found out that in my case it was the following resource block that caused it:

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

    It included a folder from the project folder (the eclipse project is a subfolder of the versioned project folder).

    In my case, I could remove the error by removing the block and replacing it with a call to the Build helper Maven plugin:

    <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>
    

    中文翻译

    Just another possible source of the problem!

    I found out that in my case it was the following resource block that caused it:

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

    It included a folder from the project folder (the eclipse project is a subfolder of the versioned project folder).

    In my case, I could remove the error by removing the block and replacing it with a call to the Build helper Maven plugin:

    <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>
    
  28. 参考答案15

  29. 英文原文

    I had to reinstall eclipse, delete .m2 folder and rebuild the jars.


    中文翻译

    I had to reinstall eclipse, delete .m2 folder and rebuild the jars.

  30. 参考答案16
  31. 参考答案17

  32. 英文原文

    Eclipse has an error log. There you will see the complete stack trace. In my case it seems to be caused by a bad jar file combined with the java.util.zip libs not throwing a proper exception, just a NullPointerException.


    中文翻译

    Eclipse has an error log. There you will see the complete stack trace. In my case it seems to be caused by a bad jar file combined with the java.util.zip libs not throwing a proper exception, just a NullPointerException.