I have a JSF managed bean to create app dependent User instances (UserFactory interface implementor). I'd like to use this factory in the EJB container. The app throws a NullPointerException because the value of the UserWithRolesDAL.userFactory is null. But why?
@Stateless
@LocalBean
public class UserWithRolesSER
{
@Inject
private UserWithRolesBUS userBUS;
...
}
@Dependent
class UserWithRolesBUS
{
@Inject
private UserWithRolesDAL userDAL;
...
}
@Dependent
class UserWithRolesDAL
{
@ManagedProperty( value = "#{userFactory}" )
private UserFactory userFactory;
...
}
public interface UserFactory
{
public UserWithRoles createUser();
}
@ManagedBean
@ApplicationScoped
@Named( value = "userFactory" )
public class XUserFactory implements UserFactory
{
...
}