0

I'm trying to use the URLRewriteFilter in combination with a number of different types of resources. It works perfectly fine for static resources and regular servlets. For JAX-RS-based services however, I get a 404.

This is the situation: There are two web applications:

  • base
  • base#nested

Requests for /base/Something/nested/furtherPath need to be forwarded to /base/nested/furtherPath. This implies forwarding from the /base context to the /base/nested context.

To do that, I configured the URLRewrite filter on the /base context:

<filter>
    <filter-name>UrlRewriteFilter</filter-name>
    <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter
    </filter-class>
    <init-param>
        <param-name>logLevel</param-name>
        <param-value>DEBUG</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

The rules (urlrewrite.xml) are as follows:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite use-context="true">
    <rule>
        <from>/base/([^/]*)/([^/]*)/(.*)</from>
        <to type="forward" context="base/nested">/$3</to>        
    </rule>
</urlrewrite>

The crossContext attribute of the /base context is set to true.

This works perfectly fine for regular servlets and static resources but not for JAX-RS services. I'm doing this in TomEE JAX-RS 1.6.0.

Your help is appreciated!

Bert
  • 861
  • 9
  • 22
  • Is there a reason you have to use tuckey? Project's been dormant for 2.5 years. As best as I can tell, no JAX-RS support. OCP Soft rewrite has tuckey support - http://ocpsoft.org/rewrite/ – John Ament Dec 13 '14 at 01:08
  • No particular reason, other then that we're looking for a servlet filter to do this job. An alternative is fine, so I'll look into OCP Soft. Thanks for the suggestion! – Bert Dec 13 '14 at 16:24
  • I got pulled off this work all of a sudden, so can't tell yet whether OCP Soft works for us. After the Christmas break, I'll take this on again and get back here. – Bert Dec 19 '14 at 09:06

0 Answers0