tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Williamson <>
Subject RE: A bit of an odd one
Date Thu, 01 Jun 2000 13:32:13 GMT

sorry to keep adding bits - my last comment was wrong 
about fixing it by putting it somewhere else. 

I have come to the conclusion that the reason I can't 
cast it is because I am using two different class loaders 
one for the Servlet and one for the JSP - when I do 
a toString() on the class loader for objects made in the Servlet and objects

made in the jsp I get different classes (the @9f81... bit at the 
end is different). 

How can this be so? I thought that the servlet engine and the
JSP engine in tomcat were all part of the same thing? 
How can I solve this problem and force them to use the 
same class loader?


-----Original Message-----
From: Mark Williamson []
Sent: 01 June 2000 13:01
To: ''
Subject: A bit of an odd one


A bit of an odd one this. Essentially we have a servlet 
that contains the following bit of code:

 Assembler assembler = new Assembler();
 req.setAttribute("Assembler", assembler);
 // get request dispatcher from servlet context
  RequestDispatcher requestDispatcher =
 // forward the request
  requestDispatcher.forward(req, res);

And in the jsp code (pointed to by template)
we have this :

 obj = request.getAttribute("Assembler");
 if ( obj != null )
	System.out.println( obj.getClass() );		// debugging stuff
	Assembler pageAssembler = (Assembler) obj;

What happens is that obj is indeed not null. The class comes 
out exactly as expected and then this error ensues: 

java.lang.ClassCastException: com.appropria.xtriffid.assembler.Assembler
	at javax.servlet.http.HttpServlet.service(

this is the root cause of a servlet exception. 

Does anyone have any idea why this is happening?



To unsubscribe, email:
For additional commmands, email:

To unsubscribe, email:
For additional commmands, email:

View raw message