jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Massol" <vmas...@octo.com>
Subject RE: error instantiating class...
Date Thu, 14 Feb 2002 22:59:11 GMT
Balki,

Yes, the problem was cactus.jar ... Why ? Because the class loader used
to load is was the system class loader (as it was located in the lib/
dir of JBoss). However you test classes were located in WEB-INF/classes
and thus were not seen by the system class loader ...

We need to stress more on the Getting Started page that the jars MUST go
where it is defined on the page and that there must be NO leftover of
them anywhere else on the system classpath.

Thanks
-Vincent

> -----Original Message-----
> From: Balki Nakshatrala [mailto:Balki@Yodlee.com]
> Sent: 14 February 2002 22:45
> To: 'Cactus Users List'
> Subject: RE: error instantiating class...
> 
> 
> 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(Abstrac
tT
> es
> tCaller.java:311)
> 	at
>
org.apache.tomcat.core.ContextManager.internalService(ContextManager.jav
a:
> 79
> 7)
> 	at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
> 	at
>
org.apache.cactus.server.AbstractTestCaller.doTest(AbstractTestCaller.ja
va
> :1
> 30)
> 	at
>
org.apache.cactus.server.AbstractTestController.handleRequest(AbstractTe
st
> Co
> ntroller.java:122)
> 	at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
tt
> pC
> onnectionHandler.java:213)
> 	at
>
org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirec
to
> r.
> java:134)
> 	at
>
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
> 	at
>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:50
1)
> 	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.jav
a:
> 79
> 7)
> 	at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
> 	at
>
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(H
tt
> pC
> onnectionHandler.java:213)
> 	at
>
org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416
)
> 	at
>
org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:50
1)
> 	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>
> 




--
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