开发者

NotSerializableException escaping Spring Controller and causing problems with Google App Engine Queue

开发者 https://www.devze.com 2023-03-09 20:57 出处:网络
I have a Spring Controller that is being invoked via an HTTP POST from the GAE Queue Scheduler. @Controller

I have a Spring Controller that is being invoked via an HTTP POST from the GAE Queue Scheduler.

@Controller
@RequestMapping(value = RSSPoller.RSS_POLLER_URL)
public class RSSPoller implements Serializable {
  private static final long serialVersionUID = -4925178778477404709L;

  public static final String RSS_POLLER_URL = "/rsspoller";

  @RequestMapping(method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.OK)
  public void pollAndProcessRssFeed() throws ServiceException  {
    try  {
      // do some stuff
    }
    catch(Exception e)  {
      throw new ServiceException("Can't process RSS feed because", e);
    }
  }
}

However when it gets invoked, the response code is 500 with a Critical log message of

Uncaught exception from servlet
java.lang.RuntimeException: java.io.NotSerializableException: <some spring class that changes all the开发者_运维问答 time, but does not implement java.io.Serializable>

The same log message shows up in the logs with a Warning level as well.

I get similar warning messages (but not critical) in my logs when I invoke other Spring Controllers that either render a web page (GET), or returns some XML data (essentially RPC invokes which use HTTP POST). When I do an HTTP GET/POST to those URLs, the response code is 200 and the output is correct (and I ignore the warning message in the logs).

That leads me to two questions:

  1. Why do I get the Critical error message/HTTP 500 for the POST from the queue, but not the GET/POST to other Spring Controllers in my app?
  2. How can I trap the exception and essentially discard it; as to my purposes the task is complete.

I can post the full exception log if it's of use; for brevity I've omitted it.


you should make your <some spring class that changes all the time, but does not implement java.io.Serializable> just Serializable (not only Controller). Me at least helped it.

0

精彩评论

暂无评论...
验证码 换一张
取 消