Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.
(Answer) (Category) Java Apache Project : (Category) Apache JServ 1.0 : (Category) Configuration :
Servlets forbidden when using mod_rewrite?
----------
From: Frank Flannery fflanner@yahoo.com
To: java-apache-users@list.working-dogs.com
Subject: servlets forbidden when using rewrite module?
Date: Mon, May 10, 1999, 8:10 PM

I've gotten JServ 1.0b4 working just fine on my linux
redhat 5.2 installation.  I then compiled in the
mod_rewrite package, which also worked.  

My problem is, as soon as I turn the rewrite engine on
(RewriteEngine on) servlets immmediately stop working,
saying that acces to servlet is forbidden.

The servlet engine definitely seems to be running,
since when I access a jsp, it says "access to
/servlets/org.gjt.jsp.JSPServlet is forbidden" 

This is with no RewriteRules, or anything.  simply the
rewrite engine being on.

When I turn it off, servlets work again.

----------
From: Ed Korthof ed@cloudfactory.org
To: Java Apache Users java-apache-users@list.working-dogs.com
Subject: Re: servlets forbidden when using rewrite module?
Date: Wed, May 12, 1999, 2:05 PM

Hiya --

So it is indeed the case that stat was leaving r->finfo in an invalid
state; when I described this & suggested a patch, one of the people in the
Apache Group decided it wasn't a good idea to trust the value in r->finfo
after a failed stat call, and applied the following (related) patch: 

-----
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/main/http_request.c,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- http_request.c    1999/04/20 23:38:44     1.147
  +++ http_request.c    1999/05/12 16:50:42     1.148
  @@ -265,8 +265,12 @@
               *cp = '\0';
               return OK;
           }
  +     /* must set this to zero, some stat()s may have corrupted it
  +      * even if they returned an error.
  +      */
  +     r->finfo.st_mode = 0;
   #if defined(ENOENT) && defined(ENOTDIR)
  -        else if (errno == ENOENT || errno == ENOTDIR) {
  +        if (errno == ENOENT || errno == ENOTDIR) {
               last_cp = cp;
   
               while (--cp > path && *cp != '/')
-----

This will be in the next version of Apache; please apply it rather than
the previously posted patch, and if you encounter any problems, drop me a
note.

thanks for the bug report!

Ed
I encountered this too and after scouring the rewrite_mod documentation, found a workaround!

RewriteEngine On
# whoops! with RewriteEngine On, JServ doesn't find about about servlets
# until we poke a hole like so (repeat for all zones):
RewriteRule ^/servlets/.* - [passthrough]
# redirect root to some servlet (requires mod_proxy)
RewriteRule ^/$ /servlets/SomeServlet [proxy]
tjmATusaDOTnet
[Append to This Answer]
Previous: (Answer) How do I turn off the JIT?
Next: (Answer) Why does my Apache JServ log file gets so big?
This document is: http://java.apache.org/faq/?file=158
[Search] [Appearance] [Show Expert Edit Commands]
This is a Faq-O-Matic 2.709.
Please browse the categories below to previous answers to questions like yours. If you do not find the answer for your particular situation, ask for help on the appropriate mailing list.