I have thought a bit about this this week end and here are my ideas :
- I'd like to have a mechanism to check the user configuration automatically and report nice errors if something is wrong. The checks could include : correct jars in the classpath, valid cactus.properties file, valid web.xml file with same mapping that what is in cactus.properties, ...
- Also, I'd like this to be transparent with regards to the cactus code (i.e. no code modification). I consider this as a kind of config wizard but that runs as the code runs.
- I'd also like that the logging of entry/exits of methods are done automatically without any change in the code (as is currently the case)
 
... Some of you will say "this is all nice but come on Vince, you're dreaming !" :-)
 
I believe it is possible and I have even experimented with this past week end. The solution is called Aspect Oriented Programming and the tool that will make this a reality is called aspectj which implements some aop concepts on top of java. For those interested, I recommend to read the tutorial (http://aspectj.org/doc/dist/tutorial.pdf). To make it short, it adds some new syntax to java. you then compile it with aspectj compiler which generates standard java classes.
 
There only difference for cactus end users will be that they will need to add a small jar to their classpath (both client and server) : aspectj.jar (24kb). Do you think that is ok for such a great benefit in exchange ? [I have to tell that I am quite excited to try aspectj as it looks like a neat and useful concept]
 
What do you think ?
-Vincent
 
----- Original Message -----
Sent: Monday, October 22, 2001 4:43 PM
Subject: RE: java.io.StreamCorruptedException: InputStream does not contain a serialized object

Hello everyone,
 
Do you think we should catch this common error and incorporate these suggestions into the message?
 
Cheers,
 
nick
-----Original Message-----
From: Vincent Massol [mailto:[EMAIL PROTECTED]]
Sent: Saturday, October 20, 2001 1:36 PM
To: [EMAIL PROTECTED]
Subject: Re: java.io.StreamCorruptedException: InputStream does not contain a serialized object

Hi Shridhar,
 
* Have you run the cactus samples (as is with no modification except modifying build.properties) ? It should run fine
* I believe your problem is either with :
- a jar missing in the classpath (client or server)
- the cactus.properties file not containing correct url for the servlet redirector
- your web.xml not having a correct mapping for the servlet redirector (not in line with cactus.properties)
 
hope it helps
-Vincent
----- Original Message -----
Sent: Saturday, October 20, 2001 5:47 AM
Subject: java.io.StreamCorruptedException: InputStream does not contain a serialized object

Hi Cactus folks,
 
Need help.
 
When I run JUnit test runner I get the following error message:
 
----- ooo -----
 
java.io.StreamCorruptedException: InputStream does not contain a serialized object
 at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:849)
 at java.io.ObjectInputStream.<init>(ObjectInputStream.java:168)
 at org.apache.cactus.client.AbstractHttpClient.doTest(AbstractHttpClient.java:148)
 at org.apache.cactus.AbstractTestCase.runGenericTest(AbstractTestCase.java:422)
 at org.apache.cactus.ServletTestCase.runTest(ServletTestCase.java:130)
 at org.apache.cactus.AbstractTestCase.runBare(AbstractTestCase.java:371)
 
----- ooo -----
 
I assume that I have made all the configs correctly.
 
I have been having this problem for a while and need help ... ...
 
My servlet engine: Tomcat 4.0.
My Webapp: cactusTrial.
 
 
My Servlet class: TestServlet: ( placed under: cactusTrial/WEB-INF/classes/)
 
----- ooo -----
 
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
 
public class TestServlet extends HttpServlet{
 
 public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException{
  getAuthor(request);
 }
 
 public String getAuthor(HttpServletRequest request){
  return (String)request.getSession().getAttribute("author");
 }
 
}
 
----- ooo -----
 
My test class: CactusTest : ( AT SERVER: placed under cactusTrial/WEB-INF/classes) and under my client: c:/cactusClient/ )
 
----- ooo -----
 
import org.apache.cactus.*;
import junit.framework.*;
 
public class CactusTest extends ServletTestCase{
 
 private TestServlet servlet;
 
 public CactusTest(String theName){
  super(theName);
 }
 
 protected void setUp(){
  servlet = new TestServlet();
 }
 
 public static Test suite(){
  TestSuite suite = new TestSuite();
  suite.addTest(new CactusTest("testGetAuthor"));
  return suite;
 }
 
 public void testGetAuthor(){
  session.setAttribute("author", "cactus tests author");
  String result = servlet.getAuthor(request);
  assertEquals("cactus tests author", result);
 }

} // end class
 
 
I have ensured the following points:
 
1.    "cactus.properties " IS in the classpath of the client. All the required libs ( cactus.jar, junit.jar ... ... )
2.    Server side libs are all put in the WEB-INF/lib/
 
 
I seem to have followed all the points given in the " ... howto".
 
When I run the Junit test runner I get the above " StreamCorruptedException ".
 
Can any one has an answer??
 
Cheers.
 
Shridhar Dhoopad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Reply via email to