Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 314728

Summary: [JUnit] java.lang.ClassNotFoundException:
Product: [Eclipse Project] JDT Reporter: Lulseged Zerfu <lulseged.zerfu>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: RESOLVED NOT_ECLIPSE QA Contact:
Severity: major    
Priority: P3 CC: markus.kell.r, Olivier_Thomann
Version: 3.6   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
.classpath file
none
.project file none

Description Lulseged Zerfu CLA 2010-05-27 13:19:24 EDT
Build Identifier: 3.5.2 for J2EE

Hi

 I have maven projects that compiles but when running a junit test, it can't find the test class.

I have created linked resource directory where all projects including test classes are put into.

The exception I get it:
Class not found com.ericsson.ims.pag.xdms.resource.list.session.ResourceListSessionTest
java.lang.ClassNotFoundException: com.ericsson.ims.pag.xdms.resource.list.session.ResourceListSessionTest
	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)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)



my .classpth file is:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src/main/java" output="bin"/>
	<classpathentry kind="src" path="src/main/resources" />
	<classpathentry kind="src" path="src/test/java" output="bin"/>
	<classpathentry kind="src" path="src/test/resources" output="bin"/>
	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
	<classpathentry kind="output" path="bin"/>
</classpath>

my .project file is:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>xdms-resource-lists</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>org.eclipse.wst.common.project.facet.core.builder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.maven.ide.eclipse.maven2Builder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>org.eclipse.jdt.core.javanature</nature>
		<nature>org.maven.ide.eclipse.maven2Nature</nature>
		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
	</natures>
	<linkedResources>
		<link>
			<name>bin</name>
			<type>2</type>
			<locationURI>MODULE_BUILD/xdms-resource-lists</locationURI>
		</link>
	</linkedResources>
</projectDescription>

MODULE_BUILD is a linked resource name pointing to \\127.0.0.1\output\build

When buiding this project I get correct contents in the bin directory.


\\127.0.0.1\output\build\xdms-resource-lists\com.ericsson.ims.pag.xdms.resource.list.session.ResourceListSessionTest

How can I make eclipse found this class?

Lulseged

Reproducible: Always
Comment 1 Lulseged Zerfu CLA 2010-05-27 13:22:30 EDT
Created attachment 170230 [details]
.classpath file
Comment 2 Lulseged Zerfu CLA 2010-05-27 13:23:12 EDT
Created attachment 170231 [details]
.project file
Comment 3 Prakash Rangaraj CLA 2010-05-27 13:31:23 EDT
Moving to JDT
Comment 4 Markus Keller CLA 2010-05-27 14:57:30 EDT
Looks like the target classpath does not contain the test class. You can see what's passed on the command line as -classpath argument when you select the process in the Debug view and then choose Properties from the context menu.

In this case, I can only guess that the Maven classpath container contains entries that cannot be resolved when passed as -classpath argument.

Please follow up with the providers of the Maven plug-in you're using.

If they supply a special launch configuration type to run a main class from a Maven project, then they maybe also have to implement a corresponding JUnit launch configuration type (see e.g. JUnit Plug-in Test from PDE).