Problem:

I’ve a JavaServer Faces 2 converter (@FacesConverter) and I’ve to access a Spring service. The converter is managed by jsf and if I use @Service or a Spring bean I’ve a null pointer exception

Solution:

access the Spring service using FacesContextUtils. Ex:

<br /> @Override<br /> public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String s) {<br /> ...<br /> if (personneService == null)<br /> personneService = (PersonneService) FacesContextUtils.getWebApplicationContext(facesContext).getBean("personneService");<br /> ...<br /> }<br />