4 Replies Latest reply on Jul 18, 2011 9:43 AM by bcn

    ELException in jsf class name conversion in AS 7

    bcn

      I get an exception in a web app that works perfectly in AS 6 with the same Mojarra and RichFaces 4 version.

       

      The jsf page has

       

      <rich:graphValidator groups="#{bean.notEmptyCity}">

       

      The corresponding bean method is:

       

      public String getNotEmptyCity() {

       

      return NoConstraintGroup.class.getName();

       

      }

       

      But throws:

       

      Caused by: javax.el.ELException: /templates/searchlocation.xhtml @9,54 groups="#{bean.notEmptyCity}": Cannot convert com.myapp.web.constraint.group.NoConstraintGroup of type class java.lang.String to class [Ljava.lang.Class;

       

      Very strange that, using the same versions of JSF, in AS 7 it throws an exception!

       

      Thanks,

      Ulrich

        • 1. Re: ELException in jsf class name conversion in AS 7
          ssilvert

          It's the same JSF, but a different impl version of EL.  I'm not sure what the groups attribute is expecting.  Does it work when you leave off the getName()?

           

          Stan

          • 2. Re: ELException in jsf class name conversion in AS 7
            bcn

            No, it crashes, too:

             

            Caused by: javax.el.ELException: /templates/searchlocation.xhtml @9,54 groups="#{bean.notEmptyCity}": Cannot convert interface com.myapp.web.constraint.group.NoConstraintGroup of type class java.lang.Class to class [Ljava.lang.Class;

                at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]

                at org.richfaces.validator.FacesBeanValidator.getGroups(FacesBeanValidator.java:168) [richfaces-components-ui-4.0.0-20110322.220419-243.jar:]

                at org.richfaces.validator.FacesBeanValidator.validate(FacesBeanValidator.java:110) [richfaces-components-ui-4.0.0-20110322.220419-243.jar:]

             

            You are right that in fact the attribute groups should be of type Class, but AS 6 / EL is so robust that it works correctly.

             

            Thanks

            • 3. Re: ELException in jsf class name conversion in AS 7
              jaikiran

              Looking at the stacktrace, it's expecting a Class array. So try:

               

              public Class<?>[] getNotEmptyCity() {
              
              return new Class<?>[] {NoConstraintGroup.class};
              
              }
              

               

              I, however, have no clue why it's expecting that Class array type and why it works differently in previous AS version.

              • 4. Re: ELException in jsf class name conversion in AS 7
                bcn

                Thanks, that works!

                It seems to be more stringent than previous versions and allows now only class arrays. For the ease of migration, I doubt that this is a good idea.

                Below the relevant section of the Java EE 6 Tutorial.

                 

                --------------------------------------------

                When a constraint is added to an element, the constraint declares which groups that constraint

                belongs by specifying the class name of the group interface name in the groups element of the

                constraint.

                 

                @NotNull(groups=Employee.class)

                Phone workPhone;

                 

                Multiple groups can be declared by surrounding the groups with angle brackets ({ and }) and

                separating the groups class names with commas.

                 

                @NotNull(groups={ Employee.class, Contractor.class })

                Phone workPhone;