jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Balki Nakshatrala <Ba...@Yodlee.com>
Subject RE: error instantiating class...
Date Thu, 14 Feb 2002 22:44:43 GMT

Actually, I found the problem. Though I followed all the things we have to
do get cactus tests working, I missed on things that we should not do. I had
junit.jar & cactus.jar also in the lib dir of JBoss and that seems to have
been the reason for not finding the Test class.



balki

-----Original Message-----
From: Balki Nakshatrala [mailto:Balki@yodlee.com]
Sent: Thursday, February 14, 2002 1:17 AM
To: 'Cactus Users List'
Subject: error instantiating class...



Hi,

I have to test a ordinary class (not a servlet servlet). It still needs to
be instantiated and used in the container (say because it will do processing
using request object). So I first wrote a simple example as shown below, but
does not do any processing.

Class to be tested :

	package test.sample;

	import java.util.Hashtable;

	public class SampleClass {

	    public SampleClass() {

	    }

	    public void authenticate(Hashtable inputHash) {

	    }
	}

The Test Class is :

	package test.func.sample;

	import junit.framework.*;
	import org.apache.cactus.*;

	import test.sample.SampleClass;

	public class TestSampleClass extends ServletTestCase {

	    public TestSampleClass(String theName) {
	        super(theName);
	    }


	    protected void setUp() {
	    }


	    protected void tearDown() {
	    }


	    public static Test suite() {
	        return new TestSuite(TestSampleClass.class);
	    }


	    public static void main(String args[]) {
	         junit.textui.TestRunner.run(suite());
	    }

	    public void beginAuthenticateOk(WebRequest req) {
	    }

	    public void testAuthenticateOk() {
	        assertTrue(true);
	    }
}

I get the following error. Is it because we cannot test a simple non-servlet
java class that still needs to instantiated and used in the container?

Testcase: testAuthenticateOk took 5.248 sec
	Caused an ERROR
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
Error instanciating class
[test.func.sample.TestSampleClass(testAuthenticateOk)]
	at org.apache.tomcat.core.Handler.service(Handler.java:287)
javax.servlet.ServletException: Error instanciating class
[test.func.sample.TestSampleClass(testAuthenticateOk)]
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.cactus.server.AbstractTestCaller.getTestClassInstance(AbstractTes
tCaller.java:311)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
	at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.cactus.server.AbstractTestCaller.doTest(AbstractTestCaller.java:1
30)
	at
org.apache.cactus.server.AbstractTestController.handleRequest(AbstractTestCo
ntroller.java:122)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
	at
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.
java:134)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at java.lang.Thread.run(Thread.java:484)
	at
org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405)
	at org.apache.tomcat.core.Handler.service(Handler.java:287)
	at
org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
	at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:79
7)
	at
org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
	at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:213)
	at
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
	at
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
	at java.lang.Thread.run(Thread.java:484)

I have followd the "How to Get Started" and "How to Config" links as on
cactus site. The SampleClass and TestSampleClass are in WEB-INF/classes
directory. I also have junit, cactus, httpclient, log4j jars in my
WEB-INF/lib. And I am using JBoss-with-Tomcat (2.2.2) application server.

Thanks,
balki

--
To unsubscribe, e-mail:
<mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:cactus-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:cactus-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:cactus-user-help@jakarta.apache.org>


Mime
View raw message