You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by JavaGeek <no...@boscarine.com> on 2008/02/06 19:33:24 UTC
tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but not
eclipse
Hello All,
I have a maven project with JUnit 4.0 unit tests. Most of our unit tests
are failing in Surefire with the message pasted below. However, all of the
unit tests work when launched from eclipse. Does anyone have any ideas on
how to troubleshoot?
Thanks in Advance,
Steven
java.lang.NoClassDefFoundError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at
org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
--
View this message in context: http://www.nabble.com/tests-throw-java.lang.NoClassDefFoundError-for-MVN%2C-JUnit-4-but-not-eclipse-tp15309895s177p15309895.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but
not eclipse
Posted by Mark Eramo <ma...@trustvesta.com>.
Hi Steven,
My guess is there is a required jar in the eclipse classpath that is not
in the Maven dependency section. You will just need to determine which
jar this class is in. I'll bet that if you add this as a dependency
inside the pom itself, these tests will work. You might need to compare
the eclipse classpath to what you have in maven, there may be other jars
missing as well.
Regards,
Mark
JavaGeek wrote:
> Hello All,
> I have a maven project with JUnit 4.0 unit tests. Most of our unit tests
> are failing in Surefire with the message pasted below. However, all of the
> unit tests work when launched from eclipse. Does anyone have any ideas on
> how to troubleshoot?
>
> Thanks in Advance,
> Steven
>
>
> java.lang.NoClassDefFoundError
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
> at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but not eclipse
Posted by Martin Gainty <mg...@hotmail.com>.
depends on the return value from <the factory>
Since the return type is a serializable bean If you want to look at
reference for Serializable Beans I encourage you to read
http://java.sun.com/docs/books/tutorial/javabeans/persistence/index.html
M-
----- Original Message -----
From: "JavaGeek" <no...@boscarine.com>
To: <us...@maven.apache.org>
Sent: Thursday, February 07, 2008 1:42 PM
Subject: Re: tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but
not eclipse
>
> Thank you so much Nicole.
> When you say:
> Nicole Lacoste wrote:
> >
> > One thing is that all classes are required to have
> > public constructors with either no-arg or String name. There are
probably
> > also requirements on public methods.
>
> I think you're right. How did you figure this out? Also, did you mean
the
> classes tested or the unit tests themselves?
>
> Thanks so much,
> Steven
>
>
>
> --
> View this message in context:
http://www.nabble.com/tests-throw-java.lang.NoClassDefFoundError-for-MVN%2C-
JUnit-4-but-not-eclipse-tp15309895s177p15340368.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but
not eclipse
Posted by JavaGeek <no...@boscarine.com>.
Thank you so much Nicole.
When you say:
Nicole Lacoste wrote:
>
> One thing is that all classes are required to have
> public constructors with either no-arg or String name. There are probably
> also requirements on public methods.
I think you're right. How did you figure this out? Also, did you mean the
classes tested or the unit tests themselves?
Thanks so much,
Steven
--
View this message in context: http://www.nabble.com/tests-throw-java.lang.NoClassDefFoundError-for-MVN%2C-JUnit-4-but-not-eclipse-tp15309895s177p15340368.html
Sent from the Maven - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: tests throw java.lang.NoClassDefFoundError for MVN, JUnit 4 but not eclipse
Posted by Nicole Lacoste <ni...@gmail.com>.
Hi Steven,
I had a sort of similar problem. Maven expects certain things from the unit
tests, that eclipse doesn't, the reason being that surefire uses reflection
to lance the unit tests. One thing is that all classes are required to have
public constructors with either no-arg or String name. There are probably
also requirements on public methods. Try making any method that is not a
test method private and check your ctors. I am not sure if this is
documented anywhere...
Nicole
On 06/02/2008, JavaGeek <no...@boscarine.com> wrote:
>
>
> Hello All,
> I have a maven project with JUnit 4.0 unit tests. Most of our unit tests
> are failing in Surefire with the message pasted below. However, all of
> the
> unit tests work when launched from eclipse. Does anyone have any ideas on
> how to troubleshoot?
>
> Thanks in Advance,
> Steven
>
>
> java.lang.NoClassDefFoundError
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> :39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(
> BeforeAndAfterRunner.java:74)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runBefores(
> BeforeAndAfterRunner.java:50)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(
> BeforeAndAfterRunner.java:33)
> at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java
> :62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(
> AbstractDirectoryTestSuite.java:138)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(
> AbstractDirectoryTestSuite.java:125)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java
> :39)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:585)
> at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(
> SurefireBooter.java:290)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java
> :818)
>
> --
> View this message in context:
> http://www.nabble.com/tests-throw-java.lang.NoClassDefFoundError-for-MVN%2C-JUnit-4-but-not-eclipse-tp15309895s177p15309895.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>