You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Fazle Khan <fa...@yahoo.com> on 2005/01/25 21:49:06 UTC

NoClassDefFoundError when running cactified test via JunitEE

I know this is dealing with tests not working with
another open source project, JunitEE, but I was hoping
someone here might have some input.  Once I change the
junit tests to work with cactus they no longer work
with JunitEE.

I am generating a war file from JunitEE that I am
later running the cactifywar ant task against. So that
cactus can execute the tests too.  

The tests have the static suite method added, for
example

import org.apache.cactus.ServletTestSuite;
...
 public static Test suite() {
        ServletTestSuite suite = new
ServletTestSuite();
        suite.addTestSuite(FriIdTest.class);
        return suite;
        }

so cactus can call the junit tests.  When I try and
run these tests via the JunitEE testservlet I get
following exception 

java.lang.NoClassDefFoundError:
org/apache/cactus/ServletTestSuite
        at
com.onexchange.mercury.cust.jse.server.FriIdTest.suite(FriIdTest.java:22)
        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:324)
        at
junit.runner.BaseTestRunner.getTest(BaseTestRunner.java:111)
        at
org.junitee.runner.TestRunner$1.run(TestRunner.java:70)
        at
org.junitee.runner.TestRunner.run(TestRunner.java:95)
        at
org.junitee.servlet.JUnitEEServlet.runTests(JUnitEEServlet.java:231)
        at
org.junitee.servlet.JUnitEEServlet.doGet(JUnitEEServlet.java:202)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
        at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:996)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
        at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
        at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6452)
        at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
        at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3661)
        at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2630)
        at
weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
        at
weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

The war file that has the tests contains the cactus
jar, here is the list of contents

Archive:  mercury-junit.war
 Length    Date    Time    Name
 ------    ----    ----    ----
      0  01-25-05  15:07   META-INF/
    222  01-25-05  15:07   META-INF/MANIFEST.MF
      0  01-25-05  15:07   WEB-INF/
      0  01-25-05  15:07   WEB-INF/lib/
 121070  01-20-05  11:26   WEB-INF/lib/junit.jar
  35754  01-20-05  11:26   WEB-INF/lib/junitee.jar
 199368  01-25-05  15:07   WEB-INF/lib/test.jar
   1742  01-25-05  15:07   WEB-INF/testCase.txt
   9214  01-25-05  15:07   index.html
   1117  01-25-05  15:07   jspRedirector.jsp
   1382  01-25-05  15:07   WEB-INF/web.xml
  29329  01-20-05  11:26  
WEB-INF/lib/aspectjrt-1.1.1.jar
 250604  01-20-05  11:26  
WEB-INF/lib/cactus-1.6.1.jar
  31605  01-20-05  11:26  
WEB-INF/lib/commons-logging-1.0.3.jar
 222618  01-20-05  11:26  
WEB-INF/lib/commons-httpclient-2.0.jar
 ------                    -------
 904025                    15 files

When I ran the tests through the debugger and the
exception is thrown by the new operator of the
ServletTestSuite().

Thanks for any help.
-Fazle





		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 

RE: NoClassDefFoundError when running cactified test via JunitEE

Posted by Vincent Massol <vm...@pivolis.com>.
Hi Fazle,

> -----Original Message-----
> From: Fazle Khan [mailto:fazleskhan@yahoo.com]
> Sent: mardi 25 janvier 2005 21:49
> To: cactus-user@jakarta.apache.org
> Subject: NoClassDefFoundError when running cactified test via JunitEE
> 
> I know this is dealing with tests not working with
> another open source project, JunitEE, but I was hoping
> someone here might have some input.  Once I change the
> junit tests to work with cactus they no longer work
> with JunitEE.
> 
> I am generating a war file from JunitEE that I am
> later running the cactifywar ant task against. So that
> cactus can execute the tests too.
> 
> The tests have the static suite method added, for
> example
> 
> import org.apache.cactus.ServletTestSuite;
> ...
>  public static Test suite() {
>         ServletTestSuite suite = new
> ServletTestSuite();
>         suite.addTestSuite(FriIdTest.class);
>         return suite;
>         }
> 
> so cactus can call the junit tests.  When I try and
> run these tests via the JunitEE testservlet I get
> following exception
> 
> java.lang.NoClassDefFoundError:
> org/apache/cactus/ServletTestSuite

This seems to indicate that you're missing the cactus jar in one of your
classpaths.

[snip]

> The war file that has the tests contains the cactus
> jar, here is the list of contents
> 
> Archive:  mercury-junit.war
>  Length    Date    Time    Name
>  ------    ----    ----    ----
>       0  01-25-05  15:07   META-INF/
>     222  01-25-05  15:07   META-INF/MANIFEST.MF
>       0  01-25-05  15:07   WEB-INF/
>       0  01-25-05  15:07   WEB-INF/lib/
>  121070  01-20-05  11:26   WEB-INF/lib/junit.jar
>   35754  01-20-05  11:26   WEB-INF/lib/junitee.jar
>  199368  01-25-05  15:07   WEB-INF/lib/test.jar
>    1742  01-25-05  15:07   WEB-INF/testCase.txt
>    9214  01-25-05  15:07   index.html
>    1117  01-25-05  15:07   jspRedirector.jsp
>    1382  01-25-05  15:07   WEB-INF/web.xml
>   29329  01-20-05  11:26
> WEB-INF/lib/aspectjrt-1.1.1.jar
>  250604  01-20-05  11:26
> WEB-INF/lib/cactus-1.6.1.jar
>   31605  01-20-05  11:26
> WEB-INF/lib/commons-logging-1.0.3.jar
>  222618  01-20-05  11:26
> WEB-INF/lib/commons-httpclient-2.0.jar
>  ------                    -------
>  904025                    15 files

This is showing the WAR file but the test runner is maybe executed in a
different JVM and if so you'll also need the right jars in this other JVM's
classpath.

The other option to verify is to make sure that the Cactus jars are NOT in
your system classpath.

Thanks
-Vincent

_________________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran�ais !
Yahoo! Mail : http://fr.mail.yahoo.com