简体   繁体   中英

Error: Eclipse 4.5 MARS NullPointerException (JUnit-Tests)

I do have a problem with Eclipse 4.5 when building a JUnit Test Class. I can build all tests with the help of ant in its repository. I think it is a configuration problem in Eclipse.

I already followed a lot of solutions in this forum:

  • Cleaning the path of eclipse itself
  • restarting eclipse
  • try to compile with JUnit3
  • try to compile with JUnit4
  • try another JRE
  • start the project in a different workspace

The reason why I haven't updated my Eclipse is because my company only uses Eclipse 4.5. So I can't accept an answer to update it.

The error log:

!ENTRY org.eclipse.core.jobs 4 2 2019-09-09 17:55:58.495
!MESSAGE An internal error occurred during: "Launching JUnitEntityDBUtility".
!STACK 0
java.lang.NullPointerException
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localURL(JUnitLaunchConfigurationDelegate.java:429)
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.entryString(JUnitLaunchConfigurationDelegate.java:418)
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.addEntry(JUnitLaunchConfigurationDelegate.java:405)
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate$ClasspathLocalizer.localizeClasspath(JUnitLaunchConfigurationDelegate.java:396)
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.getClasspath(JUnitLaunchConfigurationDelegate.java:373)
    at org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate.launch(JUnitLaunchConfigurationDelegate.java:147)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

Delete and recreate your JUnitEntityDBUtility launch configuration .

The stack trace can be found here and here . At the second finding you will find the explanation and a workaround by Moritz Eysholdt for your issue as follows (highlighting by me):

That NPE occurs if you execute a test's launch config in an Eclipse that does not have the plugin org.eclipse.jdt.junit4.runtime.patch installed when the launch config was created by an Eclipse that did actually have org.eclipse.jdt.junit4.runtime.patch installed.

Workaround: Install org.eclipse.jdt.junit4.runtime.patch via the Xpect update site or delete+recreate your launch configuration .

[...]

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