t777
t777

Reputation: 3329

Wicket and Jersey2 in same web.xml

I am trying to use a wicket application and a jersey 2 REST-service together.

This is my web.xml:

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <display-name>TBDB-Web-Application</display-name>

    <!--  SPRING CONTEXT -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/applicationContext.xml</param-value>
    </context-param>

    <!--  REST SERVICE -->
    <servlet>
        <servlet-name>rest.tbdb</servlet-name>
        <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
        <init-param>
            <param-name>javax.ws.rs.Application</param-name>
            <param-value>tbdb.rest.RestApplication</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>rest.tbdb</servlet-name>
        <url-pattern>/webapi/*</url-pattern>
    </servlet-mapping>

    <!--  WICKET APP -->
    <filter>
        <filter-name>wicket.tbdb</filter-name>
        <filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
        <init-param>
            <param-name>applicationClassName</param-name>
            <param-value>tbdb.wicket.WicketApplication</param-value>
        </init-param>
        <init-param>
            <param-name>ignorePaths</param-name>
            <param-value>/css,/js,/img</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>wicket.tbdb</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

The wicket-app and the rest-service work well, but it seems to be, that every rest-request goes through some wicket-classes/filters.

I think the problem is, that the rest app is configured as a servlet and the wicket app as a filter. But changing the rest app to a filter config, does not work.

Any ideas? TIA!

Upvotes: 0

Views: 369

Answers (1)

svenmeier
svenmeier

Reputation: 5681

You've configured the Wicket filter to handle /*, so of course all request are examined by Wicket code. Although this should do no harm, you can use the "ignorePaths" init-param (it's comma separated) to skip "/webapi/" explicitely.

Upvotes: 1

Related Questions