8 Replies Latest reply on Oct 28, 2007 8:39 PM by Mihai Poplacenel

    Function 's:hasRole' not found

    Chris Malan Novice

      Here is a bit more of the stack trace:

      javax.faces.FacesException: javax.el.ELException: /login.xhtml @36,93 rendered="#{s:hasRole('manager')}":
      Function 's:hasRole' not found
       at javax.faces.component.UIComponentBase.isRendered(UIComponentBase.java:373)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:880)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
       at javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
       at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
       at javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)


      I see this has been reported before, but no clear solution supplied.

      This is the code on the page that causes the problem:

      <s:div rendered="#{identity.loggedIn}">
       <s:link value="Manager Go Home" view="home.xhtml" rendered="#{s:hasRole('manager')}" />
       <s:link value="User Go Home" view="home.xhtml" rendered="#{s:hasRole('user')}" />
      </s:div>


      I can log in with no problem, now I want to go one step further and render a link depending on the role of the user who logged in.

      Any ideas? Any specific jars which I may have missed?

      Thanks,

        • 1. Re: Function 's:hasRole' not found
          Chris Malan Novice

          PS I am using Seam 1.2.1 on JBoss-4.2.0

          • 2. Re: Function 's:hasRole' not found
            Chris Malan Novice

            In addition to the above, the stack trace in the console window gives the following information not found in the Seam window:

            15:54:29,481 ERROR [STDERR] java.lang.ClassNotFoundException: No ClassLoaders found for: org.jboss.seam.security.SecurityFunctions
            15:54:29,481 ERROR [STDERR] at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:212)
            15:54:29,481 ERROR [STDERR] at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:514)
            15:54:29,481 ERROR [STDERR] at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:408)
            15:54:29,481 ERROR [STDERR] at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            15:54:29,481 ERROR [STDERR] at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            15:54:29,481 ERROR [STDERR] at java.lang.Class.forName0(Native Method)
            15:54:29,481 ERROR [STDERR] at java.lang.Class.forName(Class.java:164)


            jboss-app.xml is fine. How can I get JBoss to supply the class-loader to load the class which is in jboss-seam.jar which is in the ear and duly noted in application.xml?

            Thanks

            • 3. Re: Function 's:hasRole' not found
              Gavin King Master

              Are you using JSP or facelets?

              • 4. Re: Function 's:hasRole' not found
                Chris Malan Novice

                Hi Gavin,

                Facelets.

                • 5. Re: Function 's:hasRole' not found
                  Shane Bryzak Master

                  Have you tried this with 1.3.0 alpha? I know we've done some work in this area, it might be a non-issue now.

                  • 6. Re: Function 's:hasRole' not found
                    Chris Malan Novice

                    Hi Shane,

                    I downloaded 1.3.0 and tried. That caused a whole new universe of problems. If I remove jboss-seam.jar from the ear and copy it to $JBOSS_HOME/server/default/lib everything works well. The only problem was

                    <s:link value="User Go Home" view="home.xhtml" rendered="#{s:hasRole('user')}" />
                    should be
                    <s:link value="User Go Home" view="/home.xhtml" rendered="#{s:hasRole('user')}" />


                    This is clearly a class loading problem. Is the JBoss AS responsible for class loading, or the application? I would think it is the AS, in which case the problem lies with JBoss 4.2.0. I'll go and read up in the wiki about class loading.


                    • 7. Re: Function 's:hasRole' not found
                      Chris Malan Novice

                      So far nothing helps. The problem only arises when I perform an action from a xhtml page containing #{s:hasRole(... When I log in from another page and then request the offending page via the browser address field, everything is fine. The links are correctly rendered according to the role of the logged in user. But let me now do something sending data to the server from the page with #{s:hasRole(..., causing the page to be reloaded, and the function s:hasRole has disappeared. Reloading the page with the browser reload button (or ctrl r) works fine.

                      Any idea on how to fix this?

                      • 8. Re: Function 's:hasRole' not found
                        Mihai Poplacenel Newbie

                        I'm seeing the same problem, and I cannot upgrade to Seam 1.3.0 until RedHat Developer Studio accepts it. Could you please help me find a work-around? Thanks.