dev@grizzly.java.net

ClassCastException occurred when I set a custom thread pool with enabling JMX

From: Bongjae Chang <bongjae.chang_at_gmail.com>
Date: Tue, 18 Dec 2012 16:14:09 +0900

Hi,

When I used the HttpServer with enabling JMX and set a custom thread pool, I
met a ClassCastException.

The exception is below:
---
java.lang.ClassCastException: com.kakao.common.util.KakaoThreadPoolExecutor
cannot be cast to org.glassfish.grizzly.threadpool.GrizzlyExecutorService
at 
org.glassfish.grizzly.nio.transport.jmx.NIOTransport.rebuildSubTree(NIOTrans
port.java:258)
at 
org.glassfish.grizzly.nio.transport.jmx.NIOTransport.onRegister(NIOTransport
.java:127)
at 
org.glassfish.grizzly.monitoring.jmx.GrizzlyJmxManager.register(GrizzlyJmxMa
nager.java:103)
at 
org.glassfish.grizzly.http.server.jmx.NetworkListener.rebuildSubTree(Network
Listener.java:258)
at 
org.glassfish.grizzly.http.server.jmx.NetworkListener.onRegister(NetworkList
ener.java:110)
at 
org.glassfish.grizzly.monitoring.jmx.GrizzlyJmxManager.register(GrizzlyJmxMa
nager.java:103)
at 
org.glassfish.grizzly.http.server.jmx.HttpServer.rebuildSubTree(HttpServer.j
ava:149)
at 
org.glassfish.grizzly.http.server.jmx.HttpServer.onRegister(HttpServer.java:
98)
at 
org.glassfish.grizzly.monitoring.jmx.GrizzlyJmxManager.registerAtRoot(Grizzl
yJmxManager.java:87)
at 
org.glassfish.grizzly.http.server.HttpServer.enableJMX(HttpServer.java:531)
at org.glassfish.grizzly.http.server.HttpServer.start(HttpServer.java:274)
at 
com.kakao.api.server.GrizzlyWebServerBean.startWebServer(GrizzlyWebServerBea
n.java:132)
at 
com.kakao.api.server.GrizzlyWebServerBeanTest.basicTest(GrizzlyWebServerBean
Test.java:50)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
---
If a user set a custom thread pool and JMX is enabled, I think that it is
better that a user can use other monitorings such as Filters, Listeners and
Transports except for thread pool.
I attached the proposed patch based on 2.2.x simply.
Thanks!
Regards,
Bongjae Chang