After following the JSF HTTP Session Login tutorial, i tried clicking on pages and it redirected me always to the login page (without css). I tried debugging using the code below:
Enumeration<String> attributeNames = wrappedRequest.getSession().getAttributeNames();
while(attributeNames.hasMoreElements()) {
System.out.println(attributeNames.nextElement());
}
and found that the class I expected to be return at
ConnectionManager manager = (ConnectionManager) wrappedRequest.getSession()
.getAttribute("connectionManager");
wasn't returned. Some other class was returned instead of ConnectionManager class as seen in the server log.
Info: employeeManager
Info: org.jboss.weld.context.beanstore.http.LockStore
Info: com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap
Info: org.jboss.weld.context.conversation.ConversationIdGenerator
Info: org.jboss.weld.context.ConversationContext.conversations
Info: javax.faces.request.charset
EmployeeManager is another managed bean. Can I know why this is return instead?
That answer was based on the ConnectionManager
being a JSF managed bean. However, based on presence of CDI-specific objects in the session, it looks like that you're using CDI @Named
instead of JSF @ManagedBean
to manage beans (which is at its own a Good Thing though).
You could just @Inject
it into the filter instead of manually grabbing it from the HTTP session.
@Inject
private ConnectionManager connectionManager;