Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 10th, 2003, 01:28 PM
MissCrabTree MissCrabTree is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 15 MissCrabTree User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 11 sec
Reputation Power: 0
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());
}
};

Reply With Quote
  #2  
Old April 10th, 2003, 01:42 PM
MissCrabTree MissCrabTree is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 15 MissCrabTree User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 11 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old April 10th, 2003, 03:43 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
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.

Reply With Quote
  #4  
Old April 10th, 2003, 05:33 PM
MissCrabTree MissCrabTree is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Posts: 15 MissCrabTree User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 11 sec
Reputation Power: 0
Thanks Nemi, that was easy :-)

Now, I get the following error:

root cause
java.lang.InstantiationException: SimpleRequest

any ideas?

Reply With Quote
  #5  
Old April 10th, 2003, 09:41 PM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
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:
Thrown when an application tries to create an instance of a class using the newInstance method in class Class, but the specified class object cannot be instantiated because it is an interface or is an abstract class.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > java.lang.NoClassDefFoundError: junit.framework.TestCase


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT