Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8CF9CDC2 for ; Mon, 24 Nov 2014 06:25:51 +0000 (UTC) Received: (qmail 74070 invoked by uid 500); 24 Nov 2014 06:25:48 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 74006 invoked by uid 500); 24 Nov 2014 06:25:48 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 73995 invoked by uid 99); 24 Nov 2014 06:25:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Nov 2014 06:25:48 +0000 X-ASF-Spam-Status: No, hits=2.5 required=5.0 tests=FREEMAIL_REPLY,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ameer.mawia@gmail.com designates 209.85.217.175 as permitted sender) Received: from [209.85.217.175] (HELO mail-lb0-f175.google.com) (209.85.217.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 24 Nov 2014 06:25:44 +0000 Received: by mail-lb0-f175.google.com with SMTP id u10so3860393lbd.6 for ; Sun, 23 Nov 2014 22:25:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=cChsF6SWwUZvVL4aMDW7hVE5WIRNruLlnzhToM9aeOU=; b=YDY1qVq4LmtMXLfwJpQhgu72sxLujhQCuRhK2jLyWsWQLn8edV6cpWnClCPJ3l0Biw ES4LCUhgA1COnO5lLIehgkB3z89JtaompwJKO4X9LKBu7xiJoRkrRQBBGKWIvQhayi0O 8A6lOZammFrdYn1xUHu1caixSS8qC/2EyjHSWf1rWU4gYdwPlXPVAapMvBJH9RTg0n4i NnDqfCRxivEnxpxe6QXCAOCZ/wKwGM1Hj31HCsg6kTGRZ/hpUrwAtJQUCnfXwbUcv8TP MLQgsx3Ph/whrlRnMfylgUo6fC5CdB+p5lB+E+5S7VhnUDehc6uoKnJDQVgLvA+3WWu0 zY8w== MIME-Version: 1.0 X-Received: by 10.112.247.43 with SMTP id yb11mr18610680lbc.51.1416810323145; Sun, 23 Nov 2014 22:25:23 -0800 (PST) Received: by 10.25.161.132 with HTTP; Sun, 23 Nov 2014 22:25:23 -0800 (PST) Received: by 10.25.161.132 with HTTP; Sun, 23 Nov 2014 22:25:23 -0800 (PST) In-Reply-To: References: Date: Mon, 24 Nov 2014 11:55:23 +0530 Message-ID: Subject: Re: How to setup rewrite valve for angularjs From: Ameer Mawia To: Tomcat Users List Content-Type: multipart/alternative; boundary=001a1134de920679c6050894dc80 X-Virus-Checked: Checked by ClamAV on apache.org --001a1134de920679c6050894dc80 Content-Type: text/plain; charset=UTF-8 correction: On Nov 24, 2014 11:54 AM, "Ameer Mawia" wrote: > > > On Nov 24, 2014 8:30 AM, "Tay Kai Yang" wrote: > > > > 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 > > > > > > > - > > > - > > > - > > > - > > > - > > > > > > 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) > > > > > Taking hints from doc page, http://tomcat.apache.org/tomcat-8.0-doc/rewrite.html and your log, you seems to be missing path prex in your substitution string. Can you prefix /to index.jsp to your substituion string. That is: > > RewriteRule (.*) index.jsp [L] RewriteRule (.*) /index.jsp [L] > > > > > 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 wrote: > > > > > On Thu, Nov 20, 2014 at 9:08 PM, Tay Kai Yang > > > 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: Kaiyang.Tay@Gmail.com > > Skype: Kaiyang.Tay > > Regards, > Ameer Mawia --001a1134de920679c6050894dc80--