jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Varma, Nitesh" <nitesh_va...@tvworks.com>
Subject NoClassDefFoundError - can't find the servlet class under test
Date Thu, 04 May 2006 21:24:51 GMT
I'm trying to test one of our servlets running on JBoss 4.0.3 with cactus 1.7.2

 

The problem is that my Cactus TestCase can't instantiate the servlet to test. My cactified
ear file contains the following:

 

-          application jar file

-          application war file

-          cactus.war file

 

cactus.war file contains all my test classes. I used the following to cactify my ear file:

 

        <cactifyear srcfile="${cactify.dir}/${project.name}.ear" destfile="${cactify.dir}/${project.name}-cactified.ear">

              <cactuswar context="/${test.context}" version="2.3">

                  <classes dir="${cactify.dir}/test/classes">

                      <include name="**/*Test.class"/>

                  </classes>

              </cactuswar>

        </cactifyear>

 

This generates cactus.war with the following structure:

WEB-INF\classes\com\liberate\vod\web\test\ MyServletTest.class

WEB-INF\lib +

-          aspectrjt-1.2.1.jar

-          cactus-1.7.1.jar

-          commons-logging-1.0.4.jar

-          junit-3.8.1.jar

WEB-INF\web.xml

 

It seems like the cactus.war is not seeing classes under [application.war] because of class
loader issue. But my understanding is that application
classes shouldn't be included in cactus.war.

 

I'm probably missing something basic. But what, I don't know! Any hint will be appreciated.


 

The server-side stack trace is as follows:

 

14:13:19,951 INFO  [STDOUT] java.lang.NoClassDefFoundError: com/liberate/vod/web/TVPV7FrontServlet

14:13:19,952 INFO  [STDOUT]     at com.liberate.vod.web.test. MyServletTest.testGetRootFolder(MyServletTest.java:59)

14:13:19,952 INFO  [STDOUT]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

14:13:19,952 INFO  [STDOUT]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

14:13:19,952 INFO  [STDOUT]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

14:13:19,952 INFO  [STDOUT]     at java.lang.reflect.Method.invoke(Method.java:585)

14:13:19,953 INFO  [STDOUT]     at junit.framework.TestCase.runTest(TestCase.java:154)

14:13:19,953 INFO  [STDOUT]     at junit.framework.TestCase.runBare(TestCase.java:127)

14:13:19,953 INFO  [STDOUT]     at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)

 

The following is my test class:

 

public class MyServletTest extends ServletTestCase {

 

            public MyServletTest (String arg0) {

                        super(arg0);

            }

 

    public MyServletTest ()

    {

        super();

    }

 

    public MyServletTest (String arg0, Test arg1)

    {

        super(arg0, arg1);

    }

 

            protected void setUp() throws Exception {

                        super.setUp();

            }

 

            protected void tearDown() throws Exception {

                        super.tearDown();

            }

            

            public void beginGetFolderContent(WebRequest theRequest)

            {

                // Set up HTTP related parameters

                theRequest.setURL("localhost:8080", "/vod", null, null, null);

                theRequest.addParameter(GET_FOLDER_CONTENT_QUERY, "", WebRequest.POST_METHOD);

            }

 

            public void testGetRootFolder() throws Throwable

            {

                        TVPV7FrontServlet servlet = null;

                        try {

                                    servlet = new TVPV7FrontServlet();

                        } catch (Throwable t) {

                                    t.printStackTrace();

                                    throw t;

                        }

                

                // Call method to test

                servlet.doPost(this.request, this.response);

 

                // Perform some server side asserts

            }

 

            public void endXXX(WebResponse theResponse)

            {

                        assertNotNull(theResponse.getText());

                        assertEquals(HttpServletResponse.SC_OK, theResponse.getStatusCode());

            }

}


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message