[jboss-user] [JBoss Seam] - Re: Seam Security: isUserInRole() expression

jeffconstantin do-not-reply at jboss.com
Wed Apr 11 10:40:56 EDT 2007


Thanks Shane,

I know this is a configuration issue, either a wrong version of a jar file for something. It should be simple but it is driving me nuts. Do you know of a working example that uses s:hasRole?

I tried s:hasRole('admin') as follows and it throws the following exception when I hit that page. Is it using the same Seam taglib or do I have to add a new taglib?
<h:selectOneMenu value="#{switcher.conversationIdOrOutcome}" rendered="#{s:hasRole('admin')}" >
  | 

10:13:42,030 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
  | javax.faces.el.EvaluationException: Cannot get value for expression '#{s:hasRole('admin')}'
  |         at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:402)
  |         at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:1075)
  |         at javax.faces.webapp.UIComponentTag.isSuppressed(UIComponentTag.java:884)
  |         at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java:313)
  |         at org.apache.jsp.logon_jsp._jspx_meth_h_selectOneMenu_0(logon_jsp.java:311)
  |         at org.apache.jsp.logon_jsp._jspx_meth_h_form_0(logon_jsp.java:245)
  |         at org.apache.jsp.logon_jsp._jspx_meth_f_view_0(logon_jsp.java:152)
  |         at org.apache.jsp.logon_jsp._jspService(logon_jsp.java:97)
  |         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
  |         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
  |         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
  |         at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:672)
  |         at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:463)
  |         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:398)
  |         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:301)
  |         at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:416)
  |         at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
  |         at org.jboss.seam.jsf.SeamViewHandler.renderView(SeamViewHandler.java:59)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
  |         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |         at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  |         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  |         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |         at java.lang.Thread.run(Thread.java:595)
  | Caused by: javax.faces.el.ReferenceSyntaxException: Functions not supported in expressions. Function: s:hasRole
  |         at org.apache.myfaces.el.ValueBindingImpl$1.resolveFunction(ValueBindingImpl.java:71)
  |         at org.apache.commons.el.FunctionInvocation.evaluate(FunctionInvocation.java:148)
  |         at org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:383)
  |         ... 46 more
  | 

The documentation states that I have to use the following view-handler for this to work. If I add the component as follows to the the faces-config.xml file the pages will not load period. 
    <application>
  |        <view-handler>org.jboss.seam.ui.facelet.SeamFaceletViewHandler</view-handler>
  |     </application>
  | 
  | 


Exception (Is this using the wrong view-handler?):
10:33:44,612 ERROR [STDERR] Apr 11, 2007 10:33:44 AM com.sun.facelets.FaceletViewHandler handleRenderException
  | SEVERE: Error Rendering View[/logon.jsp]
  | com.sun.facelets.FaceletException: Error Parsing /logon.jsp: Error Traced[line: 4] The content of elements must consist of well-formed character data or markup.
  |         at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)
  |         at com.sun.facelets.compiler.Compiler.compile(Compiler.java:105)
  |         at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:197)
  |         at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:144)
  |         at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:95)
  |         at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:496)
  |         at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:546)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
  |         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:57)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
  |         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
  |         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
  |         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
  |         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
  |         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
  |         at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
  |         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
  |         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  |         at org.jboss.web.tomcat.tc5.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
  |         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
  |         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
  |         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
  |         at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
  |         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
  |         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
  |         at java.lang.Thread.run(Thread.java:595)
  | 

My Logon.jsp page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  | 
  | <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
  | <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
  | <%@ taglib uri="http://jboss.com/products/seam/taglib" prefix="s" %>
  | 
  | <f:view>
  | <f:loadBundle basename="messages" var="msg"/>
  |  <head>
  |   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  |   <title><h:outputText value="#{msg.Application} #{msg.LoginTitle}"/></title>
  |   <style type="text/css" media="all">
  | 	@import "style/default/screen.css";
  |   </style>
  |  </head>
  |  <body>
  |  
  |   <h1><h:outputText value="#{msg.Application} #{msg.Authentication}"/></h1>
  |  
  |    <h:form>
  | 
  |      <div class="rvgSwitch"  rendered="#{identity.loggedIn}" >  
  |         <h:selectOneMenu value="#{switcher.conversationIdOrOutcome}" rendered="#{s:hasRole('admin')}" >
  | 	         <f:selectItem itemLabel="#{msg.createUser}" itemValue="editEdmUsers" />
  | 	         <f:selectItem itemLabel="#{msg.createRole}" itemValue="editEdmRoles" />
  | 	         <f:selectItem itemLabel="#{msg.createUserRole}" itemValue="editEdmUserRoles" />
  | 	         <f:selectItem itemLabel="#{msg.createBoolean}" itemValue="editEdmBoolean" />
  | 	         <f:selectItem itemLabel="#{msg.createMaster}" itemValue="editEdmMaster" />
  | 	         <f:selectItem itemLabel="#{msg.createColor}" itemValue="editEdmColors" />
  | 	         <f:selectItem itemLabel="#{msg.createCar}" itemValue="editEdmCars" />
  | 	         <f:selectItem itemLabel="#{msg.findUser}" itemValue="findEdmUsers" />
  | 	         <f:selectItem itemLabel="#{msg.findRole}" itemValue="findEdmRoles" />
  | 	         <f:selectItem itemLabel="#{msg.findUserRole}" itemValue="findEdmUserRoles" />
  | 	         <f:selectItem itemLabel="#{msg.findBoolean}" itemValue="findEdmBoolean" />
  | 	         <f:selectItem itemLabel="#{msg.findMaster}" itemValue="findEdmMaster" />
  | 	         <f:selectItem itemLabel="#{msg.findColor}" itemValue="findEdmColors" />
  | 	         <f:selectItem itemLabel="#{msg.findCar}" itemValue="findEdmCars" />
  | 	         <f:selectItems value="#{switcher.selectItems}"/>
  |         </h:selectOneMenu>
  |         <h:selectOneMenu value="#{switcher.conversationIdOrOutcome}" rendered="#{not s:hasRole('admin')}"  >
  | 	         <f:selectItem itemLabel="#{msg.createMaster}" itemValue="editEdmMaster" />
  | 	         <f:selectItem itemLabel="#{msg.findMaster}" itemValue="findEdmMaster" />
  | 	         <f:selectItems value="#{switcher.selectItems}"/>
  |         </h:selectOneMenu>
  |         <h:commandButton action="#{switcher.select}" value="Switch" rendered="#{identity.loggedIn}"/>
  |      </div>
  |     
  |      <div class="rvgFind" >
  |        <fieldset class="rvgFieldSet" >
  |          <legend><h:outputText value="#{msg.Authentication} Form"/></legend>
  |          
  |          <span class="rvgInputs">
  |            <h:outputLabel value="#{msg.Username}" for="username">
  |              <h:inputText value="#{identity.username}" id="username"/>
  |            </h:outputLabel>
  |            <h:outputLabel value="#{msg.Password}" for="password">
  |              <h:inputSecret redisplay="false" value="#{identity.password}" id="password"/>
  |            </h:outputLabel>
  |          </span>
  |          
  |          <span class="rvgActions">
  |            <h:commandButton type="submit" value="#{msg.Login}" action="#{identity.login}" rendered="#{not identity.loggedIn}"/>
  |            <h:commandButton type="submit" value="#{msg.Logout}" action="#{identity.logout}" rendered="#{identity.loggedIn}"/>
  | 	     </span>
  | 	     
  |        </fieldset>
  |      </div>
  | 	 	     
  |    </h:form>
  |    
  |  </body>
  |  </f:view>
  | </html>
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036394#4036394

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036394



More information about the jboss-user mailing list