7

I have a JSF2 application I can access my application @ http://tvmteleshopping.com/faces/ui/manageProfile.xhtml

but when i use http://tvmteleshopping.com/ui/manageProfile.xhtml (without /faces/ ) this request is being served by Apache not tomcat. Any only static HTML content is rendered.

I am using Apache to serve static HTML files and tomcat for serving *.xhtml files

My Servlet mapping is fine: web.xml

  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>/faces/*</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
  </servlet-mapping>

My cp_jkmount.conf to redirect jsp and jsf files to tocat server.

<IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JKMount /*.do ajp13
  JKMount /servlet/* ajp13
  JKMount /servlets/* ajp13
  JKMount /*.xhtml ajp13
  JKMount /ui/* ajp13
  JKMount /ui/*.xhtml ajp13
  JKMount /faces/* ajp13
  JKMount /*.jsf ajp13
</IfModule>

I have two cp_jkmount.conf, one in /usr/local/apache/conf/userdata/std/1/myuser/mysite.com/cp_jkmount.conf

and one in /usr/local/apache/conf/userdata/std/2/myuser/mysite.com/cp_jkmount.conf

And my both cp_jkmount are same. I don't know why i do have two cp_jkmount.conf in two different directories.

P.S: my application is working fine for those .xhtml files which are in root folder http://tvmteleshopping.com/index.xhtml

for this i think my cp_jkmout.conf works fine. But for those .xhtml files behind 'ui' folder it doesn't work.

Mohit Saluja
  • 470
  • 7
  • 23
  • 2
    Your `FacesServlet` is mapped to the URL pattern `/faces/*`. Therefore, other patterns won't be intercepted by the FacesServlet – Vrushank May 02 '13 at 09:14
  • @Vrushank i think this fine...as my site is working fine locally. there is some problem with configuration of apache on server. If this is the case as you are telling than http://tvmteleshopping.com/index.xhtml should not be accessible this way (without /faces/). – Mohit Saluja May 02 '13 at 09:17
  • Vrushank is right, you were probably hitting index.xhtml as it might have been mapped as the welcome file. If you do not need /faces prefix then remove and just use *.xhtml. – Ravi Kadaboina May 02 '13 at 14:30
  • @Ravi my application is fine for all .xhtml files in root folder other pages in root folder like http://tvmteleshopping.com/products.xhtml are also working fine. – Mohit Saluja May 03 '13 at 06:34
  • Try removing "/faces/*" mapping. I guess the problem is that JSF is waiting for any pattern starting with /faces/* and ending with .jsf, .xhtml, .faces according to your mapping file. I'm not sure about it. – Diogo Moreira May 04 '13 at 13:11
  • Your servlet mapping configuration works fine for me. Do you have any other servlet defined in you web.xml file other than "Faces Servlet" ? – erencan May 05 '13 at 18:45
  • @DiogoMoreira servlet mappings try to match any of mappings in web.xml. So, it is not looking for both /faces/* and *.xhtml, *.jsf. I am using tomcat v7.0 – erencan May 05 '13 at 18:50
  • @DiogoMoreira if that is the case than my .xhtml files in root folder should not render properly. Further erencan is right in last comment...that tomcat looks for only one of these (/faces/* , *.xhtml) – Mohit Saluja May 06 '13 at 04:57
  • Do you have any other Servlet defined in web.xml? – erencan May 06 '13 at 06:52
  • @erencan I dont think this is a problem. fileServlet com.letuwin.workforce.util.FileServlet fileServlet /documents/* – Mohit Saluja May 06 '13 at 13:53

1 Answers1

2

Why don't you use

http://tvmteleshopping.com/manageProfile.jsf

instead of

http://tvmteleshopping.com/ui/manageProfile.xhml or anything else as the hyperlink?

Let the framework locate the page for you rather than you explicitly mentioning the path.

Niks
  • 4,802
  • 4
  • 36
  • 55
  • i know this way my application will work. Those .xhtml files which are in root folder are fine. I am considering this as last option. I do have a no of .xhtml files in my project an i want to keep all files related to products in product folder and files related to orders in order folder. – Mohit Saluja May 03 '13 at 06:39
  • @MohitSaluja: I hope you know that you don't have to physically place your file in the root folder. The above will work even if your file is actually inside `/ui/` The above URL actually used to work! (now it is showing `OutOfMemory` error :D) – Niks May 12 '13 at 11:41
  • My application works fine locally but on web tomcat treats files behind folders as html files not jsf files. Web.xml is same in both cases. cp_jkmount.conf is new in case of web and i am sure this is the reason of this. Yeh, i know right now its showing OutOfMemory :( – Mohit Saluja May 12 '13 at 14:01
  • @MohitSaluja Hmm..It's NOW that I understood your problem! And sorry I can't help! :-/ I suggest you post this on serverfault.com since this is more relevant to Apache Tomcat configuration! – Niks May 12 '13 at 15:03