2

I´m a JSF-Beginner and try to build a small JSF2 webapplication with Spring and Hibernate. My Server of Choice is the JBOSS 7.1 AS.

I´ve encountered an odd Error while trying to map a servlet with a Prefix URL-Pattern. This is the part of the web.xml that declares the Servlet:

<servlet>
    <servlet-name>FacesServlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>FacesServlet</servlet-name>
    <url-pattern>/webapplication/*</url-pattern>
</servlet-mapping>

If I now direct my Browser to "localhost:8080/myapp/webapplication/index.xhtml" I get a Mojarra/Facelets generated Error: "/index.xhtml Not Found in ExternalContext as a Resource". If I instead configure the URL-Pattern to "*.xhtml" everything is working fine.

I have simply no idea why the Prefix-Pattern isn´t working :/

Greetings

Xecu
  • 101
  • 1
  • 5
  • @Petr: If he didn't, he wouldn't have gotten the error page at all :) – BalusC Aug 20 '12 at 13:49
  • @BalusC: yeah, that's right. I am really getting tired today:) – Petr Mensik Aug 20 '12 at 13:53
  • Another thing I discovered: If I use a welcome-file "/wepapplication/index.xhtml" and than direct the browser to my application suprisingly shows a result... or not. Instead of a FileNotFound-Error I get an empty page. Looking at its sourcecode I can see that it contains the uncompiled JSP-Code. Still, this only occures if I use a Prefix-pattern. – Xecu Aug 21 '12 at 12:38

1 Answers1

1

I found the solution :D!

When using a prefix-pattern I thought i had to place my xhtml-files in a folder of that name. For example I used the pattern "/webapplication/*" so I created a folder "webapplication" and placed my webfiles in there. Now, when directing my Browser to "{host}/myapp/webapplication/index.xhtml" I expected the Server to search the files in "{root}/webapplication/index.xhtml". Instead, the Servlet resolved the URL as "{host}/myapp/index.xhtml". Because the file isn´t placed there, I get a FileNotFound-Error.

I also learned not to give my resource-folders the same name as my url-patterns.

Xecu
  • 101
  • 1
  • 5