| Summary: | java.lang.NoClassDefFoundError: JUnit when running JUnit test from Run Configurations | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] PDE | Reporter: | Aaron <aaron_patula> | ||||
| Component: | UI | Assignee: | PDE-UI-Inbox <pde-ui-inbox> | ||||
| Status: | RESOLVED WONTFIX | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | darin.eclipse, Michael_Rennie | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows Vista | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Can run JUnit tests without throwing an exception by Project + Right Click>Run As>3 JUnit Test. However you can't use a Run Configuration to do this and hence cannot use VM arguments to pass in Eclipse variables through the system properties mechanism. java.lang.NoClassDefFoundError: JUnit Caused by: java.lang.ClassNotFoundException: JUnit at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248) Exception in thread "main" If I click inside the console window and re-rerun the JUnit test with the Run Configuration, I get this error message popup.
Variable references empty selection: ${project_name}
(In reply to comment #3) > If I click inside the console window and re-rerun the JUnit test with the Run > Configuration, I get this error message popup. > Variable references empty selection: ${project_name} Note that to get this error, the focus remains in the Console output window and I run the JUnit test by going to the menu and doing Run>Run Configurations and picking the configuration for my test. Created attachment 176488 [details]
screen shot of error msg when focus is in console window
The "Variable references empty selection" part of this bug report is related to this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=292732 The original part of this bug report (the NoClassDefFoundError part) is still valid. Jerome, Please target and handle. trying to reproduce it to size the fixing after some investigation (thanks Julian) :
. when you use right click => run as => test : it is a TPTP run
. when you use right click => run as => run configuration : it is a PDE / JDT run
so, bug is not on TPTP part
for information, a basic workaround is replacing -Dprojloc=${project_loc} by -Dprojloc="${project_loc}"
it seems to work on my side (the ClassNotFound exception is raised on the part of project name separated by space. using double quote fix it)
re-assigning problem to PDE team, hoping they can do something
The correct approach is to use quotes, as you must always do when paths have spaces. |
Build Identifier: 20100218-1602 When I run a JUnit test from Run>Run Configuration with the VM argument -Dprojloc=${project_name}, I get a java.lang.NoClassDefFoundError: JUnit exception. My workaround is to rename the project to remove all spaces in the project name using Project + Right Click>Refactor>Rename. Reproducible: Always Steps to Reproduce: 1.Create a JUnit project with spaces in project name 2.Create Run Configuration to run the JUnit test (JUnit 4) 3.Use the following VM argument -Dprojloc=${project_name} in the Run Configuration. 4.Run the test using the Run Configuration