101

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

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
achref05
  • 1,653
  • 4
  • 16
  • 18

24 Answers24

169

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

entpnerd
  • 10,049
  • 8
  • 47
  • 68
user2985381
  • 1,722
  • 1
  • 10
  • 2
  • 5
    I tried many things, and it was the .settings folder that did it for me. – simon Jan 06 '14 at 03:35
  • This helped! But, because I was using Workspace Resolution to resolve some pom dependencies to a project in the same Workspace, I had to disable Workspace Resolution, then Disable the Maven Nature, then re-enable Maven on the project. – mcolley73 Feb 13 '14 at 22:42
  • 2
    Jep, that worked for me, it appears it was also referring to a Google App Engine version I didn't have anymore (it was updated) – Dieter Hubau Jul 05 '14 at 10:59
  • Also had to restart eclipse before reimporting. – rakmoh Jan 12 '16 at 20:06
  • I solved it just deleting all .settings files, closing before Eclipse. Then I executed a maven update. – isma.imc Apr 04 '16 at 09:53
  • I would take a copy of the directory first. I deleted .settings and .project as above. When I tried to import the project in Kepler I got: No projects are found to import. Probably because I removed .project. – andrew pate Aug 13 '16 at 16:17
  • I couldn't import "Existing Projects Into Workspace", because the metadata was missing. But File > Open Projects from File System worked for me. – GregT Sep 19 '17 at 07:41
  • In the first attempt I only deleted the .settings folder and it was not enough. Deleting both the .settings and .project and reimporting the project did the job. Imported throught the Import... Maven > Existing Maven Projects, menu option. Thanks for sharing! – André Luiz Müller Apr 10 '18 at 08:03
  • I imported by using "Existing Maven Project". It recreated .settings and .project. – GeekyDaddy Jun 26 '18 at 15:38
  • I compared the .settings folder with one from another project that didn't have this problem and it was specifically the org.eclipse.jdt.core.prefs file that was causing the error. I copied that file from the ok-project and the error was gone. – mari Dec 02 '19 at 14:01
27

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
Eel Lee
  • 3,513
  • 2
  • 31
  • 49
  • 1
    This was the only answer here that worked for me. The .settings and .project entites were being recreated on startup, causing the same issue until I deleted the metadata folder. +1 & thx! – Mark W Sep 17 '14 at 18:34
  • For me it work, but i needed re configure all my workspace. =( – Fernando Nogueira Feb 18 '16 at 18:37
  • it delete all my settings on eclipse. Layout, perspectives and colors all of is gone. – Umut Aug 16 '16 at 07:46
7

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

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

user1854278
  • 119
  • 1
  • 4
3

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.

entpnerd
  • 10,049
  • 8
  • 47
  • 68
ccellist
  • 512
  • 5
  • 10
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).)

1

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.

Jyoti Prakash
  • 3,921
  • 3
  • 21
  • 24
1

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.

Pranesh
  • 43
  • 9
1

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

Mangesh
  • 5,491
  • 5
  • 48
  • 71
Tony
  • 72
  • 1
  • 8
1

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.

user1050755
  • 11,218
  • 4
  • 45
  • 56
  • In my case, this scenario was triggered by a couple of the javadoc JARs from Selenium, e.g., https://repo1.maven.org/maven2/org/seleniumhq/selenium/selenium-java/3.9.0/selenium-java-3.9.0-javadoc.jar. In the source for the Eclipse m2e at https://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/src/org/eclipse/m2e/jdt/internal/BuildPathManager.java, you can see that the getJavaDocPathInArchive method doesn't expect a NullPointerException from en.nextElement(). – Jeremy K Jan 23 '19 at 18:32
  • Apparently the "NullPointerException" from enumerating a ZIP file is addressed in Java 9 (https://bugs.openjdk.java.net/browse/JDK-8048990). – Jeremy K Jan 23 '19 at 18:38
1

I'm using:

Eclipse Java EE IDE for Web Developers.

Version: Neon.3 Release (4.6.3) Build id: 20170314-1500

The fix/trick for me was deleting my local repository in ~/.m2/repository in order to remove local dependencies and rebuilding my project in which fresh dependencies are pulled down.

1

Above solutions did not work for me as the issue with open JDK 13 version https://github.com/spotify/dockerfile-maven/issues/163 So I degraded to open JDK8 and it works for me

RAJ
  • 11
  • 3
0

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!

clocksmith
  • 6,226
  • 3
  • 32
  • 45
0

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.

0

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 Gilbert Arenas Dagger
  • 12,071
  • 13
  • 66
  • 80
0

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

fedevo
  • 631
  • 1
  • 7
  • 15
0

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.

guest
  • 1
0

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>
Bowi
  • 1,378
  • 19
  • 33
0

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

Amit
  • 178
  • 1
  • 6
0

deleting the local maven repository helped me

0

In my case, the problem was a conflict of derived dependencies that were been used by other dependencies, and some of those derived dependencies versions were not available, maybe because some deploy that i forgot to do because with workspace resolution everything worked, but when moving to other environment all broke suddenly. And also I was working with version ranges

maven was giving me this error:

Could not resolve dependencies for project MyProject:MyProject:jar:1.0.0: Could not resolve version conflict among Dependency-A:1.0.1 -> Dependency-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

I tried all above and nothing worked, so...

THE SOLUTION: Use LATEST as version in all dependencies, so maven don't need to resolve all dependencies in ranges, wich must be used with care because if you miss to deploy one of the dependencies the build will fail

Only I suggest you to use LATEST if you are working with your own dependencies, otherwise in some third party future version, you could find some compilation or runtime errors

0

Avoid deleting the .metadata folder as it cleans up all settings, run configurations. Instead, rename the .metadata folder --> Restart eclipse --> Import project

0

deleting the local .settings folder helped me

YouSJ
  • 1
0

solution step is delete following files in project folder

.settings

.project

.classpath

enter image description here

Lova Chittumuri
  • 2,994
  • 1
  • 30
  • 33
0

I solved this problem like this: Project -> Clean -> %YOURPROJECT%

Click Here for image

  • please, avoid to add links to another websites. The images can be attached directly in your post instead. Also, provide a bit more of context regarding your environment like Eclipse and Maven version, this will help OP to assess if you two have indeed the same problem or if your solution applies to OP. – avaz Jan 16 '23 at 09:01
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 16 '23 at 09:01