1

I am currently trying to learn java ee basics and there is a simple jsf example project to get learn intelliJ idea as well. Before IntelliJ I was able to develop jsf project with maven in Eclipse and they were working good but when i did the exact same things in the same order (project from webapp archetype, add dependencies to pom, run maven, add jsf servlet to web xml and deploy) I got 404 error in return. Don't know if it arrises from some config must be done in intellij or something independent from intellij.

So here is my code and when i type localhost:8080/faces/index.xhtml either the faces servlet does not get triggered or something else happens so that the xhtml page is not found

1-project structure:

enter image description here

2-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>

Most probably these two can explain the issue. Thanks for any help :)

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Onur Emrecan Özcan
  • 642
  • 1
  • 6
  • 14
  • 1
    So, the webapp is deployed without context path? By default (at least, in Eclipse), it's the project name (which is afterwards configureable, but you did nowhere mention that). In other words, how exactly are you so sure that the URL `localhost:8080/faces/index.xhtml` is correct? The 404 error clearly says it isn't. – BalusC Oct 09 '15 at 06:53
  • Yes there must be something like that but since i am new to intellij i dont know how to handle theese things :( I've just set a context path as pms and tried this url: http://localhost:8080/pms/faces/index.xhtml. still 404 – Onur Emrecan Özcan Oct 09 '15 at 07:05
  • Server normally logs context path when webapp is successfully deployed. It also normally logs any deployment fails. – BalusC Oct 09 '15 at 07:09
  • I thing there is no fail on deployement. Logs says "Deployement .. has finished" and related stuff but not any deployement fail – Onur Emrecan Özcan Oct 09 '15 at 07:20

2 Answers2

2

I saw this post late, but I hope it helps someone else.

Under Project Structure makes sure you configured JSF:

jsf

Angelina
  • 2,175
  • 10
  • 42
  • 82
  • 1
    I am really sorry but I converted this app as an eclipse project and the same code worked with no error, nothing.. So there is no way to check it if your solution works or not. I deleted intellij since i am not familiar with it and (actually because of I don't like) now using eclipse. As I said before, even if this solution works, I can not mark it as solved. But appreciated your help, thank you :) – Onur Emrecan Özcan May 05 '16 at 19:30
  • believe it or not, but I had xercesImpl-2.6.2 (xml-apis-1.3.02) that was causing my jsf to fail loading. Replacing it with newer version: xercesImpl-2.11.0 + xml-apis-1.4.01) fixed it. – Angelina May 05 '16 at 19:35
  • this is not believe or not decision. I cannot check it, there is no project and ide anymore. Again, thank you for effort – Onur Emrecan Özcan May 05 '16 at 19:40
0

You almost certainly failed to add a web facet and artifact to your project. See the IntelliJ documentation.

jwenting
  • 5,505
  • 2
  • 25
  • 30
  • Searching, trying but can't find anything valuable. In eclipse, it works. Where am i wrong? In documentations, they explained how to add jsf module which i tried but this did not work as well. Can u explain a bit more plesa? – Onur Emrecan Özcan Oct 09 '15 at 08:20
  • I have just tried this code on eclipse and it worked.. Seems i should work on eclipse till i get better to understand configrations then pass to intellij – Onur Emrecan Özcan Oct 09 '15 at 11:52