I migrated a Primefaces 6 application to JBoss EAP 7.4 and upgraded to Primefaces 10 and JSF2.2 to JSF2.3. After this migration, the @Inject we had in the FacesConverter is not being initialized and thus returning null. This question might be duplicate (https://stackoverflow.com/a/47447140/1918516), the proposed answers did not resolve my issue.
Below my current project structure.
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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/web-facesconfig_2_3.xsd"
version="2.3">
...
</faces-config>
MyConverter.java
@FacesConverter(value = "MyConverter", managed = true)
@FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class MyConverter implements Converter {
...
@Inject
private MyBean myBean;
}
MyBean.java
@Stateless
@Named
public class MyBean{
...
}
Jsf23Activator.java
@ApplicationScoped
@FacesConfig(version = FacesConfig.Version.JSF_2_3)
public class Jsf23Activator {
}
web.xml
<web-app 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/web-app_4_0.xsd"
version="4.0">
...
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>javax.faces.validator.ENABLE_VALIDATE_WHOLE_BEAN</param-name>
<param-value>true</param-value>
</context-param>
</web-app>
I have not created a beans.xml as it is not required with newer versions as far as i know. Also when creating one, i got the common error:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type MyDao with qualifiers @Default
I got it work for the converters by injecting with
CDI.current().select(MyBean.class).get();
but for me this is just a workaroundAnother approach would be to make a @Named out of the MyConverter and use following in my jsf, but that would be ideal for JSF 2.2 not 2.3 :
<h:inputSomething ...> <f:converter binding="#{myConverter}" /> </h:inputSomething>