2

I have coded my first JSF hello world program in eclipse with WildFly 18, jdk-13.0.1. , windows 10.

Wildfly home and admin console working find but While executing program from url http://localhost:8080/jsf1/faces/WEB-INF/helloworld.xhtml it gives 404 - Not Found error. I get same error on url http://localhost:8080/jsf1

This is web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
  <display-name>jsf1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <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>
</web-app>

and below is wildfly server log

2020-01-06 10:59:19,677 INFO  [org.jboss.as.patching] (MSC service thread 1-2) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
2020-01-06 10:59:19,694 WARN  [org.jboss.as.domain.management.security] (MSC service thread 1-6) WFLYDM0111: Keystore C:\Program Files\wildfly-18.0.1.Final\standalone\configuration\application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost
2020-01-06 10:59:19,702 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-3) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Program Files\wildfly-18.0.1.Final\standalone\deployments
2020-01-06 10:59:19,723 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "jsf2.war" (runtime-name: "jsf2.war")
2020-01-06 10:59:19,720 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) WFLYSRV0027: Starting deployment of "jsf1.war" (runtime-name: "jsf1.war")
2020-01-06 10:59:19,827 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
2020-01-06 10:59:20,856 INFO  [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBossWS 5.3.0.Final (Apache CXF 3.3.3) 
2020-01-06 10:59:25,045 INFO  [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-6) ISPN000128: Infinispan version: Infinispan 'Infinity Minus ONE +2' 9.4.16.Final
2020-01-06 10:59:25,635 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 77) WFLYCLINF0002: Started client-mappings cache from ejb container
2020-01-06 10:59:26,604 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 80) Initializing Mojarra 2.3.9.SP04 for context '/jsf1'
2020-01-06 10:59:26,610 INFO  [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 78) Initializing Mojarra 2.3.9.SP04 for context '/jsf2'
2020-01-06 10:59:27,168 ERROR [stderr] (ServerService Thread Pool -- 80) javax.faces.FacesException: Unable to find CDI BeanManager

2020-01-06 10:59:27,169 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.applicationimpl.Version.isJsf23(Version.java:62)

2020-01-06 10:59:27,169 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.applicationimpl.ExpressionLanguage.addELResolver(ExpressionLanguage.java:136)

2020-01-06 10:59:27,170 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.ApplicationImpl.addELResolver(ApplicationImpl.java:221)

2020-01-06 10:59:27,170 ERROR [stderr] (ServerService Thread Pool -- 80)    at org.jboss.as.jsf-injection//org.jboss.as.jsf.injection.weld.WeldApplication.<init>(WeldApplication.java:60)

2020-01-06 10:59:27,171 ERROR [stderr] (ServerService Thread Pool -- 80)    at org.jboss.as.jsf-injection//org.jboss.as.jsf.injection.weld.WeldApplicationFactory.getApplication(WeldApplicationFactory.java:52)

2020-01-06 10:59:27,171 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.InjectionApplicationFactory.getApplication(InjectionApplicationFactory.java:61)

2020-01-06 10:59:27,172 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.config.InitFacesContext.getApplication(InitFacesContext.java:109)

2020-01-06 10:59:27,173 ERROR [stderr] (ServerService Thread Pool -- 80)    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.lifecycle.ClientWindowFactoryImpl.<init>(ClientWindowFactoryImpl.java:39)

2020-01-06 10:59:27,173 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

2020-01-06 10:59:27,174 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

2020-01-06 10:59:27,174 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

2020-01-06 10:59:27,174 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)

2020-01-06 10:59:27,175 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)

2020-01-06 10:59:27,175 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)

2020-01-06 10:59:27,176 ERROR [stderr] (ServerService Thread Pool -- 80)    at java.base/java.lang.Class.newInstance(Class.java:591)

last lines of log

Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:357)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:205)
    ... 21 more
Caused by: java.lang.NullPointerException
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.facelets.impl.DefaultResourceResolver.resolveUrl(DefaultResourceResolver.java:40)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.facelets.impl.DefaultFaceletFactory.init(DefaultFaceletFactory.java:129)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.ApplicationAssociate.createFaceletFactory(ApplicationAssociate.java:849)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.ApplicationAssociate.initializeFacelets(ApplicationAssociate.java:342)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.application.ApplicationAssociate.getCompiler(ApplicationAssociate.java:420)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:217)
    at com.sun.jsf-impl@2.3.9.SP04//com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:341)
    ... 22 more

2020-01-06 10:59:28,236 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "jsf1.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"jsf1.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.NullPointerException"}}
2020-01-06 10:59:28,466 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "jsf2.war")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"jsf2.war\".undertow-deployment" => "java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
    Caused by: java.lang.NullPointerException"}}
2020-01-06 10:59:28,518 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "jsf2.war" (runtime-name : "jsf2.war")
2020-01-06 10:59:28,519 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "jsf1.war" (runtime-name : "jsf1.war")
2020-01-06 10:59:28,521 INFO  [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186:   Services which failed to start:      service jboss.deployment.unit."jsf2.war".undertow-deployment: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
      service jboss.deployment.unit."jsf1.war".undertow-deployment: java.lang.RuntimeException: java.lang.RuntimeException: com.sun.faces.config.ConfigurationException: CONFIGURATION FAILED! null
WFLYCTL0448: 2 additional services are down due to their dependencies being missing or failed
2020-01-06 10:59:28,735 INFO  [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
2020-01-06 10:59:28,745 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
2020-01-06 10:59:28,745 INFO  [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
2020-01-06 10:59:28,745 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 18.0.1.Final (WildFly Core 10.0.3.Final) started (with errors) in 29279ms - Started 496 of 731 services (6 services failed or missing dependencies, 379 services are lazy, passive or on-demand)

folder tree: folder tree

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
user584910
  • 525
  • 2
  • 8
  • 17
  • 2
    What does your pom.xml and files/folders tree look like? `/jsf1/faces/WEB-INF/helloworld.xhtml` is a strange request path btw. – Selaron Jan 06 '20 at 09:08
  • 2
    Yes, both 404's can be explained without any relation to the startup prtoblem UNLESS the complete deployment fails, which is the case in your situation, then it is very normal. And did you by any chance include jsf in your war (that is what Selaron most likely wants to deduce from the pom.xml) – Kukeltje Jan 06 '20 at 09:33
  • @Selaron Thanks. I am not aware of pom.xml file in a non-maven project. I can not find it. I simply created a dynamic web project in eclipse. I then, created helloworld.xhtml file in WebContentf\WEB-INF directory, everything is left as default. This is screenshot of project https://ibb.co/SVf131Q – user584910 Jan 06 '20 at 10:30
  • 1
    Ok, did you try posting _"javax.faces.FacesException: Unable to find CDI BeanManager"_ in a search engine? – Kukeltje Jan 06 '20 at 11:02
  • @Kukeltje yes I am still searching for it on the web but could not find a solution yet. – user584910 Jan 06 '20 at 11:41
  • 1
    Your `xhtml` files should be in your WebContent directory not `WEB-INF`. The `WEB-INF` is not exposed as a web directory and definitely should not be. If that was exposed all of your configuration files would be exposed as well. – James R. Perkins Jan 07 '20 at 01:14
  • @JamesR.Perkins. Yes, my bad. I moved them to WebContent but fortunately I am getting the same error. – user584910 Jan 07 '20 at 08:56
  • 1
    Can you please check if you have the 'old' `@ManagedBean` annotations in your project? I have not used those for a long time but while investigating https://stackoverflow.com/questions/59667297/session-fixation-and-session-scoped-beans-in-jsf-2-3-with-cdi I by accident ran into this same error and think the annotations are related to it. When I don't use `@ManagedBean` but `@Named` (which I have been doing for ages) I don't get this error when using servlet 4.0 and jsf 2.3 specs – Kukeltje Jan 09 '20 at 22:27
  • @Kukeltje I did not use managed beans, it contains only two .xhtml files, nothing else. I had coded this JSF hello world example by exactly following this tutorial https://www.youtube.com/watch?v=SZ2kxtbFONY the only difference was that i had selected JSF 2.3 and Dynamic Web Module version 4. It did not worked so then I set their versions as 2.2 and 3.1. However, as you commented, – user584910 Jan 11 '20 at 07:16

2 Answers2

7

I have added beans.xml file in WEB-INF directory with the following contents and the errors are gone. Finally I am able to run my hello world program in "Dynamic Web Module version 4.0" and "Java Server Faces version 2.3".

beans.xml contents

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd"
       version="2.0" bean-discovery-mode="annotated">

</beans>
user584910
  • 525
  • 2
  • 8
  • 17
  • 1
    I was following a tutorial with no beans.xml file, and the server was Glassfish, but my server is actually Wildfly and this one needs a beans.xml file! It's funny that two JEE compliants server but the basic config are different. Thanks for this solution. – lyrio Jan 20 '21 at 02:32
-1

I have fixed the error by creating a new project and by changing "Dynamic Web Module version to 3.1" and "Java Server Faces version to 2.2". Previously, they were set as version 4 and 2.3 respectively.

enter image description here

user584910
  • 525
  • 2
  • 8
  • 17
  • 2
    For me this is still a workaround. One of the Q/A you can find by searching for the error you got hits at this solution too, but I find it weird that you cannot really activate 2.3... I'll see if I can investigate this coming weekend – Kukeltje Jan 07 '20 at 10:08
  • 1
    Can you please check if you have the 'old' `@ManagedBean` annotations in your project? I have not used those for a long time but while investigating https://stackoverflow.com/questions/59667297/session-fixation-and-session-scoped-beans-in-jsf-2-3-with-cdi I by accident ran into this same error and think the annotations are related to it. When I don't use `@ManagedBean` but `@Named` (which I have been doing for ages) I don't get this error when using servlet 4.0 and jsf 2.3 specs – Kukeltje Jan 09 '20 at 22:27
  • @Kukeltje I did not use managed beans, it contains only two .xhtml files, nothing else. I had coded this JSF hello world example by exactly following this tutorial https://www.youtube.com/watch?v=SZ2kxtbFONY the only difference was that i had selected JSF 2.3 and Dynamic Web Module version 4. It did not worked so then I set their versions as 2.2 and 3.1. – user584910 Jan 11 '20 at 07:10
  • changing JSF version is not a proper solution, that is why I did not tick to "Accept this as the Answer". – user584910 Jan 11 '20 at 07:17
  • 1
    Let me try tomorrow with a request parameter. Can you in the mean time try with a jsf managed bean and change that into a cdi managed bean to see if it makes a difference (using 4 and 2.3 as versions) – Kukeltje Jan 11 '20 at 09:39
  • Ok, at the movement I am not aware of CDI. I have just started learning JSF, this was my first hello world program. However, I am definitely studying CDI, it would be great if it can lead to solve the the issue. – user584910 Jan 11 '20 at 10:48
  • 1
    check https://jsf.zeef.com for good 2.3 tutorials. The youtube once are often not the best. And with jsf 2.3 you should use cdi managed beans instead of jsf ones. And now you also see why [mcve]'sre relevant – Kukeltje Jan 11 '20 at 12:02