java ee - @Named + @RequestScoped not working in JSF 2.0 with JBoss 7.1.1 -
i have working @managedbean
i'd substitute @named + @requestscoped
bean.
// before @managedbean public class login { ... } // after import javax.enterprise.context.requestscoped; @named @requestscoped public class login { ... }
everything works fine long use @managedbean
. @named
without @requestscoped
works creates new instance each el-expression. @named + @requestscoped
yields exception: unable add request scoped cache item when request cache not active
java.lang.illegalstateexception: unable add request scoped cache item when request cache not active @ org.jboss.weld.context.cache.requestscopedbeancache.additem(requestscopedbeancache.java:51) @ de.prosis.dafe.presentation.login$proxy$_$$_weldclientproxy.getusername(login$proxy$_$$_weldclientproxy.java) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25) @ java.lang.reflect.method.invoke(method.java:597) @ javax.el.beanelresolver.getvalue(beanelresolver.java:302) @ com.sun.faces.el.demuxcompositeelresolver._getvalue(demuxcompositeelresolver.java:176) @ com.sun.faces.el.demuxcompositeelresolver.getvalue(demuxcompositeelresolver.java:203) @ org.apache.el.parser.astvalue.getvalue(astvalue.java:169) @ org.apache.el.valueexpressionimpl.getvalue(valueexpressionimpl.java:189) @ org.jboss.weld.el.weldvalueexpression.getvalue(weldvalueexpression.java:50) @ com.sun.faces.facelets.el.tagvalueexpression.getvalue(tagvalueexpression.java:109) @ javax.faces.component.componentstatehelper.eval(componentstatehelper.java:194) ...
empty beans.xml
exist. there gotchas or bugs i'm not aware of? bet i'm missing bug. googled exception message haven't found source of class raises it. in advance!
update: related code omitted. login bean tries invalidate session in constructor, fails if named bean (not always, if spam f5 seems works after few times) , works managed bean. can explain behaviour?
public login() { httpsession session = (httpsession) facescontext.getcurrentinstance().getexternalcontext().getsession(false); if (session != null) { session.invalidate(); } }
code comes tutorial: http://www.greenkode.com/2011/09/user-authentication-and-authorization-using-jaas-and-servlet-3-0-login/
fixed removing invalidation of session in constructor. still don't know why @managedbean works , @named not.
Comments
Post a Comment