简体   繁体   中英

Google App Engine: Filter-related NoClassDefFoundError in Deployed Version

I am developing using Google App Engine (1.8.7) in Java. I have the following filter in my web.xml file...

<filter>
     <filter-name>MultiReadRequestFilter</filter-name>
    <filter-class>com.fitc.general.MultiReadRequestFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>MultiReadRequestFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

For info the filter wraps the For info the file allows multiply reads to HttpRequest by caching the request :

 @Override
 public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
      /* wrap the request in order to read the inputstream multiple times
      MultiReadHttpServletRequest multiReadRequest = new MultiReadHttpServletRequest((HttpServletRequest) request);
     chain.doFilter(multiReadRequest, response);
 }

Anyway. Everything works swimmingly on my localhost dev server but when I deploy to GAE something breaks. I get the following error in my GAE log:

Error for /_ah/spi/BackendService.getApiConfigs java.lang.NoClassDefFoundError: 
Could not initialize class com.fitc.general.MultiReadHttpServletRequest at
    com.fitc.general.MultiReadRequestFilter.doFilter(MultiReadRequestFilter.java:23)
        at
    org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
        at
    com.googlecode.objectify.cache.AsyncCacheFilter.doFilter(AsyncCacheFilter.java:59)
    (...as so on!)

Does anyone know what might be happening to cause this? I have a couple of other filters and they run fine when deployed. I wondered whether perhaps it was that these used jars so I made a jar of my MultiReadHttpServletRequest class and stuck it on buildpath and lib/ directory... no luck.

So if anyone else has a java.lang.NoClassDefFoundError issue on GAE, its worth checking that GAE supports that 'whatevers' you import in your code. I was using java.util.ResourceBundle for something or other, which is not supported by GAE...but would of course work on local machine running with Java JDK.

So nought to do with filters or HttpRequests at all. Who knew eh? Glad I did not waste a day fiddling with it huh! Hummm?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM