1

I have User class with overloaded methods:

    public boolean checkAccessAvoid(Role... groups) {
        ...
    }

    public boolean checkAccessAvoid(String string) {
        ...
    }

Controller:

    @RequestMapping(method = RequestMethod.GET, value = "list")
    public ModelAndView list(...) {
        ModelAndView mav = new ModelAndView();

        mav.addObject("user", Session.getUser());
        mav.addObject("notAllowedToAddGameUsers", AccessUtils.GroupArrayToString(Permission.MAIN_GAME_NOT_ALLOWED_TO_ADD_GAME));

        mav.setViewName("home");

        return mav;
    }
  • In notAllowedToAddGameUsers object, I have a string where all roles of users are listed. In my case, it looks like: '-Guest-GameDeveloper-GameQA-TechnicalWriter'

home.jsp:

<c:set var="test" value="${user.checkAccessAvoid(notAllowedToAddGameUsers)}" />
<% System.out.println( "result = " + pageContext.findAttribute("test") ); %>

The problem is when I try to get my list I face with an error:

SEVERE: Servlet.service() for servlet [appServlet] in context with path [] threw exception [An exception occurred processing JSP page /WEB-INF/views/home.jsp at line 26

26:                  <c:set var="test" value="${user.checkAccessAvoid(notAllowedToAddGameUsers)}" />
27:                  <% System.out.println( "result = " + pageContext.findAttribute("test") ); %>
javax.el.ELException: Cannot convert '-Guest-GameDeveloper-GameQA-TechnicalWriter' of type class java.lang.String to class com.domain.enums.Role

I tried to change varargs params to array and it worked, however there are a lot of places where method invokes with Role type parameter. So I want to understand why this error happens.

I3rutt
  • 574
  • 4
  • 18

0 Answers0