0

My application has been running on glassfish server for quite some time now and today one of application user warned me that server was shut down unexpectedly. In server log I see following stack-traces (10 identically stack-traces before server was shut down):

[2016-01-23T10:35:35.144+0100] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.filterchain.DefaultFilterChain] [tid: _ThreadID=30 _ThreadName=http-listener-1(4)] [timeMillis: 1453541735144] [levelValue: 900] [[
  GRIZZLY0013: Exception during FilterChain execution
java.lang.OutOfMemoryError
    at java.util.zip.Deflater.init(Native Method)
    at java.util.zip.Deflater.<init>(Deflater.java:171)
    at org.glassfish.grizzly.compression.zip.GZipEncoder$GZipOutputState.initialize(GZipEncoder.java:323)
    at org.glassfish.grizzly.compression.zip.GZipEncoder$GZipOutputState.access$100(GZipEncoder.java:307)
    at org.glassfish.grizzly.compression.zip.GZipEncoder.transformImpl(GZipEncoder.java:133)
    at org.glassfish.grizzly.compression.zip.GZipEncoder.transformImpl(GZipEncoder.java:61)
    at org.glassfish.grizzly.AbstractTransformer.transform(AbstractTransformer.java:73)
    at org.glassfish.grizzly.http.GZipContentEncoding.encode(GZipContentEncoding.java:195)
    at org.glassfish.grizzly.http.HttpCodecFilter.encodeContent(HttpCodecFilter.java:1628)
    at org.glassfish.grizzly.http.HttpCodecFilter.encodeHttpPacket(HttpCodecFilter.java:1451)
    at org.glassfish.grizzly.http.HttpServerFilter.encodeHttpPacket(HttpServerFilter.java:870)
    at org.glassfish.grizzly.http.HttpCodecFilter.handleWrite(HttpCodecFilter.java:1347)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$8.execute(ExecutorResolver.java:111)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:848)
    at org.glassfish.grizzly.filterchain.FilterChainContext.write(FilterChainContext.java:817)
    at org.glassfish.grizzly.http.io.OutputBuffer.flushBuffer(OutputBuffer.java:1024)
    at org.glassfish.grizzly.http.io.OutputBuffer.flushBinaryBuffers(OutputBuffer.java:1011)
    at org.glassfish.grizzly.http.io.OutputBuffer.flushAllBuffers(OutputBuffer.java:982)
    at org.glassfish.grizzly.http.io.OutputBuffer.close(OutputBuffer.java:715)
    at org.glassfish.grizzly.http.io.OutputBuffer.endRequest(OutputBuffer.java:378)
    at org.glassfish.grizzly.http.server.Response.finish(Response.java:516)
    at org.glassfish.grizzly.http.server.HttpServerFilter.afterService(HttpServerFilter.java:384)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:260)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
    at java.lang.Thread.run(Thread.java:745)
]]

I was trying to found out what was the cause of this exception but I can't find any useful explanation - none of the answers describes this kind of exception ( GRIZZLY0013: Exception during FilterChain execution with java.lang.OutOfMemoryError). Can please anybody explain to me why this happened and what can I do to prevent it from happening again?

Thank you.

user4341206
  • 647
  • 1
  • 7
  • 26

2 Answers2

1

The server ran out of Memory and then the JVM probably crashed. The error is occurring writing an HTTP Response.

Set the JVM option -XX:+HeapDumpOnOutOfMemoryError so that if it happens again you can get a HeapDump that you can analyse using something like Eclipse Memory Analyzer Toolkit that way you can find out what's using all the heap.

leet java
  • 304
  • 1
  • 3
  • Yes I know that error was the result of writing an HTTP Response. How can this happen? Do I have bug or memory leak in my code or is this a bug in grizzly framework? – user4341206 Jan 25 '16 at 05:41
1

java.lang.OutOfMemoryError usually points to a memory leak. It may be caused by your application as well as by Glassfish, as both run in the same JVM. The exception only states that JVM cannot allocate new objects, but does not tell what is holding the memory.

From the stacktrace, I would guess that Glassfish was trying to process response before sending it to the browser. I could have happened that the resposne was too big to be compressed in memory before sent over HTTP protocol. Try to see other logs to reconstruct what the request was doing and whether it could generate a huge response. But this is only a guess, as there may be other causes of memory consumption completely unrelated to the request being processed.

You may also increase memory limits for Glassfish by setting JVM option -Xmx.

OndroMih
  • 7,280
  • 1
  • 26
  • 44