You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Christoph Leiter <ma...@christophleiter.com> on 2012/04/03 12:55:53 UTC

Wicket with ServletContainerInitializer

Hi,

I'm trying to use ServletContainerInitializer to start my wicket 
application. There's already work done to support this in WICKET-4350. 
It's not working for me, however. The filter is registered in jetty but 
I get a 404 response for every request.

What I've done so far (starting from a quickstart):
1) Add dependency: 
org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910
2) Delete web.xml
3) Create file 
META-INF/services/javax.servlet.ServletContainerInitializer with the 
content com.mycompany.Initializer
4) Add AnnotationConfiguration to the jetty configuration:
bb.setConfigurations(new Configuration[] { new AnnotationConfiguration() });
5) Add Initializer:

| public class Initializer implements ServletContainerInitializer {
|    @Override
|     public void onStartup(Set<Class<?>> c, ServletContext 
servletContext) throws ServletException {
|         WicketApplication app = new WicketApplication();
|         app.setConfigurationType(RuntimeConfigurationType.DEVELOPMENT);
|         WicketFilter wicketFilter = new WicketFilter(app);
|         wicketFilter.setFilterPath("");
|         Dynamic filter = servletContext.addFilter("wicket", wicketFilter);
| 
filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), 
true, "/*");
|     }
| }

That's the relevant part of the jetty debug log for the filter registration:

| DEBUG - Container                  - Container 
org.eclipse.jetty.servlet.ServletHandler@78334ba0 + wicket as filter
| DEBUG - Container                  - Container 
org.eclipse.jetty.servlet.ServletHandler@78334ba0 + [/*]/[]==31=>wicket 
as filterMapping
| DEBUG - ServletHandler             - filterNameMap={wicket=wicket}
| DEBUG - ServletHandler             - pathFilters=[[/*]/[]==31=>wicket]
| DEBUG - ServletHandler             - servletFilterMap={}
| DEBUG - ServletHandler             - servletPathMap=null
| DEBUG - ServletHandler             - servletNameMap={}
| DEBUG - AbstractLifeCycle          - starting wicket
| DEBUG - WebAppClassLoader          - loaded class 
org.apache.wicket.Initializer from sun.misc.Launcher$AppClassLoader@7981c4eb
| INFO  - Application                - [wicket] init: Wicket core 
library initializer

The log for a request to /:

| DEBUG - Server                     - REQUEST / on 
BlockingHttpConnection@3c7352d1,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=18,c=0},r=1
| DEBUG - ContextHandler             - scope null||/ @ 
o.e.j.w.WebAppContext{/,null},src/main/webapp
| DEBUG - ContextHandler             - context=||/ @ 
o.e.j.w.WebAppContext{/,null},src/main/webapp
| DEBUG - session                    - 
sessionManager=org.eclipse.jetty.server.session.HashSessionManager@efc0830
| DEBUG - session                    - session=null
| DEBUG - ServletHandler             - servlet ||/ -> null
| DEBUG - ServletHandler             - chain=null
| DEBUG - ServletHandler             - Not Found /
| DEBUG - Server                     - RESPONSE /  404

Environment is Wicket 1.5.5, jetty 8.1.2. I tried with Tomcat 7 as well 
but no luck either.

Any help is appreciated


Christoph

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Wicket with ServletContainerInitializer

Posted by Christoph Leiter <ma...@christophleiter.com>.
Hi,

I'll reply to my own message. :) Martin Grigorov figured out that Jetty 
doesn't install the DefaultServlet in this configuration. Without a 
servlet the WicketFilter cannot work.

There's now new working sample code at
https://issues.apache.org/jira/browse/WICKET-4350


Christoph


Christoph Leiter (2012-04-03 12:55):
> Hi,
>
> I'm trying to use ServletContainerInitializer to start my wicket
> application. There's already work done to support this in WICKET-4350.
> It's not working for me, however. The filter is registered in jetty but
> I get a 404 response for every request.
>
> What I've done so far (starting from a quickstart):
> 1) Add dependency:
> org.eclipse.jetty.orbit:org.objectweb.asm:3.1.0.v200803061910
> 2) Delete web.xml
> 3) Create file
> META-INF/services/javax.servlet.ServletContainerInitializer with the
> content com.mycompany.Initializer
> 4) Add AnnotationConfiguration to the jetty configuration:
> bb.setConfigurations(new Configuration[] { new AnnotationConfiguration()
> });
> 5) Add Initializer:
>
> | public class Initializer implements ServletContainerInitializer {
> | @Override
> | public void onStartup(Set<Class<?>> c, ServletContext servletContext)
> throws ServletException {
> | WicketApplication app = new WicketApplication();
> | app.setConfigurationType(RuntimeConfigurationType.DEVELOPMENT);
> | WicketFilter wicketFilter = new WicketFilter(app);
> | wicketFilter.setFilterPath("");
> | Dynamic filter = servletContext.addFilter("wicket", wicketFilter);
> | filter.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class),
> true, "/*");
> | }
> | }
>
> That's the relevant part of the jetty debug log for the filter
> registration:
>
> | DEBUG - Container - Container
> org.eclipse.jetty.servlet.ServletHandler@78334ba0 + wicket as filter
> | DEBUG - Container - Container
> org.eclipse.jetty.servlet.ServletHandler@78334ba0 + [/*]/[]==31=>wicket
> as filterMapping
> | DEBUG - ServletHandler - filterNameMap={wicket=wicket}
> | DEBUG - ServletHandler - pathFilters=[[/*]/[]==31=>wicket]
> | DEBUG - ServletHandler - servletFilterMap={}
> | DEBUG - ServletHandler - servletPathMap=null
> | DEBUG - ServletHandler - servletNameMap={}
> | DEBUG - AbstractLifeCycle - starting wicket
> | DEBUG - WebAppClassLoader - loaded class org.apache.wicket.Initializer
> from sun.misc.Launcher$AppClassLoader@7981c4eb
> | INFO - Application - [wicket] init: Wicket core library initializer
>
> The log for a request to /:
>
> | DEBUG - Server - REQUEST / on
> BlockingHttpConnection@3c7352d1,g=HttpGenerator{s=0,h=-1,b=-1,c=-1},p=HttpParser{s=-5,l=18,c=0},r=1
>
> | DEBUG - ContextHandler - scope null||/ @
> o.e.j.w.WebAppContext{/,null},src/main/webapp
> | DEBUG - ContextHandler - context=||/ @
> o.e.j.w.WebAppContext{/,null},src/main/webapp
> | DEBUG - session -
> sessionManager=org.eclipse.jetty.server.session.HashSessionManager@efc0830
> | DEBUG - session - session=null
> | DEBUG - ServletHandler - servlet ||/ -> null
> | DEBUG - ServletHandler - chain=null
> | DEBUG - ServletHandler - Not Found /
> | DEBUG - Server - RESPONSE / 404
>
> Environment is Wicket 1.5.5, jetty 8.1.2. I tried with Tomcat 7 as well
> but no luck either.
>
> Any help is appreciated
>
>
> Christoph
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org