Quantcast

Keep getting "Class not found" when running/debugging JUnit tests

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Keep getting "Class not found" when running/debugging JUnit tests

Jimisola Laursen
Hi!

I keep getting "Class not found" when I run/debug JUnit tests (I haven't checked if the pro blem exists when running an actual Java application).

If I do a Project Clean in Eclipse and the project is rebuilt then everything works as expected. Is seems as if when the classes are built by Maven from the prompt/CLI then Eclipse can't find the class file. A diff of the target directory doesn't show any relevant differences.

Regards,
Jimisola

Class not found se.company.SomeClass
java.lang.ClassNotFoundException: se.company.SomeClass
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadSuiteClass(RemoteTestRunner.java:428)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:380)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
        at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Lee Meador-3
After you run a JUnit test in eclipse you can go to the debug perspective and right click on the, now terminated, run entry and select 'properties.' The box that pops up will show the classpath that was used for running the test.

Sometimes this is useful in determining what is going on.

I find that things on the Maven Classpath often get left off of the classpath for JUnit tests. I will check whether a 'clean' in eclipse will fix the problem.

Thanks.

-- Lee

On 6/26/06, Jimisola Laursen <[hidden email]> wrote:

Hi!

I keep getting "Class not found" when I run/debug JUnit tests (I haven't
checked if the pro blem exists when running an actual Java application).

If I do a Project Clean in Eclipse and the project is rebuilt then
everything works as expected. Is seems as if when the classes are built by
Maven from the prompt/CLI then Eclipse can't find the class file. A diff of
the target directory doesn't show any relevant differences.

Regards,
Jimisola

Class not found se.company.SomeClass
java.lang.ClassNotFoundException: se.company.SomeClass
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged (Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java :268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadSuiteClass(RemoteTestRunner.java:428)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest (RemoteTestRunner.java:380)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java :344)
        at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

--
View this message in context: http://www.nabble.com/Keep-getting-%22Class-not-found%22-when-running-debugging-JUnit-tests-t1851758.html#a5055762
Sent from the Maven Eclipse - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email




--
-- Lee Meador
Sent from gmail. My real email address is [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Jimisola Laursen
Thanks for the reply. I didn't know about the properties option and hence being able to see the classpath.

I will check this next time I get this error and hopefully I'll have enough information to provide a detailed bug report.

Regards,
Jimisola
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Diego Ballve
Hi,

I think we just solved that problem almost by accident... In the project containing your tests, edit Java Build Path | Order and Export. Make sure M2 Dependencies appears BEFORE JRE System Library.

Regards,
Diego
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Jimisola Laursen
Nice! Thanks.

That seemed to be the trick. Do you want to have to honor of filing a bug report or should I?

Regards,
Jimisola
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Diego Ballve
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Lee Meador-3
I suspect this is the same issue as   [ <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://jira.codehaus.org/browse/MNGECLIPSE-18?page=all" target="_blank">http://jira .codehaus.org/browse/MNGECLIPSE-18?page=all ]

On 7/23/06, doballve <[hidden email]> wrote:

Done: http://jira.codehaus.org/browse/MECLIPSE-132
--
View this message in context: http://www.nabble.com/Keep-getting-%22Class-not-found%22-when-running-debugging-JUnit-tests-tf1851758.html#a5453944
Sent from the Maven Eclipse - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email




--
-- Lee Meador
Sent from gmail. My real email address is [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Jimisola Laursen
No, I don't think so as that was fixed for 0.0.4 and this happens with 0.0.9.
The solution here seem to be to reorder Java Build Path, but I might be wrong...

Jimisola

Lee Meador-3 wrote
I suspect this is the same issue as   [ http://jira
.codehaus.org/browse/MNGECLIPSE-18?page=all ]

On 7/23/06, doballve <diego.ballve@digital-artefacts.fi> wrote:
>
>
> Done: http://jira.codehaus.org/browse/MECLIPSE-132
> --
> View this message in context:
> http://www.nabble.com/Keep-getting-%22Class-not-found%22-when-running-debugging-JUnit-tests-tf1851758.html#a5453944
> Sent from the Maven Eclipse - User forum at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
-- Lee Meador
Sent from gmail. My real email address is lee@leemeador.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Lee Meador-3
As I recall, that issue was closed because it couldn't be duplicated. That's different than "fixed."

I suspect that some settings and organizations of projects cause it to pop up. I have not had time to pare my projects down to the point that removing one more thing makes the problem go away. It's been happening to me for a long time.

BTW - Rearranging the order of things in the classpath, as described previously in this thread, does not always fix the problem for me. It does in some projects and doesn't in others. I don't know exactly how to predict it occurring.

Thanks.

-- Lee

On 7/27/06, Jimisola Laursen <[hidden email]> wrote:

No, I don't think so as that was fixed for 0.0.4 and this happens with 0.0.9.
The solution here seem to be to reorder Java Build Path, but I might be
wrong...

Jimisola


Lee Meador-3 wrote:

>
> I suspect this is the same issue as   [ http://jira
> .codehaus.org/browse/MNGECLIPSE-18?page=all ]
>
> On 7/23/06, doballve <[hidden email]> wrote:
>>
>>
>> Done: http://jira.codehaus.org/browse/MECLIPSE-132
>> --
>> View this message in context:
>> http://www.nabble.com/Keep-getting-%22Class-not-found%22-when-running-debugging-JUnit-tests-tf1851758.html#a5453944
>> Sent from the Maven Eclipse - User forum at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list please visit:
>>
>>     http://xircles.codehaus.org/manage_email
>>
>>
>
>
> --
> -- Lee Meador
> Sent from gmail. My real email address is [hidden email]
>
>
--
View this message in context: http://www.nabble.com/Keep-getting-%22Class-not-found%22-when-running-debugging-JUnit-tests-tf1851758.html#a5529256
Sent from the Maven Eclipse - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email




--
-- Lee Meador
Sent from gmail. My real email address is [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

tgh_china
public static void main(String[] args) {
junit.textui.TestRunner.run(YourClass.class);
}

if you forget these code you will Class not found exception
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Keep getting "Class not found" when running/debugging JUnit tests

Jimisola Laursen
Don't believe I have this section of code. Are you sure about this?
The "Class not found" occurs every now and then - can you explain that?

Regards,
Jimisola

tgh_china wrote
public static void main(String[] args) {
junit.textui.TestRunner.run(YourClass.class);
}

if you forget these code you will Class not found exception
Loading...