When I remove rewrite, it works fine.
Thanks for your help.
AFAIK Lincoln just tested in AS7. He also created an integration tests to verify that Rewrite behaves correctly for this. I’m currently working on getting our integration test suite to run on Glassfish: