Hi Daniel
Thanks for the reply.
I have not used a webapp META-INF/context.xml before. So I had tried to
refer to online examples.
This is what I did.
- Create context.xml in webapp/META-INF
- This is what I have added in context.xml
> -
> - <?xml version="1.0" encoding="UTF-8"?>
> - <Context copyXML="true" unpackWAR="true">
> - <Valve className="org.apache.catalina.valves.rewrite.RewriteValve"/>
> - </Context>
>
> My rewrite.config in webapp/WEB-INF
RewriteCond %{REQUEST_FILENAME} !-f
>
> RewriteCond %{REQUEST_FILENAME} !-d
>
> RewriteCond %{REQUEST_URI} !index
>
> RewriteRule (.*) index.jsp [L]
>
>
And in my localhost.log
24-Nov-2014 10:39:56.163 FINE [localhost-startStop-1]
>> org.apache.catalina.valves.rewrite.RewriteValve.startInternal Read
>> configuration from: /WEB-INF/rewrite.config
>
> 24-Nov-2014 10:39:56.163 FINE [localhost-startStop-1]
>> org.apache.catalina.valves.rewrite.RewriteValve.parse Add rule with pattern
>> (.*) and substitution index.jsp
>
> 24-Nov-2014 10:39:56.163 FINE [localhost-startStop-1]
>> org.apache.catalina.valves.rewrite.RewriteValve.parse Add condition !-f
>> test %{REQUEST_FILENAME} to rule with pattern (.*) and substitution
>> index.jsp
>
> 24-Nov-2014 10:39:56.163 FINE [localhost-startStop-1]
>> org.apache.catalina.valves.rewrite.RewriteValve.parse Add condition !-d
>> test %{REQUEST_FILENAME} to rule with pattern (.*) and substitution
>> index.jsp
>
> 24-Nov-2014 10:39:56.163 FINE [localhost-startStop-1]
>> org.apache.catalina.valves.rewrite.RewriteValve.parse Add condition !index
>> test %{REQUEST_URI} to rule with pattern (.*) and substitution index.jsp
>
>
Seems that all the required components starts up fine. But I received this
error when i try to access http://localhost:8080/{webapp}/, it shows the
following on the response.
*type* Exception report
>
> *message* *The resource path [null] is not valid*
>
> *description* *The server encountered an internal error that prevented it
> from fulfilling this request.*
>
> *exception*
>
> java.lang.IllegalArgumentException: The resource path [null] is not valid
>
> org.apache.catalina.webresources.StandardRoot.validate(StandardRoot.java:237)
>
> org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:199)
>
> org.apache.catalina.webresources.StandardRoot.getResource(StandardRoot.java:193)
>
> org.apache.catalina.valves.rewrite.ResolverImpl.resolveResource(ResolverImpl.java:151)
>
> org.apache.catalina.valves.rewrite.RewriteCond$ResourceCondition.evaluate(RewriteCond.java:82)
>
> org.apache.catalina.valves.rewrite.RewriteCond.evaluate(RewriteCond.java:235)
>
> org.apache.catalina.valves.rewrite.RewriteRule.evaluate(RewriteRule.java:105)
>
> org.apache.catalina.valves.rewrite.RewriteValve.invoke(RewriteValve.java:311)
>
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
>
> org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
>
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
>
> org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
>
> org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
>
> org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:277)
>
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2381)
>
> org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2370)
>
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>
> org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
> java.lang.Thread.run(Thread.java:745)
>
> Checking localhost_access.log gives me
127.0.0.1 - - [24/Nov/2014:10:42:18 +0800] "GET /web/ HTTP/1.1" 500 2990
I cannot figure out what is the problem, because I can't find anymore
errors, or stacktrace in any of my logfiles, catalina.stderr etc...
I can't find any information with regard to resource path [null]. What have
I missed out?
On Fri, Nov 21, 2014 at 8:28 PM, Daniel Mikusa <[email protected]> wrote:
> On Thu, Nov 20, 2014 at 9:08 PM, Tay Kai Yang <[email protected]>
> wrote:
>
> > Hi
> > I have been reading up tomcat 8's user doc. But I have some problems
> > understanding the setup of rewrite valve. I think I should add the
> rewrite
> > valve class name and XML settings to /conf/server.xml, but I am not sure
> > what to do next. Where should I place my rewrite.config, how do I
> activate
> > rewrite my war context only?
> >
>
> See the second option here...
>
> http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html#Configuration
>
> "It can also be in the context.xml of a webapp. The valve will then use a
> rewrite.config file containing the rewrite directives, it must be placed in
> the WEB-INF folder of the web application"
>
>
> >
> > Have anyone written a tutorial or can point me to a source for how-to?
> >
>
> The docs seem pretty thorough but if you need a tutorial you could look for
> a mod_rewrite tutorial. This valve is designed to be similar to
> mod_rewrite, so a tutorial for that should be mostly applicable here.
>
> Dan
>
>
> > I am trying to set a single page angularjs app to point
> > /context/path/path/... To /context/index.jsp
> >
> > Any idea on how to do that?
>
>
> > Thanks.
> > Kai yang
> >
>
--
Tay Kai Yang
Mobile: (+65) 94879678
Email: [email protected]
Skype: Kaiyang.Tay