|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
java.lang.NoClassDefFoundError: junit.framework.TestCase
I receive the following error while trying to access a servlet in Tomcat:
java.lang.NoClassDefFoundError: junit.framework.TestCase I have the path to junit.jar setup in the classpath. Any ideas? Many thanks in advance ---------------------------------------------------------------------------------- import junit.framework.*; import com.meterware.httpunit.*; public class SimpleRequest extends TestCase { WebConversation wc = new WebConversation(); String base_url = "http://www.msn.com"; public SimpleRequest(String name) { super(name); } public void testRequest() { WebResponse resp = null; try { resp = wc.getResponse( base_url ); } catch (java.net.MalformedURLException e) { System.out.println("Bad url: " + e); } catch (java.io.IOException e) { System.out.println("IO Err: " + e); } catch (org.xml.sax.SAXException e) { System.out.println("XML Err: " + e); } assertEquals(200, resp.getResponseCode()); } }; |
|
#2
|
|||
|
|||
|
It does run fine if I do the following command:
java junit.textui.TestRunner SimpleRequest But why do I get the error while running via a web browser? P.S. I know that currently, no text would print to the browser, but in the future I could write code that would. |
|
#3
|
|||
|
|||
|
The junit jar needs to be in the WEB-INF/classes folder for jsp's in Tomcat to find it. The environment variable CLASSPATH will not work.
|
|
#4
|
|||
|
|||
|
Thanks Nemi, that was easy :-)
Now, I get the following error: root cause java.lang.InstantiationException: SimpleRequest any ideas? |
|
#5
|
|||
|
|||
|
I am not familiar with junit, so I do not know what you are trying to do with it. Here is what the API docs say about that exception
Quote:
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > java.lang.NoClassDefFoundError: junit.framework.TestCase |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|