{"id":928,"date":"2010-09-19T20:46:33","date_gmt":"2010-09-19T20:46:33","guid":{"rendered":"http:\/\/salientsoft.co.uk\/?p=928"},"modified":"2011-11-17T15:18:18","modified_gmt":"2011-11-17T15:18:18","slug":"servlet-mapping-issues-with-glassfish-v3-0-1","status":"publish","type":"post","link":"https:\/\/salientsoft.co.uk\/?p=928","title":{"rendered":"Servlet Mapping Issues with Glassfish V3.0.1"},"content":{"rendered":"<p>There seem to be some servlet mapping issues with Glassfish V3.0.1.<\/p>\n<p>To summarize, the following outlines what the servlet mapping logic should do:-<\/p>\n<ol>\n<li>The &lt;url-pattern&gt; as below matches the input url and if there is a match, passes the url to the designated servlet (in this case the faces servlet).<\/li>\n<li>The url parts that match are stripped out, so that for\u00a0extension mapping e.g.\u00a0\u201c*.jsf\u201d pattern the \u201c.jsf\u201d is removed, and for path mapping\u00a0e.g. \u201c\/faces\/*\u201d pattern the \/faces subdirectory is removed.<\/li>\n<li>The javax.faces.DEFAULT_SUFFIX as below is applied to the result as a file type if one is not present, to give an actual file to be searched for. This is passed to the faces servlet for processing.<\/li>\n<\/ol>\n<p>I tried the same combination in <em>web.xml<\/em> that I had used previously on Glassfish V2.1 with ICEfaces:-<\/p>\n<p style=\"padding-left: 30px;\">&lt;servlet-mapping&gt;<br \/>\n&lt;servlet-name&gt;Faces Servlet&lt;\/servlet-name&gt;<br \/>\n&lt;url-pattern&gt;*.jsf&lt;\/url-pattern&gt;<br \/>\n&lt;\/servlet-mapping&gt;<br \/>\n&lt;context-param&gt;<br \/>\n&lt;param-name&gt;javax.faces.DEFAULT_SUFFIX&lt;\/param-name&gt;<br \/>\n&lt;param-value&gt;.jsf&lt;\/param-value&gt;<br \/>\n&lt;\/context-param&gt;<\/p>\n<p>The actual file type was also .jsf (index.jsf in this case)<br \/>\nThis gave rise to the following intermittent error when run \u2013 it would run once or twice and then blow up:-<\/p>\n<p>url:\u00a0<em> <\/em><a href=\"http:\/\/localhost\/PrimeTest1\/index.jsf\"><em>http:\/\/localhost\/PrimeTest1\/index.jsf<\/em><\/a><br \/>\nerror:\u00a0 <em> javax.servlet.ServletException: PWC1232: Exceeded maximum depth for nested request dispatches: 20<\/em><\/p>\n<p>Changing the actual file type and the above <strong>javax.faces.DEFAULT_SUFFIX<\/strong> value to .xhtml worked correctly in every case.<br \/>\nThis error occurred both with a simple Primefaces test page:-<\/p>\n<p style=\"padding-left: 30px;\">&lt;html xmlns=&#8217;<a href=\"http:\/\/www.w3c.org\/1999\/xhtml'\">http:\/\/www.w3c.org\/1999\/xhtml&#8217;<\/a><br \/>\nxmlns:f=&#8217;<a href=\"http:\/\/java.sun.com\/jsf\/core'\">http:\/\/java.sun.com\/jsf\/core&#8217;<\/a><br \/>\nxmlns:h=&#8217;<a href=\"http:\/\/java.sun.com\/jsf\/html'\">http:\/\/java.sun.com\/jsf\/html&#8217;<\/a><br \/>\nxmlns:p=&#8217;<a href=\"http:\/\/primefaces.prime.com.tr\/ui'\">http:\/\/primefaces.prime.com.tr\/ui&#8217;<\/a>&gt;<br \/>\n&lt;h:head&gt; &lt;\/h:head&gt;<br \/>\n&lt;h:body&gt;<br \/>\n&lt;p:editor \/&gt;<br \/>\n&lt;\/h:body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>and also with a simple JSF page in a non Primefaces JSF 2 faceted eclipse web project:-<\/p>\n<p style=\"padding-left: 30px;\">&lt;html xmlns=&#8221;<a href=\"http:\/\/www.w3.org\/1999\/xhtml&quot;\">http:\/\/www.w3.org\/1999\/xhtml&#8221;<\/a>&gt;<br \/>\n&lt;head&gt;<br \/>\n&lt;title&gt;Test Page Title&lt;\/title&gt;<br \/>\n&lt;\/head&gt;<br \/>\n&lt;body&gt;<br \/>\nTest page body<br \/>\n&lt;\/body&gt;<br \/>\n&lt;\/html&gt;<\/p>\n<p>It was therefore clear that the error was not Primefaces related, but appeared to be recursion caused by a servlet mapping issue. <strong><a title=\"http:\/\/forums.java.net\/jive\/thread.jspa?messageID=403535&amp;#403535\" href=\"http:\/\/forums.java.net\/jive\/thread.jspa?messageID=403535&amp;#403535\">This post on the Glassfish Forums<\/a><\/strong> reported the issue &#8211; there\u00a0was some discussion but no resolution, and I don&#8217;t think\u00a0a bug has been raised.\u00a0\u00a0<a href=\"http:\/\/old.nabble.com\/Unexpected-behaviour-of-Faces-Servlet-on-GlassFish-3-td28497432.html\"><strong>This post<\/strong><\/a> also reported the same issue. Whilst I found a number of other posts too with what seemed like a related issue, there appeared to be no clear conclusion on any of them re the nature of the problem or a fix for it. I tried other combinations such as path mapping using\u00a0\u201c\/faces\/*\u201d for the <strong>url pattern<\/strong>, \u201c.jsf\u201d for the <strong>default suffix<\/strong>, and \u201chttp:\/\/localhost\/PrimeTest1\/faces\/index.jsf\u201d for the <strong>url<\/strong>, but in this case the above error did not occur but a blank page was displayed. On examining the source for the page, it turned out to be the original page source i.e. it had not passed through the faces servlet.<\/p>\n<p>My conclusion is that the servlet mapping\/url pattern handling for Glassfish V3.0.1 has some issues, the precise nature of which is not clear. My solution is to use \u201c.xhtml\u201d for the <strong>actual filetypes<\/strong> and for the <strong>default suffix<\/strong>, and extension mapping\u00a0using \u201c*.jsf\u201d for the <strong>url pattern<\/strong> \u2013 this combination works fine with no issues.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There seem to be some servlet mapping issues with Glassfish V3.0.1. To summarize, the following outlines what the servlet mapping logic should do:- The &lt;url-pattern&gt; as below matches the input url and if there is a match, passes the url to the designated servlet (in this case the faces servlet). The url parts that match [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[13,10,40,184,21],"_links":{"self":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/928"}],"collection":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=928"}],"version-history":[{"count":11,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/928\/revisions"}],"predecessor-version":[{"id":929,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/928\/revisions\/929"}],"wp:attachment":[{"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salientsoft.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}