NutzCN Logo
问答 接口请求,java.lang.OutOfMemoryError: Java heap space
发布于 1471天前 作者 @yz 1788 次浏览 复制 上一个帖子 下一个帖子
标签:

请求同一个接口。
第一次请求,报如下错误信息:
但是第二次请求并不会报错。

javax.servlet.ServletException: java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space
	at org.apache.shiro.web.servlet.AdviceFilter.cleanup(AdviceFilter.java:196)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:148)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
	at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
	at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
	at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
	at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
	at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
	at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at com.tzding.tzd.application.filter.RouteFilter.doFilter(RouteFilter.java:61)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.nutz.mvc.WhaleFilter.doFilter(WhaleFilter.java:171)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1634)
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:215)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:533)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1317)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:473)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1564)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1219)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
	at org.eclipse.jetty.server.Server.handle(Server.java:531)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:352)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:281)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:132)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:762)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:680)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: java.lang.OutOfMemoryError: Java heap space
	at org.nutz.lang.Lang.wrapThrow(Lang.java:187)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:52)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1642)
	at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
	at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
	at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
	... 44 more
Caused by: java.lang.OutOfMemoryError: Java heap space
	at java.util.Arrays.copyOf(Arrays.java:3332)
	at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
	at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
	at java.lang.StringBuilder.append(StringBuilder.java:202)
	at org.nutz.lang.stream.StringWriter.write(StringWriter.java:23)
	at java.io.Writer.write(Writer.java:192)
	at java.io.Writer.write(Writer.java:157)
	at org.nutz.json.impl.JsonRenderImpl.doIntent(JsonRenderImpl.java:276)
	at org.nutz.json.impl.JsonRenderImpl.appendPairBegin(JsonRenderImpl.java:115)
	at org.nutz.json.impl.JsonRenderImpl.appendPair(JsonRenderImpl.java:126)
	at org.nutz.json.impl.JsonRenderImpl.writeItem(JsonRenderImpl.java:183)
	at org.nutz.json.handler.JsonPojoHandler.toJson(JsonPojoHandler.java:125)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.impl.JsonRenderImpl.appendPair(JsonRenderImpl.java:129)
	at org.nutz.json.impl.JsonRenderImpl.writeItem(JsonRenderImpl.java:183)
	at org.nutz.json.handler.JsonPojoHandler.toJson(JsonPojoHandler.java:125)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.handler.JsonArrayHandler.toJson(JsonArrayHandler.java:42)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.impl.JsonRenderImpl.appendPair(JsonRenderImpl.java:129)
	at org.nutz.json.impl.JsonRenderImpl.writeItem(JsonRenderImpl.java:183)
	at org.nutz.json.handler.JsonPojoHandler.toJson(JsonPojoHandler.java:125)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.handler.JsonArrayHandler.toJson(JsonArrayHandler.java:38)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.impl.JsonRenderImpl.appendPair(JsonRenderImpl.java:129)
	at org.nutz.json.impl.JsonRenderImpl.writeItem(JsonRenderImpl.java:183)
	at org.nutz.json.handler.JsonPojoHandler.toJson(JsonPojoHandler.java:125)
	at org.nutz.json.impl.JsonRenderImpl.render(JsonRenderImpl.java:82)
	at org.nutz.json.impl.JsonRenderImpl.appendPair(JsonRenderImpl.java:129)
	at org.nutz.json.impl.JsonRenderImpl.writeItem(JsonRenderImpl.java:183)
	at org.nutz.json.handler.JsonPojoHandler.toJson(JsonPojoHandler.java:125)
@At(value = "/login")
@POST
public Map<String, Object> login(UserLoginVo vo, HttpServletRequest request)	throws ServletException, IOException {
// ...
}
3 回复

看上去是你对某个对象执行了toJson,然后死循环了

在一个自定义的ViewProcessor类的方法里有这样的处理:

private ExceptionRecord getExceptionRecord(ActionContext ac) {
// ...
String postMsg = Json.toJson(ac.getMethodArgs());
// ...
}
添加回复
请先登陆
回到顶部