Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] How to enable extended listener types for a servlet context?

Thanks Jan, indeed precisely as you pointed you. Just for the sake of reference and documentation, it is not necessary to include Spring's ContextLoaderListener in such setup as everything is wired and initialized through Java configuration.


On Thu, Jan 16, 2014 at 6:48 AM, Jan Bartel <janb@xxxxxxxxxxx> wrote:
Behrooz,

You're trying to add a context listener too late in the webapp's
lifecycle: you're already into initializing servlets.

If you want to programmatically add this listener, do it before you
start the webapp.

Jan

On 14 January 2014 06:40, Behrooz N <nobeh5@xxxxxxxxx> wrote:
> Hi,
>
> I was trying to set up an embedded Jetty 9.1, Jersey 2.5, Spring 4
> application and tried to register Spring’s ContextLoaderListener with the
> servlet context that I get from Jetty using servletContext.addListener(new
> ContextLoaderListener(springAppContext))
>
> How ever, by default, I get an exception as:
>
> Caused by: java.lang.IllegalArgumentException: Inappropriate listener class
> org.springframework.web.context.ContextLoaderListener
>     at
> org.eclipse.jetty.server.handler.ContextHandler$Context.checkListener(ContextHandler.java:2247)
>     at
> org.eclipse.jetty.server.handler.ContextHandler$Context.addListener(ContextHandler.java:2197)
>     at
> org.eclipse.jetty.servlet.ServletContextHandler$Context.addListener(ServletContextHandler.java:1294)
>     at
> com.narmnevis.papyrus.SpringContainerLifeCycleListener.onStartup(SpringContainerLifeCycleListener.java:54)
>     at
> org.glassfish.jersey.server.internal.ConfigHelper$3.onStartup(ConfigHelper.java:95)
>     at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:171)
>     at
> org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:359)
>     at javax.servlet.GenericServlet.init(GenericServlet.java:244)
>     at
> org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:561)
>     ... 23 more
>
> When I looked into ContextHandler$Context, it seems there is a method:
>
> org.eclipse.jetty.server.handler.ContextHandler.Context.setExtendedListenerTypes(boolean)
>
> But the question is how I can use this method because it’s basically very
> down the implementation? Is there a standard way to enable this feature?
>
> Thanks,
> Behrooz
>
> --
> -- Behrooz Nobakht
>
> _______________________________________________
> jetty-dev mailing list
> jetty-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev



--
-- Behrooz Nobakht

Back to the top