Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 559009 - Malformed test classpath provokes ClassNotFoundException of test class
Summary: Malformed test classpath provokes ClassNotFoundException of test class
Status: CLOSED DUPLICATE of bug 559011
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.14   Edit
Hardware: PC Windows 10
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-01-10 05:53 EST by Aritz Bastida CLA
Modified: 2020-01-10 10:14 EST (History)
1 user (show)

See Also:


Attachments
Malformed classpath (185.39 KB, image/jpeg)
2020-01-10 05:53 EST, Aritz Bastida CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aritz Bastida CLA 2020-01-10 05:53:08 EST
Created attachment 281440 [details]
Malformed classpath

Under some specific and determined circumstances I cannot understand, Eclipse 2019-12 sets up a malformed test classpath, resulting in a ClassNotFoundException at loading the test class itself. That happens with every test class included in the project. 

Class not found com.telefonica.bst3.srv.nuc.bank.msg.PojoTest
java.lang.ClassNotFoundException: com.telefonica.bst3.srv.nuc.bank.msg.PojoTest
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:780)


I tried to find the root cause, but could not learn too much. It appears to have some relationship with the Maven dependencies I'm including in my pom.xml, because it only happens with some combination of dependencies. However, I couldn't shortlist them; the behavior it's quite random. But maybe the m2e plugin is involved in some way...

I tried to debug and found out that the first entry of the test classpath has the current directory and a URL-encoded double quote prefixed on it. As the first entry is "test-classes", that is the reason I'm having the ClassNotFoundException. So the workaround, to make the unit test work, is to patch the classpath with any trivial folder (such as "generated-sources" in the attached screenshot).
Comment 1 Andrey Loskutov CLA 2020-01-10 10:14:25 EST

*** This bug has been marked as a duplicate of bug 559011 ***