Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The pattern you're using doesn't seem to make a lot of sense. There should be no problem with injecting EJBs into a view scoped bean.</p> <p>Depending on the type of EJB you are using (stateless, stateful or singleton) different things hold. </p> <p>If the userService and emailService are stateless (they most likely should be), you gain nothing by using a bean that's injected into an application scoped bean first. Namely, what's injected is not the bean itself but a proxy and every request to that is routed to a different real bean instance anyway (see <a href="http://en.wikipedia.org/wiki/Enterprise_JavaBean#Stateless_Session_Beans" rel="nofollow">http://en.wikipedia.org/wiki/Enterprise_JavaBean#Stateless_Session_Beans</a>).</p> <p>If the userService and emailService are stateful, you do get a single instance here, but I highly doubt you need to share actual between every user in your application. But even if you would want that, only a single user (thread) can access the stateful bean at a time.</p> <p>If those services are singleton, you can just inject them right away into the view scoped bean. There is absolutely no reason to go via an application scoped bean.</p> <p>Furthermore, <code>ServicesUtil.getUserService()</code> is a static method, so using this to get an injected service is brittle. If you want to use this (you shouldn't, but suppose) <code>ServicesUtil</code> should be injected into <code>UserHandler</code>.</p> <p>Then, it seems you are confusing CDI and JSF managed beans. I agree this is confusing, but it's currently the way it is. <code>@ViewScoped</code> does not work in combination met CDI beans. From your code it's not clear if <code>@ManagedBean</code> is the JSF variant or the Java EE/CDI one. In this case it should be <code>javax.faces.bean.ManagedBean</code> if you want to use the view scope.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload