0

I am trying to integrate Spring with JSF.

@ManagedBean
@ViewScoped
public class SomeBean() implements Serializable{

    @Autowired
    private SomeService someService;   // with get and set
...
    @PostConstruct
public void init() {
      FacesContextUtils
    .getRequiredWebApplicationContext(FacesContext.getCurrentInstance())
    .getAutowireCapableBeanFactory().autowireBean(this.someService);
}

}

@Service
public class SomeServiceImpl implements SomeService{

    @Autowired
    SomeDao someDao;
...
}

I always get null the someService from bean; it does not inject any value. This is the error that returns us:

javax.servlet.ServletException: JBAS011048: No logró construir la instancia del componente javax.faces.webapp.FacesServlet.service(FacesServlet.java:606).

Can anyone please tell me how to do this properly.Thanks in advance.

we rely on the following Links: Spring JSF integration: how to inject a Spring component/service in JSF managed bean?

@Autowired Spring service not injected in a managed bean

Community
  • 1
  • 1

1 Answers1

-1

Take a look at this post in order to integrate spring with JSF.

olexd
  • 1,360
  • 3
  • 13
  • 26
  • Hi olexd. In fact I already implement the solution as suggested in the link you sent me, in section: Spring Annotations. I did the same but I have one error which is that is not injecting: @Autowired UserBo userBo; public void setUserBo(UserBo userBo) { this.userBo = userBo; } public String printMsgFromSpring() { return userBo.getMessage(); } There is no exception thrown but its value is null. Do you know why this is happening? Thanks in advance. – Juan Peralta Jan 27 '16 at 17:10