tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen Riek <stephenr...@yahoo.co.uk>
Subject Re: Tomcat Filter with RequestDispatcher - IncompatibleClassChangeError
Date Wed, 27 Nov 2002 07:29:23 GMT

Thanks for the reply, Craig. 
> > Error Trace
> > -----------
> >
> > java.lang.IncompatibleClassChangeError
> 
> This exception normally means you have made a change in a superclass and
> recompiled it, but not recompiled a subclass that depends on the old APIs.

mmmmm, I have no idea which class this could be referring 
to then, unless it means one of Tomcat's distribution 
classes. To further debug, I removed ALL other classes 
under "WEB-INF/classes", so that I only have my one Filter
there. I also removed all jars from WEB-INF/lib, then
 restarted Tomcat.  Therefore, the only superclass involved
is the Filter class.

I recompiled my LanguageFilter.java and yet the error 
still occured. 


> > at mas.TestFilter.doFilter(Store/LanguageFilter.java:35)
> 
> What is "Store"? Is that supposed to be the package name?

Sorry, yes, I copied an earlier/older trace. 

> You should recompile *all* your classes to catch any cases
> where you've  made incompatible changes.

I've done exactly that now (basically due to the fact that
I only have the ONE class - the LanguageFilter.java)  

I have even deleted the entire contents of the "<tomcat_home>/work"
 directory and restarted Tomcat again to ensure that it 
is not an old class being cached in memory.

Interestingly, the very first time that I make a request to 
the Filter, I get the following error message:

<snip>

java.lang.LinkageError: Class javax/servlet/RequestDispatcher violates loader constraints
 at test.LanguageFilter.doFilter(test/LanguageFilter.java:36)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
 at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:215)
 at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
 at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
 at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
 at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)

</snip>

Yet when I hit "reload" the error message changes to:

<snip>

java.lang.IncompatibleClassChangeError
	at test.LanguageFilter.doFilter(test/LanguageFilter.java:36)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:215)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
	at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
	at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2366)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
	at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)

</snip>

These error messages were created with this Filter code
and I've added the check you suggested in your earlier 
reply.

<snip>

package test;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public final class LanguageFilter implements Filter {
    
 private FilterConfig filterConfig = null;
 
 public void init(FilterConfig filterConfig) {
  this.filterConfig = filterConfig;
 }
 
 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
  String servletPath = ((HttpServletRequest) request).getServletPath();
  // If the first element is '/en/' or '/fr/' :
  if (servletPath.indexOf("/en/") == 0 || servletPath.indexOf("/fr/") == 0) {
   String lang = servletPath.substring(1,3);
   request.setAttribute("lang", lang);
   String targetURL = servletPath.substring(3);
   System.out.println(targetURL);
   RequestDispatcher rd = null;
   ServletContext sc = this.filterConfig.getServletContext();
   rd = sc.getRequestDispatcher(targetURL);
   System.out.println("ok, RequestDispatcher created");
   if (rd!=null) {
    rd.forward(request, response);
   }
   return;
  }
  // No language match, so just handle the request as normal.
  chain.doFilter(request, response);
 }

    public void destroy() {
    }


}

</snip>

It works fine for URLs that do not start with /en/ or /fr/
so it really does seem to be a RequestDispatcher and not
Filter problem.

Stephen.




---------------------------------
With Yahoo! Mail you can get a bigger mailbox -- choose a size that fits your needs

Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message