Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with Tomcat 9 #246

Open
vmassol opened this issue Jul 11, 2022 · 10 comments
Open

Not compatible with Tomcat 9 #246

vmassol opened this issue Jul 11, 2022 · 10 comments

Comments

@vmassol
Copy link

vmassol commented Jul 11, 2022

Tomcat 9 performs very early mapping of incoming requests before the URLRewriteFilter has a chance to execute (this was working fine in Tomcat 8 and probably earlier versions too).

See https://jira.xwiki.org/browse/XWIKI-19444?focusedCommentId=112420&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-112420 for an explanation based on the XWiki use case of URLRewriteFilter

@paultuckey
Copy link
Owner

UrlRewriteFilter has fallen behind in it's support of modern versions of app servers. It think it would be best to shop around for an alternative.

Tomcat 9 includes it's own rewrite engine. Perhaps it would be better to use that?
https://tomcat.apache.org/tomcat-9.0-doc/rewrite.html

Note, I'm more than happy to accept any PRs that have full test coverage across a variety of containers.

@vmassol
Copy link
Author

vmassol commented Jul 12, 2022

Thanks for the answer @paultuckey

Yeah I had realized it has fallen behind. It's still a great and elegant solution though ;)

Actually I've reported this issue here to let users know but it would probably be more accurate to report it on the Tomcat side as I believe the way they have coded Tomcat 9 prevents any URL rewriting from working transparently.

PS: yes I have noticed the rewrite valve. I need to find some time to check if it can work for our use case but I don't think it would as we are also rewriting outbound URLs and this is done through our call to getResponse().encodeURL(url);, which triggers the URLRewriteFilter. I don't see how any solution that is not executing under the same webapp would work to rewrite the URLs we generate in our responses (the solution would need to parse the content to make replacements AFAICS).

Thanks!

@octafishmedia
Copy link

octafishmedia commented Sep 11, 2022

I've recently migrated a java legacy app running struts1 (originally developed back in 2005-2008!) but had consistent crashes (every other day) on our virtual web server running Tomcat 9. I rolled back the urlrewritefilter to version 4.0.3 and found stability. However after a few weeks of intermittent crashes (once a week maybe, tomcat freezes when heap size maxes out) I'm considering eliminating it all together to avoid further headaches.

Any recommendations for replacing this well used tool (for years)?

@paultuckey
Copy link
Owner

paultuckey commented Sep 11, 2022

Perhaps use Nginx in front as rewriting proxy, or the built-in tomcat rewrite valve mentioned above. It's also relatively simple to write your own custom filter for your specific use-case.

@paultuckey
Copy link
Owner

5.1.1 should now work with tomcat 9.

@octafishmedia
Copy link

octafishmedia commented Oct 19, 2023

Tomcat 9 recommends Servlet 4.0 usage (https://tomcat.apache.org/whichversion.html)

Updated README says to use older version 4.0.3 w/ Servlet spec 4.0

When I use Tomcat 9 + version 5.1.2 + Servlet 4.0 I get...

SEVERE: Exception starting filter [UrlRewriteFilter]
java.lang.NoClassDefFoundError: jakarta/servlet/Filter

@paultuckey
Copy link
Owner

Apologies, I was confused about this. Looks like Tomcat 9 users will have to stay on version 4.0.3.

If anyone want to submit a PR to fix this issue (use the 4.x branch) I'd be happy to accept it.

@paultuckey paultuckey reopened this Oct 19, 2023
@stevesobol
Copy link

Looking for feedback on https://github.com/lobosstudios/xwiki_urlrewrite

I'm running XWiki 15.5.0/Tomcat 9.0.76 and URL rewrites seem to work fine.

@acotiuga
Copy link

@stevesobol I'm updating here for you: https://github.com/lobosstudios/xwiki_urlrewrite still presents the incompatibility reported in this issue, but only on certain actions as discussed in: https://forum.xwiki.org/t/xwiki-docker-image-with-short-urls/13448/9

@stevesobol
Copy link

@acotiuga yes, I think I misunderstood the original problem. I'll dig into it when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants