tomcat-users mailing list archives

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

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?

mark


-----Original Message-----
From: Mark Williamson [mailto:Mark.Williamson@Appropria.com]
Sent: 01 June 2000 13:01
To: 'tomcat-user@jakarta.apache.org'
Subject: A bit of an odd one


Hi,

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 =
servletContext.getRequestDispatcher(template);
 // 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
jsp._0002fjsp_0002fstandard_0002ejspstandard_jsp_42._jspService(_0002fjsp_00
02fstandard_0002ejspstandard_jsp_42.java:104)
	at
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	[snip]

this is the root cause of a servlet exception. 

Does anyone have any idea why this is happening?

cheers 

mark

--------------------------------------------------------------------------
To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
For additional commmands, email: tomcat-user-help@jakarta.apache.org

--------------------------------------------------------------------------
To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
For additional commmands, email: tomcat-user-help@jakarta.apache.org

Mime
View raw message