Hi Alexey,
Thanks for the quick response. I was out of the office and just filed
the following issue:
http://java.net/jira/browse/GRIZZLY-1208
Thanks very much for your kind help. Please let me know if I can help
test a patch or help in any other way.
On 02/27/2012 05:11 PM, Oleksiy Stashok wrote:
> Hi Farrukh,
>
> it's a bug, can I ask you to file an issue?
> Will fix this asap.
>
> Thanks.
>
> WBR,
> Alexey.
>
> On 02/27/2012 01:45 PM, Farrukh Najmi wrote:
>> Hi Guys,
>>
>> I have a jersey server endpoint exposed via an HttpServer created
>> using com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory from
>> jersey 1.10 (with dependency
>> org.glassfish.grizzly.servlet.HttpServletRequestImpl from grizzly
>> 2.1.2).
>>
>> The jersey server is within a Swing app and is used to sync the Swing
>> app with changes in teh rest of the system.
>>
>> Everything works great when I run my Swing app standalone. However,
>> if I package my Swing app as a webstart application with signed jars
>> and access it via java webstart / jnlp I get teh following exception
>> during request header processing:
>>
>> java.lang.ClassCastException:
>> org.glassfish.grizzly.http.util.MimeHeaders$1 cannot be cast to
>> java.util.Enumeration
>> at
>> org.glassfish.grizzly.servlet.HttpServletRequestImpl.getHeaderNames(HttpServletRequestImpl.java:822)
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.getHeaders(WebComponent.java:880)
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.createRequest(WebComponent.java:450)
>> at
>> com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:380)
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
>> at
>> com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:708)
>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
>> at
>> org.glassfish.grizzly.servlet.ServletHandler$FilterChainImpl.doFilter(ServletHandler.java:985)
>> at
>> org.glassfish.grizzly.servlet.ServletHandler$FilterChainImpl.invokeFilterChain(ServletHandler.java:928)
>> at
>> org.glassfish.grizzly.servlet.ServletHandler.doServletService(ServletHandler.java:382)
>> at
>> org.glassfish.grizzly.servlet.ServletHandler.service(ServletHandler.java:330)
>> at
>> org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
>> at
>> org.glassfish.grizzly.http.server.HttpHandlerChain.service(HttpHandlerChain.java:195)
>> at
>> org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:163)
>> at
>> org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:158)
>> at
>> org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
>> at
>> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:286)
>> at
>> org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:223)
>> at
>> org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:155)
>> at
>> org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:134)
>> at
>> org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:78)
>> at
>> org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:827)
>> at
>> org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:103)
>> at
>> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:111)
>> at
>> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
>> at
>> org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:131)
>> at
>> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:508)
>> at
>> org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:488)
>> at java.lang.Thread.run(Thread.java:619)
>>
>>
>> Having debugged it I find that the problem seems to be in
>> org.glassfish.grizzly.servlet.HttpServletRequestImpl method "public
>> Enumeration getHeaderNames()" when (System.getSecurityManager() !=
>> null) is true. In my case System.getSecurityManager() returns a
>> com.sun.javas.security.JavaWebstartSecurityManager instance.
>>
>> Debugger shows that the following code:
>>
>> AccessController.doPrivileged(
>> new GetHeaderNamesPrivilegedAction())
>>
>> returns a org.glassfish.grizzly.htt.util.MimeHeaders.$1 rather than
>> an Enumeration which results in a ClassCastException.
>>
>> If I set the System.getSecurityManager() to null in debugger then
>> else clause for the if is executed instead and all is well. Thsi
>> explains why in standalone mode things work.
>>
>> This is a complex problem involving many moving parts and I would be
>> very grateful if someone from the dev team could please tell me if
>> this is a known issue, is it a problem in Glassfish or is it in
>> Grizzly, if there are any workarounds or anything else that will help
>> and where to go from here.
>>
>> Thank you for your help.
>>
>
--
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com