Vadim Kirilchuk
Vadim Kirilchuk

Reputation: 3542

Jboss: RestEasy + spring dispatcher servlet = no servlet class has been specified for servlet javax.ws.rs.core.Application

I have an application which is deployed to Jboss eap 6.4. In the web.xml I had javax.ws.rs.core.Application defined as servlet and registered for all urls starting with 'api' (/api/*).

<servlet>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>javax.ws.rs.core.Application</servlet-name>
    <url-pattern>1</url-pattern>
</servlet-mapping>

Some time ago I have added a spring DispatcherServlet as a second servlet registered for all urls starting with 'admin' (/admin/*)

  <servlet>
        <servlet-name>admin dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>...</init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>admin dispatcher</servlet-name>
        <url-pattern>/admin/*</url-pattern>
    </servlet-mapping>

Guess what? When I started an application I got the error in the subject.

no servlet class has been specified for servlet javax.ws.rs.core.Application

Upvotes: 0

Views: 541

Answers (1)

Vadim Kirilchuk
Vadim Kirilchuk

Reputation: 3542

By debugging RestEasy sources it appeared that somewhere very deep in the Jboss/RestEasy integration if RestEasy finds "org.springframework.web.servlet.DispatcherServlet" (hardcoded string) being used spmewhere in web.xml, it just stops autoconfiguration and later fails because being misconfigured.

There is a tricky workaround - just extend spring's dispatcher servlet MyDispatcherServlet extends DispatcherServlet and use it in the web.xml instead of a spring one. This is to trick the hardcoded string.

Voila - both RestEasy and spring dispathers started to work together.

Upvotes: 1

Related Questions