users@jersey.java.net

[Jersey] Re: ClassCastException: org.glassfish.grizzly.http.util.MimeHeaders$1 cannot be cast to java.util.Enumeration

From: Farrukh Najmi <farrukh_at_wellfleetsoftware.com>
Date: Mon, 27 Feb 2012 15:18:51 -0500

Hi Guys,

I have now worked around the package scanning issue using explicit
declaration of root and provider resources by extending
com.sun.jersey.api.core.DefaultResourceConfig in jesrey server.

I am now back to getting the trace: ClassCastException:
org.glassfish.grizzly.http.util.MimeHeaders$1 cannot be cast to
java.util.Enumeration

It would help if I can log the request received by my server (running
inside webstart app). I do set the ContainerRequestFilters initParam
using following code:

             org.glassfish.grizzly.servlet.ServletHandler servletHandler
= ...
             
servletHandler.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters",
"com.sun.jersey.api.container.filter.LoggingFilter");
             
servletHandler.addInitParameter("com.sun.jersey.spi.container.ContainerResponseFilters",
"com.sun.jersey.api.container.filter.LoggingFilter");

The logging of requests works when I run the app with my jersey server
as a standalone app. It does not work when I run it via Java webstart.

Can someone familiar with the logging code tell me what may cause the
logging filters to not work when running inside webstart and what I can
try to fix this? Thanks for any pointers.

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)

On 02/27/2012 11:33 AM, Farrukh Najmi wrote:
>
> I am using com.sun.jersey.spi.spring.container.servlet.SpringServlet
> rathert than the com.sun.jersey.spi.container.servlet.ServletContainer
> suggested in the second option (trying the
> web-based scanning configuration in WEB-INF/lib and WEB-INF/classes).
> I already use the "com.sun.jersey.config.property.packages" init param
> on the SpringServlet as follows:
>
>
> servletHandler.addInitParameter("com.sun.jersey.config.property.packages",
> getAsString(packagesToScan));
>
> So this option doe snot seem to work.
>
> Anyone have any advice on this?
>
>
>


-- 
Regards,
Farrukh Najmi
Web: http://www.wellfleetsoftware.com